board.c 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * Copyright (c) 2006-2022, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2020-08-20 Abbcc first version
  9. */
  10. #include "board.h"
  11. void apm32_usart_init(void)
  12. {
  13. GPIO_Config_T GPIO_ConfigStruct;
  14. #ifdef BSP_USING_UART1
  15. RCM_EnableAPB2PeriphClock((RCM_APB2_PERIPH_T)(RCM_APB2_PERIPH_GPIOA | RCM_APB2_PERIPH_USART1));
  16. GPIO_ConfigStruct.mode = GPIO_MODE_AF_PP;
  17. GPIO_ConfigStruct.pin = GPIO_PIN_9;
  18. GPIO_ConfigStruct.speed = GPIO_SPEED_50MHz;
  19. GPIO_Config(GPIOA, &GPIO_ConfigStruct);
  20. GPIO_ConfigStruct.mode = GPIO_MODE_IN_PU;
  21. GPIO_ConfigStruct.pin = GPIO_PIN_10;
  22. GPIO_ConfigStruct.speed = GPIO_SPEED_50MHz;
  23. GPIO_Config(GPIOA, &GPIO_ConfigStruct);
  24. #endif
  25. #ifdef BSP_USING_UART2
  26. RCM_EnableAPB2PeriphClock(RCM_APB2_PERIPH_GPIOA);
  27. RCM_EnableAPB1PeriphClock(RCM_APB1_PERIPH_USART2);
  28. GPIO_ConfigStruct.mode = GPIO_MODE_AF_PP;
  29. GPIO_ConfigStruct.pin = GPIO_PIN_2;
  30. GPIO_ConfigStruct.speed = GPIO_SPEED_50MHz;
  31. GPIO_Config(GPIOA, &GPIO_ConfigStruct);
  32. GPIO_ConfigStruct.mode = GPIO_MODE_IN_PU;
  33. GPIO_ConfigStruct.pin = GPIO_PIN_3;
  34. GPIO_ConfigStruct.speed = GPIO_SPEED_50MHz;
  35. GPIO_Config(GPIOA, &GPIO_ConfigStruct);
  36. #endif
  37. }
  38. void apm32_msp_sdio_init(void *Instance)
  39. {
  40. GPIO_Config_T GPIO_InitStructure;
  41. /* Enable the GPIO and DMA2 Clock */
  42. RCM_EnableAPB2PeriphClock(RCM_APB2_PERIPH_GPIOC | RCM_APB2_PERIPH_GPIOD);
  43. /* Enable the SDIO Clock */
  44. RCM_EnableAHBPeriphClock(RCM_AHB_PERIPH_SDIO);
  45. /* Configure the GPIO pin */
  46. GPIO_InitStructure.pin = GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12;
  47. GPIO_InitStructure.mode = GPIO_MODE_AF_PP;
  48. GPIO_InitStructure.speed = GPIO_SPEED_50MHz;
  49. GPIO_Config(GPIOC, &GPIO_InitStructure);
  50. GPIO_InitStructure.pin = GPIO_PIN_2;
  51. GPIO_Config(GPIOD, &GPIO_InitStructure);
  52. }