board.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. #include <rtthread.h>
  2. #include <rthw.h>
  3. #include "gd_int.h"
  4. #include "gd_gpio.h"
  5. #include "gd_timer.h"
  6. #include "drv_uart.h"
  7. #include "gpio_cfg.h"
  8. #include "board.h"
  9. #include "drv_flash.h"
  10. #include "gh_debug_rct.h"
  11. #ifdef RT_USING_I2C
  12. #include "drv_i2c.h"
  13. #endif
  14. #ifdef RT_USING_SPI
  15. #include "drv_ssi.h"
  16. #endif
  17. #ifdef RT_USING_WDT
  18. #include "drv_wdt.h"
  19. #endif
  20. #ifdef RT_USING_GK_DMA
  21. #include "drv_dma.h"
  22. #endif
  23. #ifdef RT_USING_ADC
  24. #include "drv_adc.h"
  25. #endif
  26. #ifdef RT_USING_PWM
  27. #include "drv_pwm.h"
  28. #endif
  29. #include "rtos_lib.h"
  30. extern unsigned char __heap_start__[];
  31. extern unsigned char __heap_end__[];
  32. extern unsigned char __nocache_buffer_start__[];
  33. /**
  34. * This function will init goke board
  35. */
  36. void rt_hw_board_init(void)
  37. {
  38. rt_uint32_t code_seg_size = 0;
  39. rt_uint32_t heap_seg_size = 0;
  40. rt_uint32_t os_end_address=0;
  41. GD_TIMER_INIT_PARAMS_S gdTimerParams;
  42. GD_GPIO_XREF_S gdGpioXrefTable[] = { SYSTEM_GPIO_XREF_TABLE };
  43. GD_GPIO_INIT_PARAMS_S gdGpioInitParam =
  44. {
  45. .irqPriority = GD_INT_MID_PRIORITY,
  46. .phyType = 0,
  47. .xrefTableCount = sizeof(gdGpioXrefTable)/sizeof(gdGpioXrefTable[0]),
  48. .xrefTable = gdGpioXrefTable,
  49. };
  50. gdTimerParams.softTimerReg = GD_REG_TIMER1;
  51. gdTimerParams.hardTimerReg = GD_REG_TIMER2;
  52. gdTimerParams.gpregTimerReg = GD_REG_TIMER3;
  53. gdTimerParams.softTimerpriority = GD_INT_MID_PRIORITY;
  54. gdTimerParams.hardTimerpriority = GD_INT_MID_PRIORITY;
  55. gdTimerParams.gpregTimerpriority = GD_INT_MID_PRIORITY;
  56. GD_INT_DisableAllInterrupts();
  57. // Sensor ioctrl
  58. GH_PLL_set_IOCTRL_SENSOR(0x00000012);
  59. GD_INT_Init(NULL);
  60. GD_TIMER_Init(&gdTimerParams);
  61. GD_GPIO_Init(&gdGpioInitParam);
  62. /* initialize hardware interrupt */
  63. rt_hw_interrupt_init();
  64. /* initialize heap memory system */
  65. code_seg_size = __heap_end__ - __nocache_buffer_start__;
  66. heap_seg_size = DDR_MEMORY_OS_SIZE - code_seg_size;
  67. os_end_address= (rt_uint32_t)__heap_end__+heap_seg_size;
  68. rt_system_heap_init((void*)__heap_end__, (void*)os_end_address);
  69. /* initialize uart */
  70. rt_hw_uart_init();
  71. rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
  72. /* initalize sflash */
  73. rt_flash_init();
  74. RTOS_HwTickInit();
  75. }
  76. int rt_board_driver_init(void)
  77. {
  78. #ifdef RT_USING_I2C
  79. rt_hw_i2c_init();
  80. #endif
  81. #ifdef RT_USING_SPI
  82. rt_hw_spi_init();
  83. #endif
  84. #ifdef RT_USING_WDT
  85. rt_hw_wdt_init();
  86. #endif
  87. #ifdef RT_USING_GK_DMA
  88. rt_gk_dma_init();
  89. #endif
  90. #ifdef RT_USING_ADC
  91. rt_hw_adc_init();
  92. #endif
  93. #ifdef RT_USING_PWM
  94. rt_hw_pwm_init();
  95. #endif
  96. return 0;
  97. }
  98. //static unsigned long nticks = 0;
  99. unsigned long gkosGetTicks(void)
  100. {
  101. return rt_tick_get();
  102. }
  103. /*@}*/