-
Notifications
You must be signed in to change notification settings - Fork 0
Some key RP2040 code points I thought I'd explain
Michael Shipman edited this page Mar 14, 2024
·
1 revision
Some stuff I don't think the RP2040 SDK documentation explains super well https://www.raspberrypi.com/documentation/pico-sdk/
Vars & Refs
alarm_pool_t *ack_alarm_pool;
alarm_id_t ack_alarm_id;
static int64_t ack_timer_callback(alarm_id_t id, void *user_data);
Create a new alarm pool to use
ack_alarm_pool = alarm_pool_create_with_unused_hardware_alarm(4);
Set an alarm to run ack_timer_callback() in 1000 milliseconds
ack_alarm_id = alarm_pool_add_alarm_in_ms(ack_alarm_pool, 1000, ack_timer_callback, NULL, true);
Timer callback function example
static int64_t ack_timer_callback(alarm_id_t id, void *user_data) {
send_ack = true;
return 0; // don't repeat
}