-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Arduino Nesso N1 support #8784
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Arduino Nesso N1 support #8784
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
26fe314
Arduino Nesso N1 support
fukuen 6716f22
fix
fukuen 7867534
enable rf switch/lna
fukuen 5005386
Enabled MQTT and WEBSERVER
fukuen ef4c7b2
Merge branch 'develop' into wip/arduino-nesso-n1
mverch67 97d8e2a
added USE_TFTDISPLAY
mverch67 62e0d9d
rotate screen
mverch67 1a599b7
add display color menu
mverch67 59512e4
Merge branch 'develop' into wip/arduino-nesso-n1
mverch67 b425ac7
Enable HAS_WIRE support in platformio.ini
mverch67 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| #include "GpioExtLogic.h" | ||
| #include <assert.h> | ||
|
|
||
| void GpioExtPin::set(bool value) | ||
| { | ||
| gpio_ext_set(this->address, this->pin, value); | ||
| } | ||
|
|
||
| uint8_t GpioExtPin::get() | ||
| { | ||
| return gpio_ext_get(this->address, this->pin); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| #include "GpioLogic.h" | ||
|
|
||
| class GpioExtPin : public GpioPin | ||
| { | ||
| uint32_t num; | ||
|
|
||
| public: | ||
| GpioExtPin(uint16_t _pin) : pin(_pin & 0x3F), address(_pin & 0x100 ? 0x44 : 0x43){}; | ||
| uint8_t pin; | ||
| uint8_t address; | ||
|
|
||
| void set(bool value); | ||
| uint8_t get(); | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| #ifndef Pins_Arduino_h | ||
| #define Pins_Arduino_h | ||
|
|
||
| #include <stdint.h> | ||
|
|
||
| #define USB_VID 0x303A | ||
| #define USB_PID 0x1001 | ||
|
|
||
| static const uint8_t TX = -1; | ||
| static const uint8_t RX = -1; | ||
|
|
||
| static const uint8_t SDA = 10; | ||
| static const uint8_t SCL = 8; | ||
|
|
||
| // Default SPI will be mapped to Radio | ||
| static const uint8_t MOSI = 21; | ||
| static const uint8_t MISO = 22; | ||
| static const uint8_t SCK = 20; | ||
| static const uint8_t SS = 23; | ||
|
|
||
| #endif /* Pins_Arduino_h */ | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| [env:arduino-nesso-n1] | ||
| extends = esp32c6_base | ||
| board = esp32-c6-devkitc-1 | ||
| upload_protocol = esptool | ||
| build_unflags = | ||
| -D HAS_BLUETOOTH | ||
| -D MESHTASTIC_EXCLUDE_BLUETOOTH | ||
| -D HAS_WIFI | ||
| lib_deps = | ||
| ${esp32c6_base.lib_deps} | ||
| h2zero/NimBLE-Arduino@^2.3.6 | ||
| lovyan03/LovyanGFX@^1.2.0 | ||
| https://github.com/mverch67/BQ27220/archive/07d92be846abd8a0258a50c23198dac0858b22ed.zip | ||
| build_flags = | ||
| ${esp32c6_base.build_flags} | ||
| -D PRIVATE_HW | ||
| -D ARDUINO_NESSO_N1 | ||
| -I variants/esp32c6/arduino_nesso_n1 | ||
| -DMESHTASTIC_EXCLUDE_PAXCOUNTER=1 | ||
| -DSOC_USB_OTG_SUPPORTED=1 | ||
| -DARDUINO_USB_CDC_ON_BOOT=1 | ||
| -DARDUINO_USB_MODE=1 | ||
| -D HAS_BLUETOOTH=1 | ||
| -D HAS_WIRE=1 | ||
| -DCONFIG_BT_NIMBLE_EXT_ADV=1 | ||
| -DCONFIG_BT_NIMBLE_MAX_EXT_ADV_INSTANCES=2 | ||
| -D NIMBLE_TWO | ||
| -D CORE_DEBUG_LEVEL=5 | ||
| -D _ESP_LOGLEVEL_=5 | ||
| monitor_speed=115200 | ||
| lib_ignore = | ||
| NonBlockingRTTTL | ||
| libpax | ||
| build_src_filter = | ||
| ${esp32c6_base.build_src_filter} +<../variants/esp32c6/arduino_nesso_n1> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,127 @@ | ||
| #include "driver/gpio.h" | ||
| #include <Arduino.h> | ||
| #include <Wire.h> | ||
| // I2C device addr | ||
| #define PI4IO_M_ADDR 0x43 | ||
| #define PI4IO_M_ADDR2 0x44 | ||
|
|
||
| // PI4IO registers | ||
| #define PI4IO_REG_CHIP_RESET 0x01 | ||
| #define PI4IO_REG_IO_DIR 0x03 | ||
| #define PI4IO_REG_OUT_SET 0x05 | ||
| #define PI4IO_REG_OUT_H_IM 0x07 | ||
| #define PI4IO_REG_IN_DEF_STA 0x09 | ||
| #define PI4IO_REG_PULL_EN 0x0B | ||
| #define PI4IO_REG_PULL_SEL 0x0D | ||
| #define PI4IO_REG_IN_STA 0x0F | ||
| #define PI4IO_REG_INT_MASK 0x11 | ||
| #define PI4IO_REG_IRQ_STA 0x13 | ||
| // PI4IO | ||
|
|
||
| #define setbit(x, y) x |= (0x01 << y) | ||
| #define clrbit(x, y) x &= ~(0x01 << y) | ||
| #define reversebit(x, y) x ^= (0x01 << y) | ||
| #define getbit(x, y) ((x) >> (y)&0x01) | ||
|
|
||
| void i2c_read_byte(uint8_t addr, uint8_t reg, uint8_t *value) | ||
| { | ||
| Wire.beginTransmission(addr); | ||
| Wire.write(reg); | ||
| Wire.endTransmission(); | ||
| Wire.requestFrom(addr, 1); | ||
| *value = Wire.read(); | ||
| } | ||
|
|
||
| /*******************************************************************/ | ||
| void i2c_write_byte(uint8_t addr, uint8_t reg, uint8_t value) | ||
| { | ||
| Wire.beginTransmission(addr); | ||
| Wire.write(reg); | ||
| Wire.write(value); | ||
| Wire.endTransmission(); | ||
| } | ||
| /*******************************************************************/ | ||
| void c6l_init() | ||
| { | ||
| // P7 LoRa Reset | ||
| // P6 RF Switch | ||
| // P5 LNA Enable | ||
| // P1 KEY2 | ||
| // P0 KEY1 | ||
| // P107 LED_BUILTIN | ||
| // P106 LCD_BACKLIGHT | ||
| // P105 VIN_DETECT | ||
| // P102 GROVE_POWER_EN | ||
| // P101 LCD_RESET | ||
| // P100 POWEROFF | ||
|
|
||
| printf("pi4io_init\n"); | ||
| uint8_t in_data; | ||
| i2c_write_byte(PI4IO_M_ADDR, PI4IO_REG_CHIP_RESET, 0xFF); | ||
| vTaskDelay(10 / portTICK_PERIOD_MS); | ||
| i2c_read_byte(PI4IO_M_ADDR, PI4IO_REG_CHIP_RESET, &in_data); | ||
| vTaskDelay(10 / portTICK_PERIOD_MS); | ||
| i2c_write_byte(PI4IO_M_ADDR, PI4IO_REG_IO_DIR, 0b11100000); // 0: input 1: output | ||
| vTaskDelay(10 / portTICK_PERIOD_MS); | ||
| i2c_write_byte(PI4IO_M_ADDR, PI4IO_REG_OUT_H_IM, 0b00011100); // Output High-Impedance, 1 high-impedance | ||
| vTaskDelay(10 / portTICK_PERIOD_MS); | ||
| i2c_write_byte(PI4IO_M_ADDR, PI4IO_REG_PULL_SEL, 0b11100011); // pull up/down select, 0 down, 1 up | ||
| vTaskDelay(10 / portTICK_PERIOD_MS); | ||
| i2c_write_byte(PI4IO_M_ADDR, PI4IO_REG_PULL_EN, 0b11100011); // pull up/down enable, 0 disable, 1 enable | ||
| vTaskDelay(10 / portTICK_PERIOD_MS); | ||
| i2c_write_byte(PI4IO_M_ADDR, PI4IO_REG_IN_DEF_STA, 0b00000011); // P0 P1 Default state HIGH, interrupt when pressed | ||
| vTaskDelay(10 / portTICK_PERIOD_MS); | ||
| i2c_write_byte(PI4IO_M_ADDR, PI4IO_REG_INT_MASK, 0b11111100); // P0 P1 Interrupt 0 enable, 1 disable | ||
| vTaskDelay(10 / portTICK_PERIOD_MS); | ||
| i2c_write_byte(PI4IO_M_ADDR, PI4IO_REG_OUT_SET, 0b11100000); // default output to 0 | ||
| vTaskDelay(10 / portTICK_PERIOD_MS); | ||
| i2c_read_byte(PI4IO_M_ADDR, PI4IO_REG_IRQ_STA, &in_data); // Read IRQ_STA clear register | ||
|
|
||
| i2c_read_byte(PI4IO_M_ADDR, PI4IO_REG_OUT_SET, &in_data); | ||
| setbit(in_data, 6); // HIGH | ||
| i2c_write_byte(PI4IO_M_ADDR, PI4IO_REG_OUT_SET, in_data); | ||
|
|
||
| i2c_write_byte(PI4IO_M_ADDR2, PI4IO_REG_CHIP_RESET, 0xFF); | ||
| vTaskDelay(10 / portTICK_PERIOD_MS); | ||
| i2c_read_byte(PI4IO_M_ADDR2, PI4IO_REG_CHIP_RESET, &in_data); | ||
| vTaskDelay(10 / portTICK_PERIOD_MS); | ||
| i2c_write_byte(PI4IO_M_ADDR2, PI4IO_REG_IO_DIR, 0b11000110); // 0: input 1: output | ||
| vTaskDelay(10 / portTICK_PERIOD_MS); | ||
| i2c_write_byte(PI4IO_M_ADDR2, PI4IO_REG_OUT_H_IM, 0b00111000); // Output High-Impedance, 1 high-impedance | ||
| vTaskDelay(10 / portTICK_PERIOD_MS); | ||
| i2c_write_byte(PI4IO_M_ADDR2, PI4IO_REG_PULL_SEL, 0b11000111); // pull up/down select, 0 down, 1 up | ||
| vTaskDelay(10 / portTICK_PERIOD_MS); | ||
| i2c_write_byte(PI4IO_M_ADDR2, PI4IO_REG_PULL_EN, 0b11000111); // pull up/down enable, 0 disable, 1 enable | ||
| vTaskDelay(10 / portTICK_PERIOD_MS); | ||
| i2c_write_byte(PI4IO_M_ADDR2, PI4IO_REG_IN_DEF_STA, 0b00000000); // P0 P1 Default state HIGH, interrupt when pressed | ||
| vTaskDelay(10 / portTICK_PERIOD_MS); | ||
| i2c_write_byte(PI4IO_M_ADDR2, PI4IO_REG_INT_MASK, 0b11111111); // P0 P1 Interrupt 0 enable, 1 disable | ||
| vTaskDelay(10 / portTICK_PERIOD_MS); | ||
| i2c_write_byte(PI4IO_M_ADDR2, PI4IO_REG_OUT_SET, 0b11000110); // default output to 0 | ||
|
|
||
| // AW32001E - address 0x49 | ||
| // charge current 256mA (default 128mA) | ||
| i2c_write_byte(0x49, 0x2, 0x1f); | ||
| // charge voltage 4.200(default) | ||
| // disable watch dog timer (default: 0x1f) | ||
| i2c_write_byte(0x49, 0x5, 0x1a); | ||
| // UVLO: 2.580 (default: 2.760), charge enable, disable HIZ (default: 0xac) | ||
| i2c_write_byte(0x49, 0x1, 0xa2); | ||
| // DPM 4.520 (default) | ||
| i2c_write_byte(0x49, 0x0, 0x8f); | ||
| } | ||
|
|
||
| void gpio_ext_set(uint8_t address, uint8_t pin, bool value) | ||
| { | ||
| uint8_t in_data; | ||
| i2c_read_byte(address, PI4IO_REG_OUT_SET, &in_data); | ||
| value ? setbit(in_data, pin) : clrbit(in_data, pin); | ||
| i2c_write_byte(address, PI4IO_REG_OUT_SET, in_data); | ||
| } | ||
|
|
||
| uint8_t gpio_ext_get(uint8_t address, uint8_t pin) | ||
| { | ||
| uint8_t in_data; | ||
| i2c_read_byte(address, PI4IO_REG_OUT_SET, &in_data); | ||
| return getbit(in_data, pin); | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.