/** * @brief Low level HAL driver initialization. */ void hal_lld_init(void) { struct sigaction sigtick = { .sa_handler = port_tick_signal_handler, }; if (sigaction(PORT_TIMER_SIGNAL, &sigtick, NULL) < 0) port_halt(); const suseconds_t usecs = 1000000 / CH_FREQUENCY; struct itimerval itimer, oitimer; /* Initialize the structure with the current timer information. */ if (getitimer(PORT_TIMER_TYPE, &itimer) < 0) port_halt(); /* Set the interval between timer events. */ itimer.it_interval.tv_sec = usecs / 1000000; itimer.it_interval.tv_usec = usecs % 1000000; /* Set the current count-down. */ itimer.it_value.tv_sec = usecs / 1000000; itimer.it_value.tv_usec = usecs % 1000000; /* Set-up the timer interrupt. */ if (setitimer(PORT_TIMER_TYPE, &itimer, &oitimer) < 0) port_halt(); }
// called on I2C communication failures with the DAC uint32_t Codec_TIMEOUT_UserCallback(void) { port_halt(); return 0; }