29 #include "mcu_periph/sys_time_arch.h"
44 #define PX4IO_PORT (&((PX4IO_UART).device))
47 #define FLASH_PORT (&((FLASH_UART).device))
49 #ifndef PX4_IO_FORCE_PROG
50 #define PX4_IO_FORCE_PROG FALSE
51 #elif (PX4_IO_FORCE_PROG == TRUE)
52 PRINT_CONFIG_MSG(
"Using PX4_IO force program. Don't forget to re-program AP with this option off!");
57 #define PROTO_INSYNC 0x12
58 #define PROTO_EOC 0x20
61 #define PROTO_FAILED 0x11
62 #define PROTO_INVALID 0x13
64 #define PROTO_GET_SYNC 0x21
65 #define PROTO_GET_DEVICE 0x22
66 #define PROTO_CHIP_ERASE 0x23
67 #define PROTO_CHIP_VERIFY 0x24
68 #define PROTO_PROG_MULTI 0x27
69 #define PROTO_GET_CRC 0x29
70 #define PROTO_BOOT 0x30
96 if (PX4IO_PORT->char_available(PX4IO_PORT->periph)) {
101 while (PX4IO_PORT->char_available(PX4IO_PORT->periph)) {
102 unsigned char b = PX4IO_PORT->get_byte(PX4IO_PORT->periph);
113 while (state < 4 && FLASH_PORT->char_available(
FLASH_PORT->periph)) {
117 if (
b ==
'p') {
state++; }
else {
return; }
120 if (
b ==
'p') {
state++; }
else {
return; }
123 if (
b ==
'r') {
state++; }
else {
return; }
126 if (
b ==
'z') {
state++; }
else {
return; }
133 if (
state != 4) {
return;}
138 #if defined(CHIBIOS_MCU_ARCH_H)
140 #elif defined(STM32_MCU_ARCH_H)
180 #if !PX4_IO_FORCE_PROG
191 PX4IO_PORT->put_byte(PX4IO_PORT->periph, 0,
p[0]);
192 PX4IO_PORT->put_byte(PX4IO_PORT->periph, 0,
p[1]);
193 PX4IO_PORT->put_byte(PX4IO_PORT->periph, 0,
p[2]);
194 PX4IO_PORT->put_byte(PX4IO_PORT->periph, 0,
p[3]);
195 PX4IO_PORT->put_byte(PX4IO_PORT->periph, 0,
p[4]);
196 PX4IO_PORT->put_byte(PX4IO_PORT->periph, 0,
p[5]);
209 while (state < 4 && PX4IO_PORT->char_available(PX4IO_PORT->periph)) {
211 unsigned char b = PX4IO_PORT->get_byte(PX4IO_PORT->periph);
236 for (
int i = 0; i < 15 && !ret ; i++) {
241 PX4IO_PORT->put_byte(PX4IO_PORT->periph, 0,
PROTO_EOC);
246 while (PX4IO_PORT->char_available(PX4IO_PORT->periph)) {
247 unsigned char b = PX4IO_PORT->get_byte(PX4IO_PORT->periph);
251 if(PX4IO_PORT->char_available(PX4IO_PORT->periph)){
252 b = PX4IO_PORT->get_byte(PX4IO_PORT->periph);
265 while (PX4IO_PORT->char_available(PX4IO_PORT->periph)) {PX4IO_PORT->get_byte(PX4IO_PORT->periph);}
299 PX4IO_PORT->put_byte(PX4IO_PORT->periph, 0,
b);
void sys_time_usleep(uint32_t us)
sys_time_usleep(uint32_t us)
void uart_periph_set_baudrate(struct uart_periph *p, uint32_t baud)
Set baudrate.
void mcu_reboot(enum reboot_state_t reboot_state)
Reboot the MCU.
@ MCU_REBOOT_BOOTLOADER
Go to bootloader.
PRINT_CONFIG_MSG("USE_INS_NAV_INIT defaulting to TRUE")
void intermcu_set_enabled(bool value)
enable/disable intermcu link
Inter-MCU on the AP side.
arch independent LED (Light Emitting Diodes) API
Arch independent mcu ( Micro Controller Unit ) utilities.
PX4IO interface protocol.
#define PX4IO_REBOOT_BL_MAGIC
#define PX4IO_P_SETUP_REBOOT_BL
static uint8_t crc_packet(struct IOPacket *pkt)
uint16_t regs[PKT_MAX_REGS]
#define PROTO_GET_SYNC
NOP for re-establishing sync.
void px4flash_event(void)
#define PROTO_OK
INSYNC/OK - 'ok' response.
#define PROTO_EOC
end of command
#define PROTO_INSYNC
'in sync' byte sent before status
tid_t sys_time_register_timer(float duration, sys_time_cb cb)
Register a new system timer.
void sys_time_cancel_timer(tid_t id)
Cancel a system timer by id.
Architecture independent timing functions.
static bool sys_time_check_and_ack_timer(tid_t id)
Check if timer has elapsed.
int8_t tid_t
sys_time timer id type
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.