41 #include <px4_platform_common/px4_config.h> 42 #include "platform/cxxinitialize.h" 60 #include <stm32_uart.h> 97 if ((*target | modification) != *target) {
104 if ((*target & ~modification) != *target) {
111 if ((*target & modification) != *target) {
130 msg_next_in = (msg_next_in + 1) %
NUM_MSG;
149 msg_next_out = (msg_next_out + 1) %
NUM_MSG;
165 static uint64_t last_mem_time = 0;
168 if (now - last_mem_time > (500 * 1000)) {
169 struct mallinfo minfo = mallinfo();
178 static bool heartbeat =
false;
195 const unsigned max_brightness = 118;
198 static unsigned brightness = max_brightness;
199 static unsigned brightness_counter = 0;
200 static unsigned on_counter = 0;
202 if (brightness_counter < max_brightness) {
204 bool on = ((on_counter * 100) / brightness_counter + 1) <= ((brightness * 100) / max_brightness + 1);
211 brightness_counter++;
232 brightness = (n * n) / 8;
233 brightness_counter = 0;
264 #define APP_SIZE_MAX 0xf000 265 #define APP_LOAD_ADDRESS 0x08001000 271 sum = crc32part((uint8_t *)&bytes,
sizeof(bytes), sum);
284 #if defined(CONFIG_HAVE_CXX) && defined(CONFIG_HAVE_CXXINITIALIZE) 290 # if defined(CONFIG_SYSTEM_NSH_CXXINITIALIZE) 291 # error CONFIG_SYSTEM_NSH_CXXINITIALIZE Must not be defined! Use CONFIG_HAVE_CXX and CONFIG_HAVE_CXXINITIALIZE. 295 # error platform is dependent on c++ both CONFIG_HAVE_CXX and CONFIG_HAVE_CXXINITIALIZE must be defined. 311 #ifdef CONFIG_ARCH_DMA 316 syslog(LOG_INFO,
"\nPX4IO: starting\n");
332 #ifdef ENABLE_SBUS_OUT 357 struct mallinfo minfo = mallinfo();
359 syslog(LOG_INFO,
"MEM: free %u, largest %u\n", minfo.mxordblk, minfo.fordblks);
377 if (minfo.mxordblk < 600) {
379 syslog(LOG_ERR,
"ERR: not enough MEM");
406 uint64_t last_debug_time = 0;
407 uint64_t last_heartbeat_time = 0;
408 uint64_t last_loop_time = 0;
417 }
else if (
dt > 0.02
f) {
446 uint32_t heartbeat_period_us = 250 * 1000UL;
449 heartbeat_period_us /= 4;
480 isr_debug(1,
"d:%u s=0x%x a=0x%x f=0x%x m=%u",
485 (
unsigned)mallinfo().mxordblk);
#define PX4_CRITICAL_SECTION(cmd)
void schedule_reboot(uint32_t time_delta_usec)
schedule a reboot in time_delta_usec microseconds
static struct hrt_call serial_dma_call
volatile uint16_t r_page_setup[]
PAGE 100.
measure the time elapsed performing an event
#define PX4IO_P_SETUP_SET_DEBUG
void failsafe_led_init(void)
static void check_reboot(void)
check for a scheduled reboot
#define debug(fmt, args...)
#define PX4IO_THERMAL_IGNORE
void(* hrt_callout)(void *arg)
Callout function type.
void controls_init(void)
R/C receiver handling.
void isr_debug(uint8_t level, const char *fmt,...)
send a debug message to the console
static volatile uint32_t last_msg_counter
#define PX4IO_P_SETUP_CRC
static uint64_t reboot_time
#define ENABLE_SBUS_OUT(_s)
High-resolution timer with callouts and timekeeping.
void atomic_modify_clear(volatile uint16_t *target, uint16_t modification)
static void heartbeat_blink(void)
__EXPORT int user_start(int argc, char *argv[])
static char msg[NUM_MSG][CONFIG_USART1_TXBUFSIZE]
static volatile uint8_t msg_next_out
void perf_count(perf_counter_t handle)
Count a performance event.
void atomic_modify_or(volatile uint16_t *target, uint16_t modification)
Vector< float, 6 > f(float t, const Matrix< float, 6, 1 > &, const Matrix< float, 3, 1 > &)
static volatile uint8_t msg_next_in
void safety_init(void)
Safety switch/LED.
void perf_end(perf_counter_t handle)
End a performance event.
void interface_init(void)
FMU communications.
static void update_mem_usage(void)
__EXPORT void hrt_call_every(struct hrt_call *entry, hrt_abstime delay, hrt_abstime interval, hrt_callout callout, void *arg)
Call callout(arg) after delay, and then after every interval.
#define PX4IO_P_STATUS_FLAGS_OVERRIDE
#define PX4IO_P_STATUS_FREEMEM
#define PX4IO_P_STATUS_FLAGS_SAFETY_OFF
General defines and structures for the PX4IO module firmware.
struct sys_state_s system_state
#define PX4IO_P_SETUP_THERMAL
thermal management
#define PX4IO_P_SETUP_ARMING_FMU_ARMED
#define PX4IO_THERMAL_FULL
void output_limit_init(output_limit_t *limit)
__EXPORT int up_pwm_servo_init(uint32_t channel_mask)
Intialise the PWM servo outputs using the specified configuration.
static volatile uint32_t msg_counter
volatile uint16_t r_page_status[]
PAGE 1.
static void calculate_fw_crc(void)
static void ring_blink(void)
static void show_debug_messages(void)
void atomic_modify_and(volatile uint16_t *target, uint16_t modification)
__EXPORT void hrt_init(void)
Library for output limiting (PWM for example)
int adc_init(void)
Sensors/misc inputs.
void perf_begin(perf_counter_t handle)
Begin a performance event.
measure the interval between instances of an event
__EXPORT hrt_abstime hrt_absolute_time(void)
Get absolute time in [us] (does not wrap).
Performance measuring tools.