/** * Callback to initialize an adc_dev structure from the os device * initialization callback. This sets up a stm32f4_adc_device(), so * that subsequent lookups to this device allow us to manipulate it. * * @param1 os device ptr * @param2 stm32f4 ADC device cfg ptr * @return OS_OK on success */ int stm32f4_adc_dev_init(struct os_dev *odev, void *arg) { struct stm32f4_adc_dev_cfg *sac; struct adc_dev *dev; struct adc_driver_funcs *af; sac = (struct stm32f4_adc_dev_cfg *) arg; assert(sac != NULL); dev = (struct adc_dev *)odev; os_mutex_init(&dev->ad_lock); dev->ad_chans = (void *) sac->sac_chans; dev->ad_chan_count = sac->sac_chan_count; OS_DEV_SETHANDLERS(odev, stm32f4_adc_open, stm32f4_adc_close); af = &dev->ad_funcs; af->af_configure_channel = stm32f4_adc_configure_channel; af->af_sample = stm32f4_adc_sample; af->af_read_channel = stm32f4_adc_read_channel; af->af_set_buffer = stm32f4_adc_set_buffer; af->af_release_buffer = stm32f4_adc_release_buffer; af->af_read_buffer = stm32f4_adc_read_buffer; af->af_size_buffer = stm32f4_adc_size_buffer; return (OS_OK); }
/** * Callback to initialize an adc_dev structure from the os device * initialization callback. This sets up a nrf52_adc_device(), so * that subsequent lookups to this device allow us to manipulate it. */ int nrf52_adc_dev_init(struct os_dev *odev, void *arg) { struct adc_dev *dev; struct adc_driver_funcs *af; dev = (struct adc_dev *) odev; os_mutex_init(&dev->ad_lock); dev->ad_chans = (void *) nrf52_adc_chans; dev->ad_chan_count = NRF_SAADC_CHANNEL_COUNT; OS_DEV_SETHANDLERS(odev, nrf52_adc_open, nrf52_adc_close); assert(init_adc_config == NULL || init_adc_config == arg); init_adc_config = arg; af = &dev->ad_funcs; af->af_configure_channel = nrf52_adc_configure_channel; af->af_sample = nrf52_adc_sample; af->af_read_channel = nrf52_adc_read_channel; af->af_set_buffer = nrf52_adc_set_buffer; af->af_release_buffer = nrf52_adc_release_buffer; af->af_read_buffer = nrf52_adc_read_buffer; af->af_size_buffer = nrf52_adc_size_buffer; NVIC_SetVector(SAADC_IRQn, (uint32_t) nrfx_saadc_irq_handler); return (0); }
/** * tlc5971 init * * @param odev * @param arg * * @return int */ int tlc5971_init(struct os_dev *odev, void *arg) { struct tlc5971_dev *dev; struct tlc5971_periph_itf *itf; dev = (struct tlc5971_dev *)odev; itf = (struct tlc5971_periph_itf *)arg; /* Copy the interface */ memcpy(&dev->tlc_itf, itf, sizeof(struct tlc5971_periph_itf)); /* * Set up a default config. This is the following: * - Unblanks the leds * - Enable auto repeat * - Enable timing reset * - Use internal clock for PWM * - Set GS reference clock edge to rising */ dev->control_data = TLC5971_DSPRPT_MASK | TLC5971_TMGRST_MASK | TLC5971_OUTTMG_MASK; /* Set the device open and close handlers */ OS_DEV_SETHANDLERS(odev, tlc5971_open, tlc5971_close); return 0; }
int nrf52_trng_dev_init(struct os_dev *dev, void *arg) { struct trng_dev *trng; trng = (struct trng_dev *)dev; assert(trng); OS_DEV_SETHANDLERS(dev, nrf52_trng_dev_open, NULL); trng->interface.get_u32 = nrf52_trng_get_u32; trng->interface.read = nrf52_trng_read; return 0; }