Advertisement
Guest User

main.c

a guest
Jul 18th, 2023
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 4.65 KB | Software | 0 0
  1. /*******************************************************************************
  2. **                                  Includes                                  **
  3. *******************************************************************************/
  4.  
  5. #include "tle_device.h"
  6. #include "types.h"
  7. #include "stdint.h"
  8. #include "gpio.h"
  9. #include "ssc.h"
  10. #include "gpt12.h"
  11. #include "dma.h"
  12. #include "scu.h"
  13.  
  14. /*******************************************************************************
  15. **                                SSC Defines                                 **
  16. *******************************************************************************/
  17.  
  18. #define SSC_Read_Word()           ((uint16_t)SSC0_getRXvalue() & 0xFFFF)
  19. #define SSC_Send_Word(Word)       (SSC0_setTXvalue((uint64_t)Word))
  20. #define SSC_Chip_Select_Down()    (GPIO_setP12State(GPIO_STATE_LOW))
  21. #define SSC_Chip_Select_Up()      (GPIO_setP12State(GPIO_STATE_HIGH))
  22. #define SSC_Clear_TIR()           (SSC0->ISC.bit.TIRCLR = 1u)
  23. #define SSC_Clear_RIR()           (SSC0->ISC.bit.RIRCLR = 1u)
  24. #define Enable_MTSR_Open_Drain()  (GPIO->P0_OD.bit.OD1 = 1)
  25. #define Disable_MTSR_Open_Drain() (GPIO->P0_OD.bit.OD1 = 0)
  26.  
  27. /*******************************************************************************
  28. **                                DMA Defines                                 **
  29. *******************************************************************************/
  30.  
  31. #define DMA_Enable_Master()       (DMA_enMaster())
  32. #define DMA_Disable_Master()      (DMA->DMA_CFG.bit.MASTER_ENABLE = 0u)
  33.  
  34. /*******************************************************************************
  35. **                        Global Constant Declarations                        **
  36. *******************************************************************************/
  37.  
  38. uint16_t DMA_TX_Buffer[4] = {0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF};
  39. uint16_t DMA_RX_Buffer[4] = {0x0000, 0x0000, 0x0000, 0x0000};
  40.  
  41. /*******************************************************************************
  42. **                          Global Type Declarations                          **
  43. *******************************************************************************/
  44.  
  45. /*******************************************************************************
  46. **                          Global Macro Declarations                         **
  47. *******************************************************************************/
  48.  
  49. /*******************************************************************************
  50. **                        Global Function Declarations                        **
  51. *******************************************************************************/
  52. void SendReadAngleCommand(void)
  53. {
  54.   DMA_resetChannel(0, 3);
  55.   DMA_resetChannel(1, 4);
  56.   SSC_Chip_Select_Down();
  57.   Disable_MTSR_Open_Drain();
  58.   SSC_Send_Word(0x8022);
  59.   SCU_delay_us(2);
  60.   Enable_MTSR_Open_Drain();
  61.   DMA_Enable_Master();
  62.   SCU_delay_us(10);
  63.   SSC_Chip_Select_Up();
  64.   DMA_Disable_Master();
  65.   SSC_Clear_TIR();
  66.   SSC_Clear_RIR();
  67. }
  68. /*******************************************************************************
  69. **                     Global Inline Function Definitions                     **
  70. *******************************************************************************/
  71.  
  72. sint32 main(void)
  73. {
  74.   sint8 s8_returnCode;
  75.  
  76.   /* Clear watchdog fail status */
  77.   PMU_clrFailSafeWatchdogFailSts();
  78.  
  79.   /* Initialization of hardware modules based on Config Wizard configuration */
  80.   s8_returnCode = TLE_init();
  81.  
  82.   if (s8_returnCode != ERR_LOG_SUCCESS)
  83.   {
  84.     /* Place your code here to handle an initialization error */
  85.   }
  86.  
  87.   /*****************************************************************************
  88.   ** Place your application code here                                         **
  89.   *****************************************************************************/
  90. //  DMA_setBasicTransfer(0, (uint32)&DMA_TX_Buffer[0], (uint32)&SSC0->TB0.reg, 3, DMA_transferSize_16bit, 0);
  91. //  DMA_setBasicTransfer(1, (uint32)&SSC0->RB0.reg, (uint32)&DMA_RX_Buffer[0], 4, DMA_transferSize_16bit, 1);
  92.  
  93.   GPT12_startT3();
  94.  
  95.   /*****************************************************************************
  96.   ** Main endless loop                                                        **
  97.   *****************************************************************************/
  98.   for (;;)
  99.   {
  100.     /* Main watchdog service */
  101.     (void)PMU_serviceFailSafeWatchdog();
  102.    
  103.     /***************************************************************************
  104.     ** Place your application code here                                       **
  105.     ***************************************************************************/
  106.  
  107.    
  108.   }
  109. }
  110.  
  111.  
  112.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement