Merge pull request #14 from anecdata/Kraken_II

New command handlers for Digital Read and Analog Read. New command for Analog Read.
This commit is contained in:
Brent Rubell
2019-10-23 12:51:22 -04:00
committed by GitHub
8 changed files with 238 additions and 7 deletions

View File

@@ -1,5 +1,16 @@
Adafruit's Arduino NINA-W102 firmware 1.5.0 - 2019.10.21
* Added Digital Read and Analog Read
Adafruit's Arduino NINA-W102 firmware 1.4.0 - 2019.10.09
* Updated to use ESP-IDF 3.3 (LTS)
* Updated WiFiSSLClient
* Workflow improvements in Makefile
Adafruit's Arduino NINA-W102 firmware 1.3.1 - 2019.04.24
* Added WPA2 Enterprise
* Updated README.md to indicate this is Adafruit's fork
* Updated README.md with current, reproducible build instructions
* Updated CHANGELOG with various Adafruit changes

View File

@@ -28,7 +28,7 @@ load-passthrough:
cp passthrough.UF2 $(BOOT_VOLUME)
load-nina:
esptool.py --port $(M4_PORT) --before no_reset --baud $(UPLOAD_BAUD) write_flash 0 NINA_W102-1.4.0.bin
esptool.py --port $(M4_PORT) --before no_reset --baud $(UPLOAD_BAUD) write_flash 0 NINA_W102-1.5.0.bin
load-circuitpython:
cp $(CIRCUITPYTHON_UF2) $(BOOT_VOLUME)
@@ -47,4 +47,4 @@ firmware: all
.PHONY: load-circuitpython
.PHONY: serial
.PHONY: serial

View File

