Skip to content

Commit b27f2a0

Browse files
author
Owen L - SFE
committed
Merge branch 'master' into core-ble
2 parents 858d835 + 4a4d739 commit b27f2a0

File tree

113 files changed

+1314
-6618
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

113 files changed

+1314
-6618
lines changed

boards.txt

+7-7
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ menu.sbl_baud=Ambiq Secure Bootloader Baud Rate
2828
###############################################################
2929

3030
artemis.name=SparkFun Artemis Module
31-
artemis.build.variant=SparkFun_Artemis
31+
artemis.build.variant=artemis
3232
artemis.build.board=SFE_ARTEMIS
3333
artemis.upload.maximum_size=960000
3434
artemis.upload.sbl_baud=115200
@@ -65,7 +65,7 @@ artemis.menu.loader.sparkfun_svl.build.ldscript={build.variant.path}/linker_scri
6565
###############################################################
6666

6767
amap3redboard.name=SparkFun RedBoard Artemis
68-
amap3redboard.build.variant=SparkFun_RedBoard_Artemis
68+
amap3redboard.build.variant=redboard_artemis
6969
amap3redboard.build.board=AM_AP3_SFE_BB_ARTEMIS
7070
amap3redboard.upload.maximum_size=960000
7171
amap3redboard.upload.sbl_baud=115200
@@ -102,7 +102,7 @@ amap3redboard.menu.loader.sparkfun_svl.build.ldscript={build.variant.path}/linke
102102
###############################################################
103103

104104
amap3nano.name=SparkFun RedBoard Artemis Nano
105-
amap3nano.build.variant=SparkFun_RedBoard_Artemis_Nano
105+
amap3nano.build.variant=redboard_artemis_nano
106106
amap3nano.build.board=AM_AP3_SFE_BB_ARTEMIS_NANO
107107
amap3nano.upload.maximum_size=960000
108108
amap3nano.upload.sbl_baud=115200
@@ -139,7 +139,7 @@ amap3nano.menu.loader.sparkfun_svl.build.ldscript={build.variant.path}/linker_sc
139139
###############################################################
140140

141141
amap3atp.name=SparkFun RedBoard Artemis ATP
142-
amap3atp.build.variant=SparkFun_RedBoard_Artemis_ATP
142+
amap3atp.build.variant=redboard_artemis_atp
143143
amap3atp.build.board=AM_AP3_SFE_BB_ARTEMIS_ATP
144144
amap3atp.upload.maximum_size=960000
145145
amap3atp.upload.sbl_baud=115200
@@ -176,7 +176,7 @@ amap3atp.menu.loader.sparkfun_svl.build.ldscript={build.variant.path}/linker_scr
176176
###############################################################
177177

178178
amap3thing.name=SparkFun Artemis Thing Plus
179-
amap3thing.build.variant=SparkFun_Artemis_Thing_Plus
179+
amap3thing.build.variant=artemis_thing_plus
180180
amap3thing.build.board=AM_AP3_SFE_THING_PLUS
181181
amap3thing.upload.maximum_size=960000
182182
amap3thing.upload.sbl_baud=115200
@@ -213,7 +213,7 @@ amap3thing.menu.loader.sparkfun_svl.build.ldscript={build.variant.path}/linker_s
213213
###############################################################
214214

215215
edge.name=SparkFun Edge
216-
edge.build.variant=SparkFun_Edge
216+
edge.build.variant=edge
217217
edge.build.board=SFE_EDGE
218218
edge.upload.tool=ambiq_bin2board
219219
edge.upload.maximum_size=960000
@@ -260,7 +260,7 @@ edge.menu.loader.sparkfun_svl.build.ldscript={build.variant.path}/linker_scripts
260260
###############################################################
261261

262262
edge2.name=SparkFun Edge2
263-
edge2.build.variant=SparkFun_Edge2
263+
edge2.build.variant=edge2
264264
edge2.build.board=SFE_EDGE2
265265
edge2.upload.maximum_size=960000
266266
edge2.upload.sbl_baud=115200

cores/arduino/am_sdk_ap3/mcu/apollo3/hal/am_hal_uart.c

