Code: Select all
static const ICUConfig icumyconfig = {
ICU_INPUT_ACTIVE_HIGH,
100,
myicucb,
icuperiodcb,
NULL,
ICU_CHANNEL_1,
0
};
icucnt_t width;
static void myicucb(ICUDriver *icup) {
width = icuGetWidth(icup);
print_number(width,&SD1);
}
icucnt_t last_period;
static void icuperiodcb(ICUDriver *icup) {
last_period = icuGetPeriod(icup);
}
int main(void) {
/*
* System initializations.
* - HAL initialization, this also initializes the configured device drivers
* and performs the board-specific initializations.
* - Kernel initialization, the main() function becomes a thread and the
* RTOS is active.
*/
halInit();
chSysInit();
/*
* Activates the serial driver 1 using the driver default configuration.
*/
sdStart(&SD1, NULL);
palSetPadMode(GPIOB, PAL_PORT_BIT(6), PAL_MODE_STM32_ALTERNATE_PUSHPULL);
icuStart(&ICUD4, &icumyconfig);
icuEnable(&ICUD4);
}