sx12xxEiger.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /*
  2. * THE FOLLOWING FIRMWARE IS PROVIDED: (1) "AS IS" WITH NO WARRANTY; AND
  3. * (2)TO ENABLE ACCESS TO CODING INFORMATION TO GUIDE AND FACILITATE CUSTOMER.
  4. * CONSEQUENTLY, SEMTECH SHALL NOT BE HELD LIABLE FOR ANY DIRECT, INDIRECT OR
  5. * CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT
  6. * OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION
  7. * CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
  8. *
  9. * Copyright (C) SEMTECH S.A.
  10. */
  11. /*!
  12. * \file sx12xxEiger.c
  13. * \brief
  14. *
  15. * \version 1.0
  16. * \date Nov 21 2012
  17. * \author Miguel Luis
  18. */
  19. #include <stdint.h>
  20. #include "spi.h"
  21. #include "i2c.h"
  22. #include "ioe.h"
  23. #include "led.h"
  24. #include "uart.h"
  25. #include "sx12xxEiger.h"
  26. //#if( defined( STM32F4XX ) || defined( STM32F2XX ) || defined( STM32F429_439xx ) )
  27. //
  28. //#include "usbd_cdc_core.h"
  29. //#include "usbd_usr.h"
  30. //#include "usbd_desc.h"
  31. //
  32. //#else
  33. //
  34. //#include "usb_regs.h"
  35. //#include "usb_core.h"
  36. //#include "usb_init.h"
  37. //#include "usb_pwr.h"
  38. //#include "usb_bsp.h"
  39. //#include "usb_sil.h"
  40. //
  41. //#endif
  42. // System tick (1ms)
  43. volatile uint32_t TickCounter = 0;
  44. //#if( defined( STM32F4XX ) || defined( STM32F2XX ) || defined( STM32F429_439xx ) )
  45. //
  46. //#ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED
  47. // #if defined ( __ICCARM__ ) /*!< IAR Compiler */
  48. // #pragma data_alignment=4
  49. // #endif
  50. //#endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */
  51. //
  52. //__ALIGN_BEGIN USB_OTG_CORE_HANDLE USB_OTG_dev __ALIGN_END ;
  53. //
  54. //#else
  55. //
  56. //#endif
  57. void BoardInit( void )
  58. {
  59. // uint8_t i;
  60. //
  61. // /* Setup SysTick Timer for 1 us interrupts ( not too often to save power ) */
  62. // if( SysTick_Config( SystemCoreClock / 1000 ) )
  63. // {
  64. // /* Capture error */
  65. // while (1);
  66. // }
  67. //
  68. // // Initialize SPI
  69. // SpiInit( );
  70. //
  71. // // Initialize I2C
  72. // I2cInit( );
  73. //
  74. // // Initialize IO expander
  75. // IoeInit( );
  76. //
  77. // // Initialize LED
  78. // for( i = 0; i < LED_NB; i++ )
  79. // {
  80. // LedInit( ( tLed )i );
  81. // }
  82. // IoePinOn( LED_1_PIN );
  83. // IoePinOn( LED_2_PIN );
  84. // IoePinOn( LED_3_PIN );
  85. //
  86. //#if( defined( STM32F4XX ) || defined( STM32F2XX ) || defined( STM32F429_439xx ) )
  87. //
  88. // USBD_Init( &USB_OTG_dev,
  89. //#ifdef USE_USB_OTG_HS
  90. // USB_OTG_HS_CORE_ID,
  91. //#else
  92. // USB_OTG_FS_CORE_ID,
  93. //#endif
  94. // &USR_desc,
  95. // &USBD_CDC_cb,
  96. // &USR_cb );
  97. //#else
  98. // /* Configure the used GPIOs*/
  99. // GPIO_Configuration( );
  100. // /* Additional EXTI configuration (configure both edges) */
  101. // EXTI_Configuration( );
  102. //
  103. // USB_Interrupts_Config( );
  104. // Set_USBClock( );
  105. // USB_Init( );
  106. //#endif
  107. }
  108. void Delay ( uint32_t delay )
  109. {
  110. // Wait delay ms
  111. uint32_t startTick = TickCounter;
  112. while( ( TickCounter - startTick ) < delay );
  113. }
  114. void LongDelay ( uint8_t delay )
  115. {
  116. uint32_t longDelay;
  117. uint32_t startTick;
  118. longDelay = delay * 1000;
  119. // Wait delay s
  120. startTick = TickCounter;
  121. while( ( TickCounter - startTick ) < longDelay );
  122. }