+6-1
Original file line numberDiff line numberDiff line change
@@ -1104,7 +1104,12 @@ am_hal_uart_flags_get(void *pHandle, uint32_t *ui32Flags)
11041104
return AM_HAL_STATUS_INVALID_HANDLE;
11051105
}
11061106

1107-
return UARTn(ui32Module)->FR;
1107+
//Correct code
1108+
*ui32Flags = (uint32_t)UARTn(ui32Module)->FR;
1109+
return AM_HAL_STATUS_SUCCESS;
1110+
1111+
//return UARTn(ui32Module)->FR; //Incorrect code?
1112+
11081113
} // am_hal_uart_flags_get()
11091114

11101115
//*****************************************************************************

cores/arduino/ard_sup/Arduino.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ extern "C"
3939
// Include Apollo headers
4040
#include "am_mcu_apollo.h"
4141
#include "am_util.h"
42-
// #include "am_bsp.h"
42+
#include "am_bsp.h"
4343

4444
#include "hooks.h"
4545

cores/arduino/ard_sup/ap3_uart.h

+1-21
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class Uart : public HardwareSerial
6767
uint32_t printf(const char *pcFmt, ...);
6868
using Print::write; // pull in write(str) and write(buf, size) from Print
6969

70-
void rx_isr(void);
70+
void uart_isr(void);
7171

7272
operator bool() { return true; } // todo: wait for a serial terminal to be open... probably depends on RTS or CTS...
7373

@@ -86,26 +86,6 @@ class Uart : public HardwareSerial
8686

8787
ap3_err_t set_config(HardwareSerial_Config_e HWSconfig);
8888
ap3_err_t _begin(void); // call once all members + config structure are set up
89-
90-
// ap3_err_t initialize( void );
91-
92-
// SERCOM *sercom;
93-
// RingBuffer rxBuffer;
94-
// RingBuffer txBuffer;
95-
96-
// uint8_t uc_pinRX;
97-
// uint8_t uc_pinTX;
98-
// SercomRXPad uc_padRX;
99-
// SercomUartTXPad uc_padTX;
100-
// uint8_t uc_pinRTS;
101-
// volatile uint32_t* pul_outsetRTS;
102-
// volatile uint32_t* pul_outclrRTS;
103-
// uint32_t ul_pinMaskRTS;
104-
// uint8_t uc_pinCTS;
105-
106-
// SercomNumberStopBit extractNbStopBit(uint16_t config);
107-
// SercomUartCharSize extractCharSize(uint16_t config);
108-
// SercomParityMode extractParity(uint16_t config);
10989
};
11090

11191
#endif // _AP3_UART_H_

cores/arduino/ard_sup/uart/ap3_uart.cpp

+73-18
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,7 @@ int Uart::available()
9090

9191
int Uart::availableForWrite()
9292
{
93-
// return _tx_buffer.availableForStore();
94-
return 127; // todo:
93+
return _tx_buffer.availableForStore();
9594
}
9695

