-
Notifications
You must be signed in to change notification settings - Fork 964
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from meshtastic/master
Update my repo from head
- Loading branch information
Showing
16 changed files
with
364 additions
and
108 deletions.
There are no files selected for viewing
This file contains 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 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 @@ | ||
# You probably don't want to use this script, it programs a custom bootloader build onto a nrf52 board | ||
|
||
set -e | ||
|
||
BOOTDIR=/home/kevinh/development/meshtastic/Adafruit_nRF52_Bootloader | ||
|
||
nrfjprog --eraseall -f nrf52 | ||
|
||
# this generates an intel hex file that can be programmed into a NRF52 to tell the adafruit bootloader that the current app image is valid | ||
# Bootloader settings are at BOOTLOADER_SETTINGS (rw) : ORIGIN = 0xFF000, LENGTH = 0x1000 | ||
# first 4 bytes should be 0x01 to indicate valid app image | ||
# second 4 bytes should be 0x00 to indicate no CRC required for image | ||
echo "01 00 00 00 00 00 00 00" | xxd -r -p - >/tmp/bootconf.bin | ||
srec_cat /tmp/bootconf.bin -binary -offset 0xff000 -output /tmp/bootconf.hex -intel | ||
|
||
echo Generating merged hex file | ||
mergehex -m $BOOTDIR/_build/build-ttgo_eink/ttgo_eink_bootloader-0.3.2-124-g69bd8eb-dirty_s140_6.1.1.hex .pio/build/eink/firmware.hex /tmp/bootconf.hex -o ttgo_eink_full.hex | ||
|
||
echo Telling bootloader app region is valid and telling CPU to run | ||
nrfjprog --program ttgo_eink_full.hex -f nrf52 --reset | ||
|
||
# nrfjprog --readuicr /tmp/uicr.hex; objdump -s /tmp/uicr.hex | less |
This file contains 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,6 @@ | ||
# You probably don't need this - it is a basic test of the serial flash on the TTGO eink board | ||
|
||
nrfjprog -qspiini nrf52/ttgo_eink_qpsi.ini --qspieraseall | ||
nrfjprog --qspiini nrf52/ttgo_eink_qpsi.ini --memwr 0x12000000 --val 0xdeadbeef --verify | ||
nrfjprog --qspiini nrf52/ttgo_eink_qpsi.ini --readqspi spi.hex | ||
objdump -s spi.hex | less |
This file contains 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,69 @@ | ||
; nrfjprog.exe configuration file. | ||
|
||
; Note: QSPI flash is mapped into memory at address 0x12000000 | ||
|
||
[DEFAULT_CONFIGURATION] | ||
; Define the capacity of the flash memory device in bytes. Set to 0 if no external memory device is present in your board. | ||
; MX25R1635F is 16Mbit/2Mbyte | ||
MemSize = 0x200000 | ||
|
||
; Define the desired ReadMode. Valid options are FASTREAD, READ2O, READ2IO, READ4O and READ4IO | ||
ReadMode = READ2IO | ||
|
||
; Define the desired WriteMode. Valid options are PP, PP2O, PP4O and PP4IO | ||
WriteMode = PP | ||
|
||
; Define the desired AddressMode. Valid options are BIT24 and BIT32 | ||
AddressMode = BIT24 | ||
|
||
; Define the desired Frequency. Valid options are M2, M4, M8, M16 and M32 | ||
Frequency = M16 | ||
|
||
; Define the desired SPI mode. Valid options are MODE0 and MODE3 | ||
SpiMode = MODE0 | ||
|
||
; Define the desired SckDelay. Valid options are in the range 0 to 255 | ||
SckDelay = 0x80 | ||
|
||
; Define the desired IO level for DIO2 and DIO3 during a custom instruction. Valid options are LEVEL_HIGH and LEVEL_LOW | ||
CustomInstructionIO2Level = LEVEL_LOW | ||
CustomInstructionIO3Level = LEVEL_HIGH | ||
|
||
; Define the assigned pins for the QSPI peripheral. Valid options are those existing in your device | ||
CSNPin = 15 | ||
CSNPort = 1 | ||
SCKPin = 14 | ||
SCKPort = 1 | ||
DIO0Pin = 12 | ||
DIO0Port = 1 | ||
DIO1Pin = 13 | ||
DIO1Port = 1 | ||
|
||
;These two pins are not connected, but we must name something | ||
DIO2Pin = 3 | ||
DIO2Port = 1 | ||
DIO3Pin = 5 | ||
DIO3Port = 1 | ||
|
||
; Define the Index of the Write In Progress (WIP) bit in the status register. Valid options are in the range of 0 to 7. | ||
WIPIndex = 0 | ||
|
||
; Define page size for commands. Valid sizes are PAGE256 and PAGE512. | ||
PPSize = PAGE256 | ||
|
||
; Custom instructions to send to the external memory after initialization. Format is instruction code plus data to send in between optional brakets. | ||
; These instructions will be executed each time the qspi peripheral is initiated by nrfjprog. | ||
; To improve execution speed on consecutive interations with QSPI, you can run nrfjprog once with custom initialization, and then comment out the lines below. | ||
; Numbers can be given in decimal, hex (starting with either 0x or 0X) and binary (starting with either 0b or 0B) formats. | ||
; The custom instructions will be executed in the order found. | ||
|
||
; This example includes two commands, first a WREN (WRite ENable) and then a WRSR (WRite Satus Register) enabling the Quad Operation and the High Performance | ||
; mode for the MX25R6435F memory present in the nRF52840 DK. | ||
;InitializationCustomInstruction = 0x06 | ||
;InitializationCustomInstruction = 0x01, [0x40, 0, 0x2] | ||
|
||
; For MX25R1635F on TTGO board, only two data lines are connected | ||
; This example includes two commands, first a WREN (WRite ENable) and then a WRSR (WRite Satus Register) disabling Quad Operation and the High Performance | ||
; mode. For normal operation you might want low power mode instead. | ||
InitializationCustomInstruction = 0x06 | ||
InitializationCustomInstruction = 0x01, [0x00, 0, 0x2] |
This file contains 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 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,87 @@ | ||
#include "Air530GPS.h" | ||
#include <assert.h> | ||
|
||
/* | ||
Helpful translations from the Air530 GPS datasheet | ||
Sat acquision mode | ||
捕获电流值@3.3v 42.6 mA | ||
sat tracking mode | ||
跟踪电流值@3.3v 36.7 mA | ||
Low power mode | ||
低功耗模式@3.3V 0.85 mA | ||
(发送指令:$PGKC051,0) | ||
Super low power mode | ||
超低功耗模式@3.3V 31 uA | ||
(发送指令:$PGKC105,4) | ||
To exit sleep use WAKE pin | ||
Commands to enter sleep | ||
6、Command: 105 | ||
进入周期性低功耗模式 | ||
Arguments: | ||
Arg1: “0”,正常运行模式 (normal mode) | ||
“1”,周期超低功耗跟踪模式,需要拉高 WAKE 来唤醒 (periodic low power tracking mode - keeps sat positions, use wake to wake up) | ||
“2”,周期低功耗模式 (periodic low power mode) | ||
“4”,直接进入超低功耗跟踪模式,需要拉高 WAKE 来唤醒 (super low power consumption mode immediately, need WAKE to resume) | ||
“8”,自动低功耗模式,可以通过串口唤醒 (automatic low power mode, wake by sending characters to serial port) | ||
“9”, 自动超低功耗跟踪模式,需要拉高 WAKE 来唤醒 (automatic low power tracking when possible, need wake pin to resume) | ||
(Arg 2 & 3 only valid if Arg1 is "1" or "2") | ||
Arg2:运行时间(毫秒),在 Arg1 为 1、2 的周期模式下,此参数起作用 | ||
ON time in msecs | ||
Arg3:睡眠时间(毫秒),在 Arg1 为 1、2 的周期模式下,此参数起作用 | ||
Sleep time in msecs | ||
Example: | ||
$PGKC105,8*3F<CR><LF> | ||
This will set automatic low power mode with waking when we send chars to the serial port. Possibly do this as soon as we get a | ||
new location. When we wake again in a minute we send a character to wake up. | ||
*/ | ||
|
||
|
||
void Air530GPS::sendCommand(const char *cmd) { | ||
uint8_t sum = 0; | ||
|
||
// Skip the $ | ||
assert(cmd[0] == '$'); | ||
const char *p = cmd + 1; | ||
while(*p) | ||
sum ^= *p++; | ||
|
||
assert(_serial_gps); | ||
|
||
_serial_gps->write(cmd); | ||
_serial_gps->printf("*%02x\r\n", sum); | ||
|
||
// DEBUG_MSG("xsum %02x\n", sum); | ||
} | ||
|
||
void Air530GPS::sleep() { | ||
#ifdef PIN_GPS_WAKE | ||
digitalWrite(PIN_GPS_WAKE, 0); | ||
pinMode(PIN_GPS_WAKE, OUTPUT); | ||
sendCommand("$PGKC105,4"); | ||
#endif | ||
} | ||
|
||
/// wake the GPS into normal operation mode | ||
void Air530GPS::wake() | ||
{ | ||
#if 1 | ||
#ifdef PIN_GPS_WAKE | ||
digitalWrite(PIN_GPS_WAKE, 1); | ||
pinMode(PIN_GPS_WAKE, OUTPUT); | ||
#endif | ||
#else | ||
// For power testing - keep GPS sleeping forever | ||
sleep(); | ||
#endif | ||
} |
This file contains 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 @@ | ||
#pragma once | ||
|
||
#include "NMEAGPS.h" | ||
|
||
/** | ||
* A gps class thatreads from a NMEA GPS stream (and FIXME - eventually keeps the gps powered down except when reading) | ||
* | ||
* When new data is available it will notify observers. | ||
*/ | ||
class Air530GPS : public NMEAGPS | ||
{ | ||
protected: | ||
/// If possible force the GPS into sleep/low power mode | ||
virtual void sleep(); | ||
|
||
/// wake the GPS into normal operation mode | ||
virtual void wake(); | ||
|
||
private: | ||
/// Send a NMEA cmd with checksum | ||
void sendCommand(const char *str); | ||
}; |
This file contains 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 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
Oops, something went wrong.