29 #include "mcu_periph/sys_time_arch.h"
38 #include "libopencm3/cm3/scb.h"
44 #define PX4IO_PORT (&((PX4IO_UART).device))
47 #define FLASH_PORT (&((FLASH_UART).device))
52 #define PROTO_INSYNC 0x12
53 #define PROTO_EOC 0x20
56 #define PROTO_FAILED 0x11
57 #define PROTO_INVALID 0x13
59 #define PROTO_GET_SYNC 0x21
60 #define PROTO_GET_DEVICE 0x22
61 #define PROTO_CHIP_ERASE 0x23
62 #define PROTO_LOAD_ADDRESS 0x24
63 #define PROTO_PROG_MULTI 0x27
64 #define PROTO_GET_CRC 0x29
65 #define PROTO_BOOT 0x30
91 if (PX4IO_PORT->char_available(PX4IO_PORT->periph)) {
96 while (PX4IO_PORT->char_available(PX4IO_PORT->periph)) {
97 unsigned char b = PX4IO_PORT->get_byte(PX4IO_PORT->periph);
108 while (state < 4 && FLASH_PORT->char_available(
FLASH_PORT->periph)) {
112 if (b ==
'p') { state++; }
else {
return; }
115 if (b ==
'p') { state++; }
else {
return; }
118 if (b ==
'r') { state++; }
else {
return; }
121 if (b ==
'z') { state++; }
else {
return; }
128 if (state != 4) {
return;}
193 PX4IO_PORT->put_byte(PX4IO_PORT->periph, 0, p[0]);
194 PX4IO_PORT->put_byte(PX4IO_PORT->periph, 0, p[1]);
195 PX4IO_PORT->put_byte(PX4IO_PORT->periph, 0, p[2]);
196 PX4IO_PORT->put_byte(PX4IO_PORT->periph, 0, p[3]);
197 PX4IO_PORT->put_byte(PX4IO_PORT->periph, 0, p[4]);
198 PX4IO_PORT->put_byte(PX4IO_PORT->periph, 0, p[5]);
211 while (state < 4 && PX4IO_PORT->char_available(PX4IO_PORT->periph)) {
213 unsigned char b = PX4IO_PORT->get_byte(PX4IO_PORT->periph);
219 if (b == 0xe5) { state++; }
else { state = 0; }
222 if (b == 0x32) { state++; }
else { state = 0; }
225 if (b == 0x0a) { state++; }
else { state = 0; }
238 for (
int i = 0; i < 15 && !ret ; i++) {
243 PX4IO_PORT->put_byte(PX4IO_PORT->periph, 0,
PROTO_EOC);
248 while (PX4IO_PORT->char_available(PX4IO_PORT->periph)) {
249 unsigned char b = PX4IO_PORT->get_byte(PX4IO_PORT->periph);
260 while (PX4IO_PORT->char_available(PX4IO_PORT->periph)) {PX4IO_PORT->get_byte(PX4IO_PORT->periph);}
279 PX4IO_PORT->put_byte(PX4IO_PORT->periph, 0, b);
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
#define PX4IO_P_SETUP_REBOOT_BL
void uart_periph_set_baudrate(struct uart_periph *p, uint32_t baud)
Set baudrate.
#define PROTO_GET_SYNC
NOP for re-establishing sync.
void intermcu_set_enabled(bool value)
void sys_time_cancel_timer(tid_t id)
Cancel a system timer by id.
#define PROTO_EOC
end of command
void px4flash_event(void)
#define PROTO_INSYNC
'in sync' byte sent before status
void sys_time_usleep(uint32_t us)
sys_time_usleep(uint32_t us)
static uint8_t crc_packet(struct IOPacket *pkt)
Architecture independent timing functions.
int8_t tid_t
sys_time timer id type
Rotorcraft Inter-MCU on the autopilot.
static bool sys_time_check_and_ack_timer(tid_t id)
Check if timer has elapsed.
uint16_t regs[PKT_MAX_REGS]
arch independent LED (Light Emitting Diodes) API
#define PX4IO_REBOOT_BL_MAGIC
tid_t sys_time_register_timer(float duration, sys_time_cb cb)
Register a new system timer.