@@ -5,6 +5,20 @@ repository is located at https://github.com/arduino/nina-fw
This firmware uses [Espressif's IDF](https://github.com/espressif/esp-idf)
## Contributing to nina-fw
Please be aware that by contributing to this project
you are agreeing to the [Code of Conduct](https://github.com/adafruit/nina-fw/code-of-conduct.md).
Contributors who follow the [Code of Conduct](https://github.com/adafruit/nina-fw/code-of-conduct.md)
are welcome to submit pull requests and they will be promptly
reviewed by project admins. Please join the [Discord](https://adafru.it/discord) too.
The NINA firmware version needs to be updated in four places in this repo:
1. CommandHandler.cpp
1. combine.py
1. Makefile
1. CHANGELOG
## Building
The firmware shipped in Adafruit's products is compiled following these
@@ -20,7 +34,7 @@ original Arduino firmware repository.
1. Use appropriate tools (esptool.py, appropriate pass-through firmware etc)
to load this binary file onto your board.
a. If you do not know how to do this, [we have an excellent guide on the Adafruit Learning System for upgrading your ESP32's firmware](https://learn.adafruit.com/upgrading-esp32-firmware)
## License

View File

@@ -18,6 +18,9 @@
*/
#include <driver/ledc.h>
#include <driver/adc.h>
#include <esp_adc_cal.h>
#include <soc/adc_channel.h>
#include "wiring_analog.h"
@@ -43,3 +46,49 @@ void analogWrite(uint32_t pin, uint32_t value)
};
ledc_channel_config(&ledc_conf);
}
int analogRead(uint32_t pin, uint32_t atten)
{
#define DEFAULT_VREF 1100
static esp_adc_cal_characteristics_t *adc_chars;
adc_channel_t channel;
switch(pin)
{
case ADC1_CHANNEL_0_GPIO_NUM:
channel = ADC1_GPIO36_CHANNEL;
break;
case ADC1_CHANNEL_1_GPIO_NUM:
channel = ADC1_GPIO37_CHANNEL;
break;
case ADC1_CHANNEL_2_GPIO_NUM:
channel = ADC1_GPIO38_CHANNEL;
break;
case ADC1_CHANNEL_3_GPIO_NUM:
channel = ADC1_GPIO39_CHANNEL;
break;
case ADC1_CHANNEL_4_GPIO_NUM:
channel = ADC1_GPIO32_CHANNEL;
break;
case ADC1_CHANNEL_5_GPIO_NUM:
channel = ADC1_GPIO33_CHANNEL;
break;
case ADC1_CHANNEL_6_GPIO_NUM:
channel = ADC1_GPIO34_CHANNEL;
break;
case ADC1_CHANNEL_7_GPIO_NUM:
channel = ADC1_GPIO35_CHANNEL;
break;
default:
return -1;
}
adc1_config_width(ADC_WIDTH_BIT_12);
adc1_config_channel_atten(channel, atten);
adc_chars = calloc(1, sizeof(esp_adc_cal_characteristics_t));
esp_adc_cal_characterize(ADC_UNIT_1, atten, ADC_WIDTH_BIT_12, DEFAULT_VREF, adc_chars);
int val = adc1_get_raw(channel);
return val;
}

View File

@@ -28,6 +28,8 @@ extern "C" {
extern void analogWrite(uint32_t pin, uint32_t value);
extern int analogRead(uint32_t pin, uint32_t atten);
#ifdef __cplusplus
}
#endif

127
code-of-conduct.md Normal file
View File

@@ -0,0 +1,127 @@
# Adafruit Community Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as
contributors and leaders pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, gender identity and expression, level or type of
experience, education, socio-economic status, nationality, personal appearance,
race, religion, or sexual identity and orientation.
## Our Standards
We are committed to providing a friendly, safe and welcoming environment for
all.
Examples of behavior that contributes to creating a positive environment
include:
* Be kind and courteous to others
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Collaborating with other community members
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and sexual attention or advances
* The use of inappropriate images, including in a community member's avatar
* The use of inappropriate language, including in a community member's nickname
* Any spamming, flaming, baiting or other attention-stealing behavior
* Excessive or unwelcome helping; answering outside the scope of the question
asked
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate
The goal of the standards and moderation guidelines outlined here is to build
and maintain a respectful community. We ask that you dont just aim to be
"technically unimpeachable", but rather try to be your best self.
We value many things beyond technical expertise, including collaboration and
supporting others within our community. Providing a positive experience for
other community members can have a much more significant impact than simply
providing the correct answer.
## Our Responsibilities
Project leaders are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.
Project leaders have the right and responsibility to remove, edit, or
reject messages, comments, commits, code, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any community member for other behaviors that they deem
inappropriate, threatening, offensive, or harmful.
## Moderation
Instances of behaviors that violate the Adafruit Community Code of Conduct
may be reported by any member of the community. Community members are
encouraged to report these situations, including situations they witness
involving other community members.
You may report in the following ways:
In any situation, you may send an email to <support@adafruit.com>.
On the Adafruit Discord, you may send an open message from any channel
to all Community Helpers by tagging @community helpers. You may also send an
open message from any channel, or a direct message to @kattni#1507,
@tannewt#4653, @Dan Halbert#1614, @cater#2442, @sommersoft#0222, or
@Andon#8175.
Email and direct message reports will be kept confidential.
In situations on Discord where the issue is particularly egregious, possibly
illegal, requires immediate action, or violates the Discord terms of service,
you should also report the message directly to Discord.
These are the steps for upholding our communitys standards of conduct.
1. Any member of the community may report any situation that violates the
Adafruit Community Code of Conduct. All reports will be reviewed and
investigated.
2. If the behavior is an egregious violation, the community member who
committed the violation may be banned immediately, without warning.
3. Otherwise, moderators will first respond to such behavior with a warning.
4. Moderators follow a soft "three strikes" policy - the community member may
be given another chance, if they are receptive to the warning and change their
behavior.
5. If the community member is unreceptive or unreasonable when warned by a
moderator, or the warning goes unheeded, they may be banned for a first or
second offense. Repeated offenses will result in the community member being
banned.
## Scope
This Code of Conduct and the enforcement policies listed above apply to all
Adafruit Community venues. This includes but is not limited to any community
spaces (both public and private), the entire Adafruit Discord server, and
Adafruit GitHub repositories. Examples of Adafruit Community spaces include
but are not limited to meet-ups, audio chats on the Adafruit Discord, or
interaction at a conference.
This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. As a community
member, you are representing our community, and are expected to behave
accordingly.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 1.4, available at
<https://www.contributor-covenant.org/version/1/4/code-of-conduct.html>,
and the [Rust Code of Conduct](https://www.rust-lang.org/en-US/conduct.html).
For other projects adopting the Adafruit Community Code of
Conduct, please contact the maintainers of those projects for enforcement.
If you wish to use this code of conduct for your own project, consider
explicitly mentioning your moderation policy or making a copy with your
own moderation policy so as to avoid confusion.

View File

@@ -7,7 +7,7 @@ partitionData = open("build/partitions.bin", "rb").read()
appData = open("build/nina-fw.bin", "rb").read()
certsData = open("data/roots.pem", "rb").read()
# calculate the output binary size, app offset
# calculate the output binary size, app offset
outputSize = 0x30000 + len(appData)
if (outputSize % 1024):
outputSize += 1024 - (outputSize % 1024)
@@ -31,7 +31,7 @@ for i in range(0, len(certsData)):
# zero terminate the pem file
outputData[0x10000 + len(certsData)] = 0
outputFilename = "NINA_W102-1.4.0.bin"
outputFilename = "NINA_W102-1.5.0.bin"
if (len(sys.argv) > 1):
outputFilename = sys.argv[1]

View File

@@ -28,7 +28,7 @@
#include "Arduino.h"
const char FIRMWARE_VERSION[6] = "1.4.0";
const char FIRMWARE_VERSION[6] = "1.5.0";
// Optional, user-defined X.509 certificate
char CERT_BUF[1300];
@@ -994,6 +994,34 @@ int setAnalogWrite(const uint8_t command[], uint8_t response[])
return 6;
}
int setDigitalRead(const uint8_t command[], uint8_t response[])
{
uint8_t pin = command[4];
int8_t value = digitalRead(pin);
response[2] = 1; // number of parameters
response[3] = 1; // parameter 1 length
response[4] = value;
return 6;
}
int setAnalogRead(const uint8_t command[], uint8_t response[])
{
uint8_t pin = command[4];
uint8_t atten = command[6];
int value = analogRead(pin, atten);
response[2] = 1; // number of parameters
response[3] = sizeof(value); // parameter 1 length
memcpy(&response[4], &value, sizeof(value));
return 5 + sizeof(value);
}
int wpa2EntSetIdentity(const uint8_t command[], uint8_t response[]) {
char identity[32 + 1];
@@ -1112,7 +1140,7 @@ const CommandHandlerType commandHandlers[] = {
setClientCert, setCertKey, NULL, NULL, sendDataTcp, getDataBufTcp, insertDataBuf, NULL, NULL, NULL, wpa2EntSetIdentity, wpa2EntSetUsername, wpa2EntSetPassword, wpa2EntSetCACert, wpa2EntSetCertKey, wpa2EntEnable,
// 0x50 -> 0x5f
setPinMode, setDigitalWrite, setAnalogWrite,
setPinMode, setDigitalWrite, setAnalogWrite, setDigitalRead, setAnalogRead,
};
#define NUM_COMMAND_HANDLERS (sizeof(commandHandlers) / sizeof(commandHandlers[0]))