Skip to content

Commit c9865e8

Browse files
Move to RTC as time base; HSEM3 critical regions; RTOS rework; BLE 1.14.1 stack
1 parent 7192ecd commit c9865e8

Some content is hidden

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

70 files changed

+7448
-17311
lines changed

cores/arduino/Arduino.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ extern "C"{
4646

4747
#define ARM_MATH_CM4
4848
#include "armv7m.h"
49-
#include "rtos_api.h"
5049
#include "stm32wbxx.h"
5150

5251
#undef STM32WB

cores/arduino/CDC.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ CDC::CDC(void (*serialEventRun)(void)) {
6464

6565
m_work = K_WORK_INIT((k_work_routine_t)&CDC::notifyRoutine, this);
6666

67-
m_event = K_EVENT_INIT();
67+
m_sem = K_SEM_INIT(0, 1);
6868
}
6969

7070
void CDC::begin(unsigned long baudrate) {
@@ -135,7 +135,7 @@ int CDC::read(uint8_t *buffer, size_t size) {
135135
void CDC::flush() {
136136
if (k_task_is_in_progress()) {
137137
while (m_tx_busy) {
138-
k_event_receive(&m_event, 1, (K_EVENT_ANY | K_EVENT_CLEAR), K_TIMEOUT_FOREVER, NULL);
138+
k_sem_acquire(&m_sem, K_TIMEOUT_FOREVER);
139139
}
140140
}
141141
}
@@ -217,7 +217,7 @@ size_t CDC::write(const uint8_t *buffer, size_t size) {
217217
}
218218

219219
if (m_tx_busy) {
220-
k_event_receive(&m_event, 1, (K_EVENT_ANY | K_EVENT_CLEAR), K_TIMEOUT_FOREVER, NULL);
220+
k_sem_acquire(&m_sem, K_TIMEOUT_FOREVER);
221221
}
222222
}
223223
} while (tx_size == 0);
@@ -401,7 +401,7 @@ bool CDC::rts() {
401401
void CDC::transmitCallback(class CDC *self) {
402402
uint32_t tx_read, tx_write, tx_count;
403403

404-
k_event_send(&self->m_event, 1);
404+
k_sem_release(&self->m_sem);
405405

406406
tx_count = self->m_tx_count;
407407

cores/arduino/HardwareSerial.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ int wiring_stderr_write(const char *data, int nbytes) {
101101
return Serial.write((const uint8_t*)data, nbytes);
102102
}
103103

104-
retirn 0;
104+
return 0;
105105
}
106106

107107
}

cores/arduino/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ OBJCOPY = $(TOOLS)/bin/arm-none-eabi-objcopy
1010
CFLAGS = -c -g3 -Os $(WARNINGS) -std=gnu11 -ffast-math -ffunction-sections -fdata-sections -nostdlib -MMD $(EXTRAS) $(DEFINES) $(INCLUDES)
1111
CXXFLAGS = -c -g3 -Os $(WARNINGS) -std=gnu++11 -ffast-math -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib -fno-use-cxa-atexit -fno-rtti -fno-exceptions -MMD $(EXTRAS) $(DEFINES) $(INCLUDES)
1212
ASFLAGS = -c -g -x assembler-with-cpp $(EXTRAS) $(DEFINES) $(INCLUDES)
13-
LDFLAGS = -g -Os $(EXTRAS) -Wl,--gc-sections,--no-undefined -T../../system/STM32WBxx/LinkScripts/STM32WB55xx_FLASH.ld --specs=nano.specs --specs=nosys.specs -Wl,--defsym=__RTC_EPOCH__=$(shell date +"%s")
13+
LDFLAGS = -g -Os $(EXTRAS) -Wl,--gc-sections,--no-undefined -T../../system/STM32WBxx/LdScripts/STM32WB55xx_FLASH.ld --specs=nano.specs --specs=nosys.specs -Wl,--defsym=__RTC_EPOCH__=$(shell date +"%s")
14+
#LDFLAGS = -g -Os $(EXTRAS) -Wl,--gc-sections,--no-undefined -T../../system/STM32WBxx/LinkScripts/STM32WB55xx_FLASH.ld --specs=nano.specs --specs=nosys.specs
1415
WARNINGS = -Wall -Wextra
1516
EXTRAS = -mcpu=cortex-m4 -march=armv7e-m+fp -mthumb -mabi=aapcs -mfpu=fpv4-sp-d16 -mfloat-abi=hard
1617
DEFINES = -DSTM32WB55xx -D__SYSTEM_CORE_CLOCK__=64000000 -DDOSFS_SDCARD=0 -DDOSFS_SFLASH=0 -DARDUINO_MAKEFILE

cores/arduino/USBAPI.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ class CDC : public HardwareSerial
156156
Callback m_transmit_callback;
157157

158158
k_work_t m_work;
159-
k_event_t m_event;
159+
k_sem_t m_sem;
160160

161161
static void transmitCallback(class CDC *self);
162162
static void eventCallback(class CDC *self, uint32_t events);

cores/arduino/Uart.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ Uart::Uart(struct _stm32wb_uart_t *uart, const struct _stm32wb_uart_params_t *pa
6464

6565
m_work = K_WORK_INIT((k_work_routine_t)&Uart::notifyRoutine, this);
6666

67-
m_event = K_EVENT_INIT();
67+
m_sem = K_SEM_INIT(0, 1);
6868

6969
stm32wb_uart_create(uart, params);
7070
}
@@ -145,7 +145,7 @@ int Uart::read(uint8_t *buffer, size_t size) {
145145
void Uart::flush() {
146146
if (k_task_is_in_progress()) {
147147
while (m_tx_busy) {
148-
k_event_receive(&m_event, 1, (K_EVENT_ANY | K_EVENT_CLEAR), K_TIMEOUT_FOREVER, NULL);
148+
k_sem_acquire(&m_sem, K_TIMEOUT_FOREVER);
149149
}
150150
}
151151
}
@@ -206,8 +206,8 @@ size_t Uart::write(const uint8_t *buffer, size_t size) {
206206
tx_count = m_tx_size - tx_read;
207207
}
208208

209-
if (tx_count > CDC_TX_PACKET_SIZE) {
210-
tx_count = CDC_TX_PACKET_SIZE;
209+
if (tx_count > UART_TX_PACKET_SIZE) {
210+
tx_count = UART_TX_PACKET_SIZE;
211211
}
212212

213213
if (tx_count) {
@@ -227,7 +227,7 @@ size_t Uart::write(const uint8_t *buffer, size_t size) {
227227
}
228228

229229
if (m_tx_busy) {
230-
k_event_receive(&m_event, 1, (K_EVENT_ANY | K_EVENT_CLEAR), K_TIMEOUT_FOREVER, NULL);
230+
k_sem_acquire(&m_sem, K_TIMEOUT_FOREVER);
231231
}
232232
}
233233
} while (tx_size == 0);
@@ -270,8 +270,8 @@ size_t Uart::write(const uint8_t *buffer, size_t size) {
270270
tx_count = m_tx_size - tx_read;
271271
}
272272

273-
if (tx_count > CDC_TX_PACKET_SIZE) {
274-
tx_count = CDC_TX_PACKET_SIZE;
273+
if (tx_count > UART_TX_PACKET_SIZE) {
274+
tx_count = UART_TX_PACKET_SIZE;
275275
}
276276

277277
if (tx_count) {
@@ -359,7 +359,7 @@ Uart::operator bool() {
359359
void Uart::transmitCallback(class Uart *self) {
360360
uint32_t tx_read, tx_write, tx_count;
361361

362-
k_event_send(&self->m_event, 1);
362+
k_sem_release(&self->m_sem);
363363

364364
tx_count = self->m_tx_count;
365365

@@ -381,8 +381,8 @@ void Uart::transmitCallback(class Uart *self) {
381381
tx_count = (self->m_tx_size - tx_read);
382382
}
383383

384-
if (tx_count > CDC_TX_PACKET_SIZE) {
385-
tx_count = CDC_TX_PACKET_SIZE;
384+
if (tx_count > UART_TX_PACKET_SIZE) {
385+
tx_count = UART_TX_PACKET_SIZE;
386386
}
387387

388388
self->m_tx_count = tx_count;

cores/arduino/Uart.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ class Uart : public HardwareSerial
9696
Callback m_transmit_callback;
9797

9898
k_work_t m_work;
99-
k_event_t m_event;
99+
k_sem_t m_sem;
100100

101101
static void transmitCallback(class Uart *self);
102102
static void eventCallback(class Uart *self, uint32_t events);

cores/arduino/avr/fdevopen.c

Lines changed: 0 additions & 55 deletions
This file was deleted.

cores/arduino/main.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222

2323
#if defined(ARDUINO_MAKEFILE)
2424

25-
#include "STM32WB.h"
26-
2725
void setup(void) {
2826
}
2927

cores/arduino/syscalls_stm32wb.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
#include <sys/unistd.h>
3838

3939
#include "armv7m.h"
40-
#include "rtos_api.h"
4140

4241
extern int wiring_stdin_read(char *data, int nbytes);
4342
extern int wiring_stdout_write(const char *data, int nbytes);

0 commit comments

Comments
 (0)