FreeRTOS port on GAP8/RISC-V
|
Data Structures | |
struct | pi_rtc_bcd_datetime_t |
Macros | |
#define | PI_RTC_YEAR_RANGE_START |
#define | PI_RTC_YEAR_RANGE_END |
#define | PI_RTC_IFR_ALARM_FLAG |
#define | PI_RTC_IFR_TIMER_FLAG |
#define | PI_RTC_IFR_CAL_FLAG |
#define | PI_RTC_CLK_DIV_DEFAULT |
Functions | |
static int8_t | __pi_rtc_datetime_check (struct tm *time) |
static void | __pi_rtc_apb_handler (void *arg) |
static void | __pi_rtc_handler (void *arg) |
static void | __pi_rtc_irq_type_handle (void *arg) |
static void | __pi_rtc_apb_reg_wait (uint8_t rtc_id) |
static uint32_t | __pi_rtc_apb_reg_read (uint8_t rtc_id, uint8_t addr) |
static void | __pi_rtc_apb_reg_write (uint8_t rtc_id, uint8_t addr, uint32_t data) |
static void | __pi_rtc_enable (uint8_t rtc_id) |
static void | __pi_rtc_disable (uint8_t rtc_id) |
static void | __pi_rtc_soft_reset (uint8_t rtc_id) |
static void | __pi_rtc_clock_div_set (uint8_t rtc_id, uint16_t clk_div) |
static void | __pi_rtc_calendar_start (uint8_t rtc_id) |
static void | __pi_rtc_calendar_stop (uint8_t rtc_id) |
static void | __pi_rtc_alarm_start (uint8_t rtc_id, pi_rtc_alarm_repeat_e mode) |
static void | __pi_rtc_alarm_stop (uint8_t rtc_id) |
static void | __pi_rtc_timer_start (uint8_t rtc_id, uint8_t repeat) |
static void | __pi_rtc_timer_stop (uint8_t rtc_id) |
static uint32_t | __pi_rtc_status_get (uint8_t rtc_id) |
static void | __pi_rtc_irq_mask_set (uint8_t rtc_id, uint32_t mask) |
static void | __pi_rtc_irq_mask_clear (uint8_t rtc_id, uint32_t mask) |
static uint32_t | __pi_rtc_irq_flag_get (uint8_t rtc_id) |
static void | __pi_rtc_irq_flag_clear (uint8_t rtc_id, uint32_t mask) |
static void | __pi_rtc_datetime_to_bcd (struct tm *time, pi_rtc_bcd_datetime_t *datetime) |
static void | __pi_rtc_bcd_to_datetime (pi_rtc_bcd_datetime_t *datetime, struct tm *time) |
static uint32_t | __pi_rtc_irq_mask_get (uint8_t rtc_id) |
static void | __pi_rtc_cb_attach (uint8_t rtc_id, uint32_t mask, pi_task_t *task) |
void | __pi_rtc_conf_init (struct pi_rtc_conf *conf) |
int32_t | __pi_rtc_open (uint8_t rtc_id, struct pi_rtc_conf *conf) |
void | __pi_rtc_close (uint8_t rtc_id) |
int32_t | __pi_rtc_datetime_set (uint8_t rtc_id, struct tm *time) |
int32_t | __pi_rtc_datetime_get (uint8_t rtc_id, struct tm *time) |
int32_t | __pi_rtc_alarm_set (uint8_t rtc_id, struct tm *alarm) |
int32_t | __pi_rtc_alarm_get (uint8_t rtc_id, struct tm *alarm) |
int32_t | __pi_rtc_timer_set (uint8_t rtc_id, uint32_t countdown) |
uint32_t | __pi_rtc_timer_get (uint8_t rtc_id) |
int32_t | __pi_rtc_ioctl (uint8_t rtc_id, uint32_t cmd, void *arg) |
Variables | |
static pi_task_t | g_irq_task [3] |
static volatile uint8_t | g_rtc_pending |
#define PI_RTC_CLK_DIV_DEFAULT |
Referenced by __pi_rtc_open().
#define PI_RTC_IFR_ALARM_FLAG |
Referenced by __pi_rtc_alarm_start(), __pi_rtc_cb_attach(), __pi_rtc_ioctl(), and __pi_rtc_irq_type_handle().
#define PI_RTC_IFR_CAL_FLAG |
Referenced by __pi_rtc_cb_attach(), and __pi_rtc_irq_type_handle().
#define PI_RTC_IFR_TIMER_FLAG |
Referenced by __pi_rtc_cb_attach(), __pi_rtc_ioctl(), __pi_rtc_irq_type_handle(), and __pi_rtc_timer_start().
#define PI_RTC_YEAR_RANGE_END |
Referenced by __pi_rtc_datetime_check().
#define PI_RTC_YEAR_RANGE_START |
Referenced by __pi_rtc_bcd_to_datetime(), __pi_rtc_datetime_check(), and __pi_rtc_datetime_to_bcd().
int32_t __pi_rtc_alarm_get | ( | uint8_t | rtc_id, |
struct tm * | alarm | ||
) |
References __pi_rtc_apb_reg_read(), __pi_rtc_bcd_to_datetime(), ALARM1_DATE_OFFSET, ALARM1_TIME_OFFSET, pi_rtc_bcd_datetime_t::date, and pi_rtc_bcd_datetime_t::time.
Referenced by pi_rtc_alarm_get().
int32_t __pi_rtc_alarm_set | ( | uint8_t | rtc_id, |
struct tm * | alarm | ||
) |
References __pi_rtc_apb_reg_write(), __pi_rtc_datetime_check(), __pi_rtc_datetime_to_bcd(), ALARM1_DATE_OFFSET, ALARM1_TIME_OFFSET, pi_rtc_bcd_datetime_t::date, and pi_rtc_bcd_datetime_t::time.
Referenced by __pi_rtc_open(), and pi_rtc_alarm_set().
|
static |
Start alarm.
References __pi_rtc_apb_reg_write(), __pi_rtc_irq_flag_clear(), __pi_rtc_irq_mask_set(), ALARM_CONTROL_OFFSET, PI_RTC_IFR_ALARM_FLAG, Catch::Generators::repeat(), RTC_ALARM_CONTROL_CFG, RTC_ALARM_CONTROL_MODE, and RTC_ALARM_CONTROL_SB.
Referenced by __pi_rtc_ioctl().
|
static |
Stop alarm.
References __pi_rtc_apb_reg_write(), ALARM_CONTROL_OFFSET, and RTC_ALARM_CONTROL_SB.
Referenced by __pi_rtc_ioctl().
|
static |
|
static |
Read from RTC internal registers.
References __pi_rtc_apb_reg_wait(), g_rtc_pending, hal_rtc_data_get(), hal_rtc_irq_flag_read_reset(), and hal_rtc_request_set().
Referenced by __pi_rtc_alarm_get(), __pi_rtc_datetime_get(), __pi_rtc_disable(), __pi_rtc_enable(), __pi_rtc_irq_flag_clear(), __pi_rtc_irq_flag_get(), __pi_rtc_irq_mask_clear(), __pi_rtc_irq_mask_get(), __pi_rtc_irq_mask_set(), __pi_rtc_soft_reset(), __pi_rtc_status_get(), and __pi_rtc_timer_get().
|
static |
Wait for APB IRQ. Used to read/write RTC internal registers.
References FC_SW_NOTIFY_EVENT, g_rtc_pending, and hal_eu_evt_mask_wait_and_clr().
Referenced by __pi_rtc_apb_reg_read(), and __pi_rtc_apb_reg_write().
|
static |
Write to RTC internal regisers.
References __pi_rtc_apb_reg_wait(), g_rtc_pending, hal_rtc_data_set(), hal_rtc_irq_flag_write_reset(), and hal_rtc_request_set().
Referenced by __pi_rtc_alarm_set(), __pi_rtc_alarm_start(), __pi_rtc_alarm_stop(), __pi_rtc_calendar_start(), __pi_rtc_calendar_stop(), __pi_rtc_clock_div_set(), __pi_rtc_datetime_set(), __pi_rtc_disable(), __pi_rtc_enable(), __pi_rtc_irq_flag_clear(), __pi_rtc_irq_mask_clear(), __pi_rtc_irq_mask_set(), __pi_rtc_soft_reset(), __pi_rtc_timer_set(), __pi_rtc_timer_start(), and __pi_rtc_timer_stop().
|
static |
References pi_rtc_bcd_datetime_t::date, rtc_calendar_date_t::day0, rtc_calendar_date_t::day1, rtc_calendar_time_t::field, rtc_calendar_date_t::field, rtc_calendar_time_t::hou0, rtc_calendar_time_t::hou1, rtc_calendar_time_t::min0, rtc_calendar_time_t::min1, rtc_calendar_date_t::mon0, rtc_calendar_date_t::mon1, PI_RTC_YEAR_RANGE_START, rtc_calendar_time_t::sec0, rtc_calendar_time_t::sec1, pi_rtc_bcd_datetime_t::time, rtc_calendar_time_t::word, rtc_calendar_date_t::word, rtc_calendar_date_t::yea0, and rtc_calendar_date_t::yea1.
Referenced by __pi_rtc_alarm_get(), and __pi_rtc_datetime_get().
|
static |
Start calendar.
References __pi_rtc_apb_reg_write(), CALENDAR_CONTROL_OFFSET, and RTC_CALENDAR_CONTROL_SB.
Referenced by __pi_rtc_ioctl().
|
static |
Stop calendar.
References __pi_rtc_apb_reg_write(), CALENDAR_CONTROL_OFFSET, and RTC_CALENDAR_CONTROL_SB.
Referenced by __pi_rtc_ioctl().
|
static |
References memcpy(), PI_RTC_IFR_ALARM_FLAG, PI_RTC_IFR_CAL_FLAG, and PI_RTC_IFR_TIMER_FLAG.
Referenced by __pi_rtc_ioctl().
|
static |
Set up clock divider. Used when RTC should output a signal.
References __pi_rtc_apb_reg_write(), __pi_rtc_disable(), __pi_rtc_enable(), and CKIN_DIV1_OFFSET.
Referenced by __pi_rtc_open().
void __pi_rtc_close | ( | uint8_t | rtc_id | ) |
References __pi_rtc_disable(), hal_soc_eu_clear_fc_mask(), pi_fc_event_handler_clear(), SOC_EVENT_RTC, and SOC_EVENT_RTC_APB.
Referenced by pi_rtc_close().
void __pi_rtc_conf_init | ( | struct pi_rtc_conf * | conf | ) |
Referenced by pi_rtc_conf_init().
|
static |
References PI_RTC_YEAR_RANGE_END, PI_RTC_YEAR_RANGE_START, and printf.
Referenced by __pi_rtc_alarm_set(), and __pi_rtc_datetime_set().
int32_t __pi_rtc_datetime_get | ( | uint8_t | rtc_id, |
struct tm * | time | ||
) |
References __pi_rtc_apb_reg_read(), __pi_rtc_bcd_to_datetime(), CALENDAR_DATE_OFFSET, CALENDAR_TIME_OFFSET, pi_rtc_bcd_datetime_t::date, and pi_rtc_bcd_datetime_t::time.
Referenced by pi_rtc_datetime_get().
int32_t __pi_rtc_datetime_set | ( | uint8_t | rtc_id, |
struct tm * | time | ||
) |
|
static |
References pi_rtc_bcd_datetime_t::date, rtc_calendar_date_t::day0, rtc_calendar_date_t::day1, rtc_calendar_time_t::field, rtc_calendar_date_t::field, rtc_calendar_time_t::hou0, rtc_calendar_time_t::hou1, rtc_calendar_time_t::min0, rtc_calendar_time_t::min1, rtc_calendar_date_t::mon0, rtc_calendar_date_t::mon1, PI_RTC_YEAR_RANGE_START, rtc_calendar_time_t::sec0, rtc_calendar_time_t::sec1, pi_rtc_bcd_datetime_t::time, rtc_calendar_time_t::word, rtc_calendar_date_t::word, rtc_calendar_date_t::yea0, and rtc_calendar_date_t::yea1.
Referenced by __pi_rtc_alarm_set(), and __pi_rtc_datetime_set().
|
static |
Enable RTC standby mode.
References __pi_rtc_apb_reg_read(), __pi_rtc_apb_reg_write(), RTC_CR_OFFSET, and RTC_RTC_CR_SB.
Referenced by __pi_rtc_clock_div_set(), and __pi_rtc_close().
|
static |
Disable RTC standby mode.
References __pi_rtc_apb_reg_read(), __pi_rtc_apb_reg_write(), RTC_CR_OFFSET, and RTC_RTC_CR_SB_MASK.
Referenced by __pi_rtc_clock_div_set().
|
static |
RTC IRQ handler. IRQ triggered when alarm/timer/calibration ends.
References __pi_rtc_irq_type_handle(), pi_l2_malloc(), pi_task_callback(), pmsis_event_get_default_scheduler(), pmsis_event_push(), and printf.
Referenced by __pi_rtc_open().
int32_t __pi_rtc_ioctl | ( | uint8_t | rtc_id, |
uint32_t | cmd, | ||
void * | arg | ||
) |
|
static |
Acknowledge received IRQ, need to be cleared to get other IRQ. Clear IRQ flags. IRQ flags need to be cleared before in order to receive next ones.
References __pi_rtc_apb_reg_read(), __pi_rtc_apb_reg_write(), and RTC_IFR_OFFSET.
Referenced by __pi_rtc_alarm_start(), __pi_rtc_irq_type_handle(), and __pi_rtc_timer_start().
|
static |
Read IRQ flags.
References __pi_rtc_apb_reg_read(), and RTC_IFR_OFFSET.
Referenced by __pi_rtc_irq_type_handle().
|
static |
Disable IRQ for alarm/timer/calibration.
References __pi_rtc_apb_reg_read(), __pi_rtc_apb_reg_write(), and RTC_IMR_OFFSET.
|
static |
References __pi_rtc_apb_reg_read(), and RTC_IMR_OFFSET.
|
static |
Enable IRQ for alarm/timer/calibration.
References __pi_rtc_apb_reg_read(), __pi_rtc_apb_reg_write(), and RTC_IMR_OFFSET.
Referenced by __pi_rtc_alarm_start(), and __pi_rtc_timer_start().
|
static |
Function called by the handler to clear IRQ flags.
References __pi_rtc_irq_flag_clear(), __pi_rtc_irq_flag_get(), pi_l2_free(), PI_RTC_IFR_ALARM_FLAG, PI_RTC_IFR_CAL_FLAG, and PI_RTC_IFR_TIMER_FLAG.
Referenced by __pi_rtc_handler().
int32_t __pi_rtc_open | ( | uint8_t | rtc_id, |
struct pi_rtc_conf * | conf | ||
) |
References __pi_rtc_alarm_set(), __pi_rtc_apb_handler(), __pi_rtc_clock_div_set(), __pi_rtc_datetime_set(), __pi_rtc_handler(), __pi_rtc_soft_reset(), __pi_rtc_timer_set(), hal_soc_eu_set_fc_mask(), pi_fc_event_handler_set(), PI_RTC_CLK_DIV_DEFAULT, SOC_EVENT_RTC, and SOC_EVENT_RTC_APB.
Referenced by pi_rtc_open().
|
static |
Reset RTC device after configs.
References __pi_rtc_apb_reg_read(), __pi_rtc_apb_reg_write(), RTC_CR_OFFSET, and RTC_RTC_CR_SOFT_RST.
Referenced by __pi_rtc_open().
|
static |
Read RTC IRQ status.
References __pi_rtc_apb_reg_read(), and RTC_SR_OFFSET.
uint32_t __pi_rtc_timer_get | ( | uint8_t | rtc_id | ) |
References __pi_rtc_apb_reg_read(), and COUNTDOWN1_TIMER_OFFSET.
Referenced by pi_rtc_timer_get().
int32_t __pi_rtc_timer_set | ( | uint8_t | rtc_id, |
uint32_t | countdown | ||
) |
References __pi_rtc_apb_reg_write(), and COUNTDOWN1_INIT_OFFSET.
Referenced by __pi_rtc_open(), and pi_rtc_timer_set().
|
static |
Start timer.
References __pi_rtc_apb_reg_write(), __pi_rtc_irq_flag_clear(), __pi_rtc_irq_mask_set(), COUNTDOWN_CONTROL_OFFSET, PI_RTC_IFR_TIMER_FLAG, RTC_COUNTDOWN_CONTROL_MODE, and RTC_COUNTDOWN_CONTROL_SB.
Referenced by __pi_rtc_ioctl().
|
static |
Stop timer.
References __pi_rtc_apb_reg_write(), COUNTDOWN_CONTROL_OFFSET, and RTC_COUNTDOWN_CONTROL_SB.
Referenced by __pi_rtc_ioctl().
|
static |
|
static |
Referenced by __pi_rtc_apb_handler(), __pi_rtc_apb_reg_read(), __pi_rtc_apb_reg_wait(), and __pi_rtc_apb_reg_write().