tm4c123_config.c 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. * Copyright (c) 2006-2021, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2020-06-27 AHTYDHD the first version
  9. */
  10. #include <rtthread.h>
  11. #include <stdbool.h>
  12. #include <stdint.h>
  13. #include "inc/hw_memmap.h"
  14. #include "driverlib/pin_map.h"
  15. #include "driverlib/sysctl.h"
  16. #include "driverlib/gpio.h"
  17. #include "tm4c123_config.h"
  18. #ifdef RT_USING_SERIAL
  19. #include "driverlib/uart.h"
  20. #endif /* RT_USING_SERIAL */
  21. #ifdef RT_USING_ADC
  22. #include "driverlib/adc.h"
  23. #endif /* RT_USING_ADC */
  24. #ifdef RT_USING_PWM
  25. #include "driverlib/pwm.h"
  26. #endif /* RT_USING_PWM */
  27. #ifdef RT_USING_SPI
  28. #include "driverlib/ssi.h"
  29. #endif /* RT_USING_SPI */
  30. #ifdef RT_USING_SERIAL
  31. void uart_hw_config(void)
  32. {
  33. /* UART0 */
  34. SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
  35. SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
  36. GPIOPinConfigure(GPIO_PA0_U0RX);
  37. GPIOPinConfigure(GPIO_PA1_U0TX);
  38. GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
  39. /* UART1 */
  40. SysCtlPeripheralEnable(SYSCTL_PERIPH_UART1);
  41. SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
  42. GPIOPinConfigure(GPIO_PC4_U1RX);
  43. GPIOPinConfigure(GPIO_PC5_U1TX);
  44. GPIOPinTypeUART(GPIO_PORTC_BASE, GPIO_PIN_4 | GPIO_PIN_5);
  45. }
  46. #endif /* RT_USING_SERIAL */
  47. #ifdef RT_USING_ADC
  48. void adc_hw_config(void)
  49. {
  50. /* ADC0 */
  51. SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
  52. SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
  53. GPIOPinTypeADC(GPIO_PORTD_BASE, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3);
  54. }
  55. #endif /* RT_USING_ADC */
  56. #ifdef RT_USING_PWM
  57. void pwm_hw_config(void)
  58. {
  59. /* PWM7 (PWM1 module,M1PWM6 and M1PWM7) */
  60. SysCtlPWMClockSet(SYSCTL_PWMDIV_2);
  61. SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM1);
  62. SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
  63. GPIOPinConfigure(GPIO_PF2_M1PWM6);
  64. GPIOPinConfigure(GPIO_PF3_M1PWM7);
  65. GPIOPinTypePWM(GPIO_PORTF_BASE, GPIO_PIN_2 | GPIO_PIN_3);
  66. }
  67. #endif /* RT_USING_PWM */
  68. #ifdef RT_USING_SPI
  69. void spi_hw_config(void)
  70. {
  71. /* SPI0 */
  72. SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI0);
  73. SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
  74. GPIOPinConfigure(GPIO_PA2_SSI0CLK);
  75. GPIOPinConfigure(GPIO_PA4_SSI0RX);
  76. GPIOPinConfigure(GPIO_PA5_SSI0TX);
  77. GPIOPinTypeSSI(GPIO_PORTA_BASE, GPIO_PIN_5 | GPIO_PIN_4 | GPIO_PIN_2);
  78. }
  79. #endif /* RT_USING_SPI */
  80. /************************** end of file ******************/