29 #include "mcu_periph/sys_time_arch.h"
40 #ifdef STM32_MCU_ARCH_H
41 #include <libopencm3/cm3/scb.h>
48 #define PX4IO_PORT (&((PX4IO_UART).device))
51 #define FLASH_PORT (&((FLASH_UART).device))
53 #ifndef PX4_IO_FORCE_PROG
54 #define PX4_IO_FORCE_PROG FALSE
55 #elif (PX4_IO_FORCE_PROG == TRUE)
56 PRINT_CONFIG_MSG(
"Using PX4_IO force program. Don't forget to re-program AP with this option off!");
61 #define PROTO_INSYNC 0x12
62 #define PROTO_EOC 0x20
65 #define PROTO_FAILED 0x11
66 #define PROTO_INVALID 0x13
68 #define PROTO_GET_SYNC 0x21
69 #define PROTO_GET_DEVICE 0x22
70 #define PROTO_CHIP_ERASE 0x23
71 #define PROTO_CHIP_VERIFY 0x24
72 #define PROTO_PROG_MULTI 0x27
73 #define PROTO_GET_CRC 0x29
74 #define PROTO_BOOT 0x30
100 if (PX4IO_PORT->char_available(PX4IO_PORT->periph)) {
105 while (PX4IO_PORT->char_available(PX4IO_PORT->periph)) {
106 unsigned char b = PX4IO_PORT->get_byte(PX4IO_PORT->periph);
121 if (
b ==
'p') {
state++; }
else {
return; }
124 if (
b ==
'p') {
state++; }
else {
return; }
127 if (
b ==
'r') {
state++; }
else {
return; }
130 if (
b ==
'z') {
state++; }
else {
return; }
137 if (
state != 4) {
return;}
142 #if defined(CHIBIOS_MCU_ARCH_H)
144 #elif defined(STM32_MCU_ARCH_H)
184 #if !PX4_IO_FORCE_PROG
195 PX4IO_PORT->put_byte(PX4IO_PORT->periph, 0,
p[0]);
196 PX4IO_PORT->put_byte(PX4IO_PORT->periph, 0,
p[1]);
197 PX4IO_PORT->put_byte(PX4IO_PORT->periph, 0,
p[2]);
198 PX4IO_PORT->put_byte(PX4IO_PORT->periph, 0,
p[3]);
199 PX4IO_PORT->put_byte(PX4IO_PORT->periph, 0,
p[4]);
200 PX4IO_PORT->put_byte(PX4IO_PORT->periph, 0,
p[5]);
213 while (state < 4 && PX4IO_PORT->
char_available(PX4IO_PORT->periph)) {
215 unsigned char b = PX4IO_PORT->get_byte(PX4IO_PORT->periph);
240 for (
int i = 0; i < 15 && !ret ; i++) {
245 PX4IO_PORT->put_byte(PX4IO_PORT->periph, 0,
PROTO_EOC);
250 while (PX4IO_PORT->char_available(PX4IO_PORT->periph)) {
251 unsigned char b = PX4IO_PORT->get_byte(PX4IO_PORT->periph);
255 if(PX4IO_PORT->char_available(PX4IO_PORT->periph)){
256 b = PX4IO_PORT->get_byte(PX4IO_PORT->periph);
269 while (PX4IO_PORT->char_available(PX4IO_PORT->periph)) {PX4IO_PORT->get_byte(PX4IO_PORT->periph);}
303 PX4IO_PORT->put_byte(PX4IO_PORT->periph, 0,
b);
void sys_time_usleep(uint32_t us)
sys_time_usleep(uint32_t us)
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
void uart_periph_set_baudrate(struct uart_periph *periph, uint32_t baud)
Arch independent mcu ( Micro Controller Unit ) utilities.
static int char_available(struct linkdev *d)
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.