9796
int Uart::peek()
@@ -118,19 +117,47 @@ size_t Uart::write(const uint8_t data)
118117
size_t Uart::write(const uint8_t *buffer, size_t size)
119118
{
120119
uint32_t ui32BytesWritten = 0;
120+
uint32_t remaining = size;
121121

122-
// todo: use a local buffer to guarantee lifespan of data (maybe txbuffer, but maybe not a ring buffer? b/c of efficiency + not breaking up transfers)
122+
//FIFO on Apollo3 is 32 bytes
123123

124-
const am_hal_uart_transfer_t sUartWrite =
125-
{
126-
.ui32Direction = AM_HAL_UART_WRITE,
127-
.pui8Data = (uint8_t *)buffer,
128-
.ui32NumBytes = size,
129-
.ui32TimeoutMs = AM_HAL_UART_WAIT_FOREVER,
130-
.pui32BytesTransferred = (uint32_t *)&ui32BytesWritten,
131-
};
132-
am_hal_uart_transfer(_handle, &sUartWrite);
133-
return ui32BytesWritten;
124+
//If TX UART is sitting idle, load it. This will start the ISR TX handler as well.
125+
uint32_t uartFlags;
126+
am_hal_uart_flags_get(_handle, &uartFlags);
127+
if (uartFlags & AM_HAL_UART_FR_TX_EMPTY)
128+
{
129+
uint32_t amtToSend = remaining;
130+
if (amtToSend > AM_HAL_UART_FIFO_MAX)
131+
amtToSend = AM_HAL_UART_FIFO_MAX;
132+
133+
remaining -= amtToSend;
134+
135+
//Transfer to local buffer
136+
uint8_t tempTX[AM_HAL_UART_FIFO_MAX];
137+
for (int x = 0; x < amtToSend; x++)
138+
tempTX[x] = buffer[x];
139+
140+
const am_hal_uart_transfer_t sUartWrite =
141+
{
142+
.ui32Direction = AM_HAL_UART_WRITE,
143+
.pui8Data = (uint8_t *)tempTX,
144+
.ui32NumBytes = amtToSend,
145+
.ui32TimeoutMs = AM_HAL_UART_WAIT_FOREVER,
146+
.pui32BytesTransferred = (uint32_t *)&ui32BytesWritten,
147+
};
148+
am_hal_uart_transfer(_handle, &sUartWrite);
149+
}
150+
151+
//Transfer any remaining bytes into ring buffer
152+
for (int x = size - remaining; x < size; x++)
153+
{
154+
//If TX ring buffer is full, begin blocking
155+
while (_tx_buffer.availableForStore() == 0)
156+
delay(1);
157+
_tx_buffer.store_char(buffer[x]);
158+
}
159+
160+
return ui32BytesWritten; //Return number of bytes pushed to UART hardware
134161
}
135162

136163
// Stop Bits
@@ -370,9 +397,9 @@ ap3_err_t Uart::_begin(void)
370397

371398
UARTn(_instance)->LCRH_b.FEN = 0; // Disable that pesky FIFO
372399

373-
// Enable RX interrupts
400+
// Enable TX and RX interrupts
374401
NVIC_EnableIRQ((IRQn_Type)(UART0_IRQn + _instance));
375-
am_hal_uart_interrupt_enable(_handle, (AM_HAL_UART_INT_RX));
402+
am_hal_uart_interrupt_enable(_handle, (AM_HAL_UART_INT_RX | AM_HAL_UART_INT_TX));
376403
am_hal_interrupt_master_enable();
377404

378405
// Register the class into the local list
@@ -487,7 +514,7 @@ ap3_err_t ap3_uart_pad_funcsel(uint8_t instance, ap3_uart_pad_type_e type, ap3_g
487514
// Interrupt handler for the UART.
488515
//
489516
//*****************************************************************************
490-
inline void Uart::rx_isr(void)
517+
inline void Uart::uart_isr(void)
491518
{
492519

493520
uint32_t ui32Status;
@@ -517,21 +544,49 @@ inline void Uart::rx_isr(void)
517544
_rx_buffer.store_char(rx_c);
518545
}
519546
}
547+
548+
if (ui32Status & AM_HAL_UART_INT_TX)
549+
{
550+
//If bytes are sitting in TX buffer, load them into UART buffer for transfer
551+
if (_tx_buffer.available())
552+
{
553+
uint32_t ui32BytesWritten = 0;
554+
555+
uint32_t amtToSend = _tx_buffer.available();
556+
if (amtToSend > AM_HAL_UART_FIFO_MAX)
557+
amtToSend = AM_HAL_UART_FIFO_MAX;
558+
559+
//Transfer to local buffer
560+
uint8_t tempTX[AM_HAL_UART_FIFO_MAX];
561+
for (int x = 0; x < amtToSend; x++)
562+
tempTX[x] = _tx_buffer.read_char();
563+
564+
const am_hal_uart_transfer_t sUartWrite =
565+
{
566+
.ui32Direction = AM_HAL_UART_WRITE,
567+
.pui8Data = (uint8_t *)tempTX,
568+
.ui32NumBytes = (uint32_t)amtToSend,
569+
.ui32TimeoutMs = AM_HAL_UART_WAIT_FOREVER,
570+
.pui32BytesTransferred = (uint32_t *)&ui32BytesWritten,
571+
};
572+
am_hal_uart_transfer(_handle, &sUartWrite);
573+
}
574+
}
520575
}
521576

