FreeRTOS port on GAP8/RISC-V
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gap9/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_handler (void *arg)
 
static void __pi_rtc_apb_reg_wait (struct rtc_data_s *driver_data)
 
static uint32_t __pi_rtc_apb_reg_read (struct rtc_data_s *driver_data, uint8_t addr)
 
static void __pi_rtc_apb_reg_write (struct rtc_data_s *driver_data, uint8_t addr, uint32_t data)
 
static uint32_t __pi_rtc_status_get (struct rtc_data_s *driver_data)
 
static void __pi_rtc_irq_mask_set (struct rtc_data_s *driver_data, uint32_t mask)
 
static uint32_t __pi_rtc_irq_mask_get (struct rtc_data_s *driver_data)
 
static void __pi_rtc_irq_mask_clear (struct rtc_data_s *driver_data, uint32_t mask)
 
static uint32_t __pi_rtc_irq_flag_get (struct rtc_data_s *driver_data)
 
static void __pi_rtc_irq_flag_clear (struct rtc_data_s *driver_data, uint32_t mask)
 
static void __pi_rtc_enable (struct rtc_data_s *driver_data)
 
static void __pi_rtc_disable (struct rtc_data_s *driver_data)
 
static void __pi_rtc_soft_reset (struct rtc_data_s *driver_data)
 
static void __pi_rtc_clock_div_set (struct rtc_data_s *driver_data, uint16_t clk_div)
 
static void __pi_rtc_calendar_start (struct rtc_data_s *driver_data)
 
static void __pi_rtc_calendar_stop (struct rtc_data_s *driver_data)
 
static void __pi_rtc_alarm_start (struct rtc_data_s *driver_data, pi_rtc_alarm_repeat_e mode)
 
static void __pi_rtc_alarm_stop (struct rtc_data_s *driver_data)
 
static void __pi_rtc_timer_start (struct rtc_data_s *driver_data, uint8_t repeat)
 
static void __pi_rtc_timer_stop (struct rtc_data_s *driver_data)
 
static void __pi_rtc_cb_attach (struct rtc_data_s *driver_data, uint32_t event, pi_task_t *task)
 
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)
 
void __pi_rtc_conf_init (struct pi_rtc_conf *conf)
 
int32_t __pi_rtc_open (struct rtc_data_s **device_data, struct pi_rtc_conf *conf)
 
void __pi_rtc_close (struct rtc_data_s *device_data)
 
int32_t __pi_rtc_datetime_set (struct rtc_data_s *device_data, struct tm *time)
 
int32_t __pi_rtc_datetime_get (struct rtc_data_s *device_data, struct tm *time)
 
int32_t __pi_rtc_alarm_set (struct rtc_data_s *device_data, struct tm *alarm)
 
int32_t __pi_rtc_alarm_get (struct rtc_data_s *device_data, struct tm *alarm)
 
int32_t __pi_rtc_timer_set (struct rtc_data_s *device_data, uint32_t countdown)
 
uint32_t __pi_rtc_timer_get (struct rtc_data_s *device_data)
 
int32_t __pi_rtc_ioctl (struct rtc_data_s *device_data, uint32_t cmd, void *arg)
 

Variables

static pi_task_t g_irq_task [3]
 
static volatile uint8_t g_rtc_pending
 
static struct rtc_data_sg_rtc_data
 

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 ( struct rtc_data_s device_data,
struct tm *  alarm 
)
static void __pi_rtc_alarm_start ( struct rtc_data_s driver_data,
pi_rtc_alarm_repeat_e  mode 
)
static
static void __pi_rtc_alarm_stop ( struct rtc_data_s driver_data)
static
static void __pi_rtc_apb_handler ( void *  arg)
static

RTC_APB IRQ handler. Not used.

References rtc_data_s::pending_irq.

Referenced by __pi_rtc_open().

static void __pi_rtc_apb_reg_wait ( struct rtc_data_s driver_data)
static

Wait for APB IRQ. Used to read/write RTC internal registers.

References FC_SOC_EVENT_NOTIFY_IRQ, hal_eu_evt_mask_wait_and_clr(), and rtc_data_s::pending_irq.

Referenced by __pi_rtc_apb_reg_read(), and __pi_rtc_apb_reg_write().

static void __pi_rtc_calendar_start ( struct rtc_data_s driver_data)
static
static void __pi_rtc_calendar_stop ( struct rtc_data_s driver_data)
static
static void __pi_rtc_cb_attach ( struct rtc_data_s driver_data,
uint32_t  event,
pi_task_t task 
)
static

Attach an event task to an event.

References rtc_data_s::event_task, PI_RTC_EVENT_ALARM, PI_RTC_EVENT_CALIB, and PI_RTC_EVENT_TIMER.

Referenced by __pi_rtc_ioctl().

static void __pi_rtc_clock_div_set ( struct rtc_data_s driver_data,
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_conf_init ( struct pi_rtc_conf *  conf)

References memset().

static int8_t __pi_rtc_datetime_check ( struct tm *  time)
static
int32_t __pi_rtc_datetime_get ( struct rtc_data_s device_data,
struct tm *  time 
)
static void __pi_rtc_disable ( struct rtc_data_s driver_data)
static
static void __pi_rtc_enable ( struct rtc_data_s driver_data)
static
static void __pi_rtc_handler ( void *  arg)
static

RTC IRQ handler. IRQ triggered when alarm/timer/calibration ends.

References __pi_rtc_irq_type_handler(), pi_l2_malloc(), pi_task_callback(), pi_task_push(), and RTC_TRACE_ERR.

Referenced by __pi_rtc_open().

static void __pi_rtc_irq_flag_clear ( struct rtc_data_s driver_data,
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_handler(), and __pi_rtc_timer_start().

static uint32_t __pi_rtc_irq_flag_get ( struct rtc_data_s driver_data)
static

Read IRQ flags.

References __pi_rtc_apb_reg_read(), and RTC_IFR_OFFSET.

Referenced by __pi_rtc_irq_type_handler().

static void __pi_rtc_irq_mask_clear ( struct rtc_data_s driver_data,
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 ( struct rtc_data_s driver_data)
static

Get current IRQ.

References __pi_rtc_apb_reg_read(), and RTC_IMR_OFFSET.

static void __pi_rtc_irq_mask_set ( struct rtc_data_s driver_data,
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_handler ( void *  arg)
static
static void __pi_rtc_soft_reset ( struct rtc_data_s driver_data)
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 ( struct rtc_data_s driver_data)
static

Read RTC IRQ status.

References __pi_rtc_apb_reg_read(), and RTC_SR_OFFSET.

uint32_t __pi_rtc_timer_get ( struct rtc_data_s device_data)
int32_t __pi_rtc_timer_set ( struct rtc_data_s device_data,
uint32_t  countdown 
)
static void __pi_rtc_timer_start ( struct rtc_data_s driver_data,
uint8_t  repeat 
)
static
static void __pi_rtc_timer_stop ( struct rtc_data_s driver_data)
static

Variable Documentation

pi_task_t g_irq_task[3]
static
struct rtc_data_s* g_rtc_data
static

Referenced by __pi_rtc_open().

volatile uint8_t g_rtc_pending
static