代码改变世界

SAMS70XXX PIO 学习

2021-08-09 19:08  dreamboy2000  阅读(441)  评论(0编辑  收藏  举报

1、uint32_t pio_configure_pin(uint32_t ul_pin, const uint32_t ul_flags)  // 配置 I/O 参数 

     \sam\drivers\pio\pio.h

  \common\services\serial\sam_uart\uart_serial.h

  \sam\utils\cmsis\sams70\include\component\usart.h

 common\components\touch\mxt\example_usart\same70q21_same70_xplained\conf_uart_serial.h

sam\utils\cmsis\same70\include\same70q21.h

#define PIO_IMR_P0 (0x1u << 0) /**< \brief (PIO_IMR) Input Change Interrupt Mask */

/********************************************************************************************************/

sam\boards\same70_xplained\init.c  

#ifdef CONF_BOARD_ILI9488
/**LCD pin configure on EBI*/
pio_configure(PIN_EBI_RESET_PIO, PIN_EBI_RESET_TYPE, PIN_EBI_RESET_MASK, PIN_EBI_RESET_ATTRI);
pio_configure(PIN_EBI_CDS_PIO, PIN_EBI_CDS_TYPE, PIN_EBI_CDS_MASK, PIN_EBI_CDS_ATTRI);
pio_configure(PIN_EBI_DATAL_PIO, PIN_EBI_DATAL_TYPE, PIN_EBI_DATAL_MASK, PIN_EBI_DATAL_ATTRI);
pio_configure(PIN_EBI_DATAH_0_PIO, PIN_EBI_DATAH_0_TYPE, PIN_EBI_DATAH_0_MASK, PIN_EBI_DATAH_0_ATTRI);
pio_configure(PIN_EBI_DATAH_1_PIO, PIN_EBI_DATAH_1_TYPE, PIN_EBI_DATAH_1_MASK, PIN_EBI_DATAH_1_ATTRI);
pio_configure(PIN_EBI_NWE_PIO, PIN_EBI_NWE_TYPE, PIN_EBI_NWE_MASK, PIN_EBI_NWE_ATTRI);
pio_configure(PIN_EBI_NRD_PIO, PIN_EBI_NRD_TYPE, PIN_EBI_NRD_MASK, PIN_EBI_NRD_ATTRI);
pio_configure(PIN_EBI_CS_PIO, PIN_EBI_CS_TYPE, PIN_EBI_CS_MASK, PIN_EBI_CS_ATTRI);
pio_configure(PIN_EBI_BACKLIGHT_PIO, PIN_EBI_BACKLIGHT_TYPE, PIN_EBI_BACKLIGHT_MASK, PIN_EBI_BACKLIGHT_ATTRI);
pio_set(PIN_EBI_BACKLIGHT_PIO, PIN_EBI_BACKLIGHT_MASK);
#endif

/********************************************************************************************************/

E:\xdk-asf-3.50.0\sam\boards\same70_xplained\same70_xplained.h

spi 相关驱动 

#ifdef CONF_BOARD_ILI9488
/**LCD pin configure on SPI*/
pio_configure_pin(LCD_SPI_MISO_PIO, LCD_SPI_MISO_FLAGS);
pio_configure_pin(LCD_SPI_MOSI_PIO, LCD_SPI_MOSI_FLAGS);
pio_configure_pin(LCD_SPI_SPCK_PIO, LCD_SPI_SPCK_FLAGS);
pio_configure_pin(LCD_SPI_NPCS_PIO, LCD_SPI_NPCS_FLAGS);
pio_configure_pin(LCD_SPI_RESET_PIO, LCD_SPI_RESET_FLAGS);
pio_configure_pin(LCD_SPI_CDS_PIO, LCD_SPI_CDS_FLAGS);
pio_configure_pin(LCD_SPI_BACKLIGHT_PIO, LCD_SPI_BACKLIGHT_FLAGS);
pio_set_pin_high(LCD_SPI_BACKLIGHT_PIO);

#endif

 \common\services\spi\sam_spi\spi_master.c

AFEC(ADC相关驱动)

\xdk-asf-3.50.0\sam\drivers\acc\acc_example\acc_example_canopus.c

case 'V':
/* Start conversion */
afec_start_software_conversion(AFEC0);
ul_status = afec_get_interrupt_status(AFEC0);
while ((ul_status & AFEC_ISR_EOC0) != AFEC_ISR_EOC0) {
ul_status = afec_get_interrupt_status(AFEC0);
}
/* Conversion is done */

ul_value = afec_channel_get_value(AFEC0, AFEC_CHANNEL_POTENTIOMETER);

// 系统TICK

sysclk_get_cpu_hz()

/* Setup SysTick Timer for 1 msec interrupts */
if (SysTick_Config(sysclk_get_cpu_hz() / 1000)) {
while (1) { /* Capture error */
}
}

// 定时器