522577
// Individual ISR implementations for the two UART peripherals on the Apollo3
523578
extern "C" void am_uart_isr(void)
524579
{
525580
if (ap3_uart_handles[0] != NULL)
526581
{
527-
ap3_uart_handles[0]->rx_isr();
582+
ap3_uart_handles[0]->uart_isr();
528583
}
529584
}
530585

531586
extern "C" void am_uart1_isr(void)
532587
{
533588
if (ap3_uart_handles[1] != NULL)
534589
{
535-
ap3_uart_handles[1]->rx_isr();
590+
ap3_uart_handles[1]->uart_isr();
536591
}
537592
}

docs/CHANGELOG.md

+46-8
Original file line numberDiff line numberDiff line change
@@ -5,37 +5,75 @@ This is a record of the major changes between versions of the SparkFun Arduino A
55

66
Each log entry will use the version number of the release that contains the changes listed. Newest version at the top of the file (just below this line)
77

8-
1.0.15
8+
1.0.21 - In-progress
9+
====================
10+
- merge PR #89 to improve SPI performance
11+
12+
1.0.20 - Nov 15 2019
13+
====================
14+
- updated bootloader executables
15+
16+
1.0.18 - Nov 15 2019
17+
====================
18+
- merge #84
19+
- merge #88 Tensorflow Lite Micro library compatibility (changes how ADC is set up)
20+
21+
1.0.17 - Oct 30 2019
922
===================
23+
- merge #75 EEPROM Improvements
24+
- merge #76 IC Revision Example
25+
- merge #77 Low Power example
26+
- merge #81 Clean SVL
27+
- merge #79 Pullup Resistor defaults
28+
- adds default access to BSP files for all variants
29+
30+
1.0.16 - Oct 14 2019
31+
====================
32+
- merge #73
33+
- merge #72
34+
- revert to artemis_svl.exe from v1.0.12 as stop-gap fix for #74
35+
36+
1.0.15 - Oct 10 2019
37+
====================
1038
- merge PR #70 to allow Arduino CLI to use svl linker script by default
1139
- re-release to include BLE examples
1240

13-
1.0.14
41+
1.0.14 - Oct 4 2019
1442
===================
1543
- regeneration of svl binary
1644

17-
1.0.13
18-
===================
45+
1.0.13 - Sep 30 2019
46+
====================
1947
- merged PR #61 to improve automated testing
2048
- added standard IPAddress files w/ PR #63
2149
- SoftwareSerial now inherits from Stream w/ PR #64
2250
- increased library compatibility w/ PR #66
2351
- improved error handling/reporting in the SparkFun Variable Loader w/ PR #67
2452

25-
1.0.12
26-
===================
53+
1.0.12 - Sep 26 2019
54+
====================
2755
- fixed redefinition of ADC symbols in redboard_artemis_nano
2856
- added empty pins_arduino.h for compile-compatibility iwht older libraries
2957
- added standard IPAddress library
3058
- changed SoftwareSerial to inherit from Stream instead of Print
3159

32-
1.0.8
60+
1.0.10 - Sep 21 2019
61+
====================
62+
- rename board directories to RedBoard. Fix for variant.h not found error.
63+
64+
1.0.9 - Sep 19 2019
65+
===================
66+
- adds Artemis Thing Plus board definitions
67+
- changes board definitions to 'Red' for LTS
68+
- once again based on the temporary core-ble branch that contains a BLE example (mistakenly omitted from v1.0.8)
69+
70+
1.0.8 - Sep 12 2019
3371
===================
3472
- Wire library requestFrom address bug fix (previously required address to be set with 'beginTransmission')
3573
- Correct variant definition for Artemis module (Serial mis-definition)
3674
- Correct variant definition for Edge (Wire1 redefinition)
3775

38-
1.0.7 -
76+
1.0.7 - Aug 27 2019
3977
===================
4078
- Rectified error in Artemis variant pin map (pad 46 was listed as available when it is in fact not)
4179
- Fixed CPU hang on certain 'analogWrite' calls

0 commit comments

Comments
 (0)