static inline int ov2640_camera_initialize(void) { FAR struct i2c_dev_s *i2c; uint32_t actual; int ret; /* Get the I2C driver that interfaces with the camers (OV2640_BUS)*/ i2c = up_i2cinitialize(OV2640_BUS); if (!i2c) { gdbg("ERROR: Failed to initialize TWI%d\n", OV2640_BUS); return EXIT_FAILURE; } /* Enable clocking to the ISI peripheral */ sam_isi_enableclk(); /* Configure OV2640 pins * * ISI: * - HSYNC, VSYNC, PCK * - 8 data bits for 8-bit color * PCK * - PCK1 provides OV2640 system clock */ sam_configpio(PIO_ISI_HSYNC); sam_configpio(PIO_ISI_VSYNC); sam_configpio(PIO_ISI_PCK); sam_configpio(PIO_ISI_D0); sam_configpio(PIO_ISI_D1); sam_configpio(PIO_ISI_D2); sam_configpio(PIO_ISI_D3); sam_configpio(PIO_ISI_D4); sam_configpio(PIO_ISI_D5); sam_configpio(PIO_ISI_D6); sam_configpio(PIO_ISI_D7); sam_configpio(PIO_PMC_PCK1); /* Configure and enable the PCK1 output */ actual = sam_pck_configure(PCK1, OV2640_FREQUENCY); gvdbg("Desired PCK1 frequency: %ld Actual: %ld\n", (long)OV2640_FREQUENCY, (long)actual); sam_pck_enable(PCK1, true); /* Configure the ISI peripheral */ #warning Missing Logic /* Initialize the OV2640 camera */ ret = ov2640_initialize(i2c); if (ret < 0) { gdbg("ERROR: Failed to initialize the OV2640: %d\n", ret); return EXIT_FAILURE; } return EXIT_FAILURE; }
int sam_isi_initialize(void) { int ret; /* Configure PIO pins for the ISI (outputs) */ /* Data pins */ (void)sam_configpio(PIO_ISI_D0); (void)sam_configpio(PIO_ISI_D1); (void)sam_configpio(PIO_ISI_D2); (void)sam_configpio(PIO_ISI_D3); (void)sam_configpio(PIO_ISI_D4); (void)sam_configpio(PIO_ISI_D5); (void)sam_configpio(PIO_ISI_D6); (void)sam_configpio(PIO_ISI_D7); (void)sam_configpio(PIO_ISI_D8); (void)sam_configpio(PIO_ISI_D9); (void)sam_configpio(PIO_ISI_D10); (void)sam_configpio(PIO_ISI_D11); /* Horizontal and vertical sync pins (inputs) */ (void)sam_configpio(PIO_ISI_HSYNC); (void)sam_configpio(PIO_ISI_VSYNC); /* Pixel clock input (ISI_PCK, not to be confused with the processor clock * (PCK) or the programmable clock (PCK). * * NOTE: "Several parts of the ISI controller use the pixel clock provided * by the image sensor (ISI_PCK). Thus the user must first program the * image sensor to provide this clock (ISI_PCK) before programming the * Image Sensor Controller." */ (void)sam_configpio(PIO_ISI_PCK); /* Configure ISI_MCK programmable clock output. * * REVISIT: Might this not be needed before the image sensor is * initialized? */ g_isi.actual = sam_pck_configure(ISI_PCKID, PCKSRC_MCK, CONFIG_ISI_MCKFREQ); ginfo("PCK%d frequency=%d actual=%d\n", ISI_PCKID, CONFIG_ISI_MCKFREQ, g_isi.actual); /* Enable the MCK (output) */ sam_pck_enable(ISI_PCKID, true); /* Configure the pixel clock */ #warning Missing logic /* Configure color */ #warning Missing logic /* Configure decimation */ #warning Missing logic /* Configure DMA */ #warning Missing logic }
void sam_boardinitialize(void) { #ifdef CONFIG_SCHED_TICKLESS uint32_t frequency; uint32_t actual; /* If Tickless mode is selected then enabled PCK6 as a possible clock * source for the timer/counters. The ideal frequency could be: * * frequency = 1,000,000 / CONFIG_USEC_PER_TICK * * The main crystal is selected as the frequency source. The maximum * prescaler value is 256 so the minimum frequency is 46,875 Hz which * corresponds to a period of 21.3 microseconds. A value of * CONFIG_USEC_PER_TICK=20, or 50KHz, would give an exact solution with * a divider of 240. */ frequency = USEC_PER_SEC / CONFIG_USEC_PER_TICK; DEBUGASSERT(frequency >= (BOARD_MAINOSC_FREQUENCY / 256)); actual = sam_pck_configure(PCK6, PCKSRC_MAINCK, frequency); /* We expect to achieve this frequency exactly */ DEBUGASSERT(actual == frequency); UNUSED(actual); /* Enable PCK6 */ (void)sam_pck_enable(PCK6, true); #endif #ifdef CONFIG_SAMV7_SDRAMC /* Configure SDRAM if it has been enabled in the NuttX configuration. * Here we assume, of course, that we are not running out SDRAM. */ sam_sdram_config(); #endif #ifdef CONFIG_SAMV7_SPI /* Configure SPI chip selects if SPI has been enabled */ sam_spidev_initialize(); #endif #ifdef HAVE_USB /* Setup USB-related GPIO pins for the SAME70-XPLD board. */ sam_usbinitialize(); #endif #ifdef HAVE_NETWORK /* Configure board resources to support networking if the 1) networking is * enabled, and 2) the EMAC module is enabled */ sam_netinitialize(); #endif /* Configure on-board LEDs if LED support has been selected. */ #ifdef CONFIG_ARCH_LEDS board_autoled_initialize(); #endif }
__END_DECLS /**************************************************************************** * Protected Functions ****************************************************************************/ /**************************************************************************** * Public Functions ****************************************************************************/ /************************************************************************************ * Name: sam_boardinitialize * * Description: * All SAMV7 architectures must provide the following entry point. This * entry point is called early in the initialization -- after clocking and * memory have been configured but before caches have been enabled and * before any devices have been initialized. * ************************************************************************************/ __EXPORT void sam_boardinitialize(void) { #ifdef CONFIG_SCHED_TICKLESS uint32_t frequency; uint32_t actual; /* If Tickless mode is selected then enabled PCK6 as a possible clock * source for the timer/counters. The ideal frequency could be: * * frequency = 1,000,000 / CONFIG_USEC_PER_TICK * * The main crystal is selected as the frequency source. The maximum * prescaler value is 256 so the minimum frequency is 46,875 Hz which * corresponds to a period of 21.3 microseconds. A value of * CONFIG_USEC_PER_TICK=20, or 50KHz, would give an exact solution with * a divider of 240. */ frequency = USEC_PER_SEC / CONFIG_USEC_PER_TICK; DEBUGASSERT(frequency >= (BOARD_MAINOSC_FREQUENCY / 256)); actual = sam_pck_configure(PCK6, PCKSRC_MAINCK, frequency); /* We expect to achieve this frequency exactly */ DEBUGASSERT(actual == frequency); UNUSED(actual); /* Enable PCK6 */ (void)sam_pck_enable(PCK6, true); #endif /* Lets bring the clock out for a sanity check*/ #ifdef GPIO_PCK1 sam_configgpio(GPIO_PCK1); volatile uint32_t actual = sam_pck_configure(PCK1, PCKSRC_MCK, BOARD_MCK_FREQUENCY / 2); // Out 1/2 Clock UNUSED(actual); (void)sam_pck_enable(PCK1, true); #endif #ifdef CONFIG_SAMV7_SDRAMC /* Configure SDRAM if it has been enabled in the NuttX configuration. * Here we assume, of course, that we are not running out SDRAM. */ sam_sdram_config(); #endif #ifdef CONFIG_SAMV7_SPI /* configure SPI interfaces */ board_spi_initialize(); #endif #ifdef CONFIG_ARCH_LEDS /* configure LEDs */ board_autoled_initialize(); #endif }