FreeRTOS port on GAP8/RISC-V
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gap8/pmsis/drivers/rtc/rtc_internal.c File Reference

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
 

Macro Definition Documentation

#define PI_RTC_CLK_DIV_DEFAULT

Referenced by __pi_rtc_open().

#define PI_RTC_IFR_ALARM_FLAG
#define PI_RTC_IFR_CAL_FLAG
#define PI_RTC_IFR_TIMER_FLAG
#define PI_RTC_YEAR_RANGE_END

Referenced by __pi_rtc_datetime_check().

#define PI_RTC_YEAR_RANGE_START

Function Documentation

int32_t __pi_rtc_alarm_get ( uint8_t  rtc_id,
struct tm *  alarm 
)
static void __pi_rtc_alarm_start ( uint8_t  rtc_id,
pi_rtc_alarm_repeat_e  mode 
)
static
static void __pi_rtc_alarm_stop ( uint8_t  rtc_id)
static
static void __pi_rtc_apb_handler ( void *  arg)
static

RTC_APB IRQ handler. Not used.

References g_rtc_pending.

Referenced by __pi_rtc_open().

static void __pi_rtc_apb_reg_wait ( uint8_t  rtc_id)
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 void __pi_rtc_calendar_start ( uint8_t  rtc_id)
static
static void __pi_rtc_calendar_stop ( uint8_t  rtc_id)
static
static void __pi_rtc_cb_attach ( uint8_t  rtc_id,
uint32_t  mask,
pi_task_t task 
)
static
static void __pi_rtc_clock_div_set ( uint8_t  rtc_id,
uint16_t  clk_div 
)
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)
void __pi_rtc_conf_init ( struct pi_rtc_conf *  conf)

Referenced by pi_rtc_conf_init().

static int8_t __pi_rtc_datetime_check ( struct tm *  time)
static
int32_t __pi_rtc_datetime_get ( uint8_t  rtc_id,
struct tm *  time 
)
static void __pi_rtc_disable ( uint8_t  rtc_id)
static
static void __pi_rtc_enable ( uint8_t  rtc_id)
static
static void __pi_rtc_handler ( void *  arg)
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().

static void __pi_rtc_irq_flag_clear ( uint8_t  rtc_id,
uint32_t  mask 
)
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 uint32_t __pi_rtc_irq_flag_get ( uint8_t  rtc_id)
static

Read IRQ flags.

References __pi_rtc_apb_reg_read(), and RTC_IFR_OFFSET.

Referenced by __pi_rtc_irq_type_handle().

static void __pi_rtc_irq_mask_clear ( uint8_t  rtc_id,
uint32_t  mask 
)
static

Disable IRQ for alarm/timer/calibration.

References __pi_rtc_apb_reg_read(), __pi_rtc_apb_reg_write(), and RTC_IMR_OFFSET.

static uint32_t __pi_rtc_irq_mask_get ( uint8_t  rtc_id)
static
static void __pi_rtc_irq_mask_set ( uint8_t  rtc_id,
uint32_t  mask 
)
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 void __pi_rtc_irq_type_handle ( void *  arg)
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().

static void __pi_rtc_soft_reset ( uint8_t  rtc_id)
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 uint32_t __pi_rtc_status_get ( uint8_t  rtc_id)
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)
int32_t __pi_rtc_timer_set ( uint8_t  rtc_id,
uint32_t  countdown 
)
static void __pi_rtc_timer_start ( uint8_t  rtc_id,
uint8_t  repeat 
)
static
static void __pi_rtc_timer_stop ( uint8_t  rtc_id)
static

Variable Documentation

pi_task_t g_irq_task[3]
static
volatile uint8_t g_rtc_pending
static