Lines Matching refs:data

75 	struct mcp7940n_data *data = dev->data;  in decode_rtc()  local
79 time.tm_sec = RTC_BCD_DECODE(data->registers.rtc_sec.sec); in decode_rtc()
80 time.tm_min = RTC_BCD_DECODE(data->registers.rtc_min.min); in decode_rtc()
81 time.tm_hour = RTC_BCD_DECODE(data->registers.rtc_hours.hr); in decode_rtc()
82 time.tm_mday = RTC_BCD_DECODE(data->registers.rtc_date.date); in decode_rtc()
83 time.tm_wday = data->registers.rtc_weekday.weekday; in decode_rtc()
85 time.tm_mon = RTC_BCD_DECODE(data->registers.rtc_month.month) - 1; in decode_rtc()
87 time.tm_year = RTC_BCD_DECODE(data->registers.rtc_year.year) + in decode_rtc()
108 struct mcp7940n_data *data = dev->data; in encode_rtc() local
121 data->registers.rtc_sec.start_osc = 1; in encode_rtc()
123 data->registers.rtc_sec.sec_one = time_buffer->tm_sec % 10; in encode_rtc()
124 data->registers.rtc_sec.sec_ten = time_buffer->tm_sec / 10; in encode_rtc()
125 data->registers.rtc_min.min_one = time_buffer->tm_min % 10; in encode_rtc()
126 data->registers.rtc_min.min_ten = time_buffer->tm_min / 10; in encode_rtc()
127 data->registers.rtc_hours.hr_one = time_buffer->tm_hour % 10; in encode_rtc()
128 data->registers.rtc_hours.hr_ten = time_buffer->tm_hour / 10; in encode_rtc()
129 data->registers.rtc_weekday.weekday = time_buffer->tm_wday; in encode_rtc()
130 data->registers.rtc_date.date_one = time_buffer->tm_mday % 10; in encode_rtc()
131 data->registers.rtc_date.date_ten = time_buffer->tm_mday / 10; in encode_rtc()
132 data->registers.rtc_month.month_one = month % 10; in encode_rtc()
133 data->registers.rtc_month.month_ten = month / 10; in encode_rtc()
134 data->registers.rtc_year.year_one = year_since_epoch % 10; in encode_rtc()
135 data->registers.rtc_year.year_ten = year_since_epoch / 10; in encode_rtc()
152 struct mcp7940n_data *data = dev->data; in encode_alarm() local
157 alm_regs = &data->alm0_registers; in encode_alarm()
159 alm_regs = &data->alm1_registers; in encode_alarm()
211 struct mcp7940n_data *data = dev->data; in read_time() local
215 int rc = i2c_write_read_dt(&cfg->i2c, &addr, sizeof(addr), &data->registers, in read_time()
258 struct mcp7940n_data *data = dev->data; in write_data_block() local
273 write_block_start = (uint8_t *)&data->registers; in write_data_block()
275 write_block_start = (uint8_t *)&data->alm0_registers; in write_data_block()
277 write_block_start = (uint8_t *)&data->alm1_registers; in write_data_block()
305 struct mcp7940n_data *data = dev->data; in set_day_of_week() local
310 data->registers.rtc_weekday.weekday = time_buffer.tm_wday; in set_day_of_week()
312 *((uint8_t *)(&data->registers.rtc_weekday))); in set_day_of_week()
329 struct mcp7940n_data *data = dev->data; in mcp7940n_handle_interrupt() local
338 alm_regs = &data->alm0_registers; in mcp7940n_handle_interrupt()
341 alm_regs = &data->alm1_registers; in mcp7940n_handle_interrupt()
346 k_sem_take(&data->lock, K_FOREVER); in mcp7940n_handle_interrupt()
358 if (data->counter_handler[alarm_id]) { in mcp7940n_handle_interrupt()
359 cb = data->counter_handler[alarm_id]; in mcp7940n_handle_interrupt()
360 ticks = data->counter_ticks[alarm_id]; in mcp7940n_handle_interrupt()
365 k_sem_give(&data->lock); in mcp7940n_handle_interrupt()
368 cb(data->mcp7940n, 0, ticks, data->alarm_user_data[alarm_id]); in mcp7940n_handle_interrupt()
374 struct mcp7940n_data *data = in mcp7940n_work_handler() local
378 mcp7940n_handle_interrupt(data->mcp7940n, ALARM0_ID); in mcp7940n_work_handler()
379 mcp7940n_handle_interrupt(data->mcp7940n, ALARM1_ID); in mcp7940n_work_handler()
385 struct mcp7940n_data *data = in mcp7940n_init_cb() local
390 k_work_submit(&data->alarm_work); in mcp7940n_init_cb()
395 struct mcp7940n_data *data = dev->data; in mcp7940n_rtc_set_time() local
404 k_sem_take(&data->lock, K_FOREVER); in mcp7940n_rtc_set_time()
422 k_sem_give(&data->lock); in mcp7940n_rtc_set_time()
429 struct mcp7940n_data *data = dev->data; in mcp7940n_counter_start() local
432 k_sem_take(&data->lock, K_FOREVER); in mcp7940n_counter_start()
435 data->registers.rtc_sec.start_osc = 1; in mcp7940n_counter_start()
437 *((uint8_t *)(&data->registers.rtc_sec))); in mcp7940n_counter_start()
439 k_sem_give(&data->lock); in mcp7940n_counter_start()
446 struct mcp7940n_data *data = dev->data; in mcp7940n_counter_stop() local
449 k_sem_take(&data->lock, K_FOREVER); in mcp7940n_counter_stop()
452 data->registers.rtc_sec.start_osc = 0; in mcp7940n_counter_stop()
454 *((uint8_t *)(&data->registers.rtc_sec))); in mcp7940n_counter_stop()
456 k_sem_give(&data->lock); in mcp7940n_counter_stop()
464 struct mcp7940n_data *data = dev->data; in mcp7940n_counter_get_value() local
468 k_sem_take(&data->lock, K_FOREVER); in mcp7940n_counter_get_value()
478 k_sem_give(&data->lock); in mcp7940n_counter_get_value()
486 struct mcp7940n_data *data = dev->data; in mcp7940n_counter_set_alarm() local
495 k_sem_take(&data->lock, K_FOREVER); in mcp7940n_counter_set_alarm()
499 alm_regs = &data->alm0_registers; in mcp7940n_counter_set_alarm()
502 alm_regs = &data->alm1_registers; in mcp7940n_counter_set_alarm()
522 data->registers.rtc_control.alm0_en = 1; in mcp7940n_counter_set_alarm()
524 data->registers.rtc_control.alm1_en = 1; in mcp7940n_counter_set_alarm()
541 *((uint8_t *)(&data->registers.rtc_control))); in mcp7940n_counter_set_alarm()
547 data->counter_handler[alarm_id] = alarm_cfg->callback; in mcp7940n_counter_set_alarm()
548 data->counter_ticks[alarm_id] = current_time; in mcp7940n_counter_set_alarm()
549 data->alarm_user_data[alarm_id] = alarm_cfg->user_data; in mcp7940n_counter_set_alarm()
552 k_sem_give(&data->lock); in mcp7940n_counter_set_alarm()
559 struct mcp7940n_data *data = dev->data; in mcp7940n_counter_cancel_alarm() local
562 k_sem_take(&data->lock, K_FOREVER); in mcp7940n_counter_cancel_alarm()
566 data->registers.rtc_control.alm0_en = 0; in mcp7940n_counter_cancel_alarm()
568 data->registers.rtc_control.alm1_en = 0; in mcp7940n_counter_cancel_alarm()
575 *((uint8_t *)(&data->registers.rtc_control))); in mcp7940n_counter_cancel_alarm()
578 k_sem_give(&data->lock); in mcp7940n_counter_cancel_alarm()
599 struct mcp7940n_data *data = dev->data; in mcp7940n_counter_get_pending_int() local
603 k_sem_take(&data->lock, K_FOREVER); in mcp7940n_counter_get_pending_int()
607 (uint8_t *)&data->alm0_registers.alm_weekday); in mcp7940n_counter_get_pending_int()
612 if (data->alm0_registers.alm_weekday.alm_if) { in mcp7940n_counter_get_pending_int()
614 data->alm0_registers.alm_weekday.alm_if = 0; in mcp7940n_counter_get_pending_int()
616 *((uint8_t *)(&data->alm0_registers.alm_weekday))); in mcp7940n_counter_get_pending_int()
625 (uint8_t *)&data->alm1_registers.alm_weekday); in mcp7940n_counter_get_pending_int()
630 if (data->alm1_registers.alm_weekday.alm_if) { in mcp7940n_counter_get_pending_int()
632 data->alm1_registers.alm_weekday.alm_if = 0; in mcp7940n_counter_get_pending_int()
634 *((uint8_t *)(&data->alm1_registers.alm_weekday))); in mcp7940n_counter_get_pending_int()
642 k_sem_give(&data->lock); in mcp7940n_counter_get_pending_int()
657 struct mcp7940n_data *data = dev->data; in mcp7940n_init() local
663 k_sem_init(&data->lock, 0, 1); in mcp7940n_init()
682 data->registers.rtc_hours.twelve_hr = false; in mcp7940n_init()
684 *((uint8_t *)(&data->registers.rtc_hours))); in mcp7940n_init()
699 data->mcp7940n = dev; in mcp7940n_init()
700 k_work_init(&data->alarm_work, mcp7940n_work_handler); in mcp7940n_init()
707 gpio_init_callback(&data->int_callback, mcp7940n_init_cb, in mcp7940n_init()
710 gpio_add_callback(cfg->int_gpios.port, &data->int_callback); in mcp7940n_init()
714 data->int_active_high = false; in mcp7940n_init()
716 data->int_active_high = true; in mcp7940n_init()
718 data->alm0_registers.alm_weekday.alm_pol = data->int_active_high; in mcp7940n_init()
719 data->alm1_registers.alm_weekday.alm_pol = data->int_active_high; in mcp7940n_init()
721 *((uint8_t *)(&data->alm0_registers.alm_weekday))); in mcp7940n_init()
723 *((uint8_t *)(&data->alm1_registers.alm_weekday))); in mcp7940n_init()
726 k_sem_give(&data->lock); in mcp7940n_init()