june9152 пре 6 година
родитељ
комит
9e48c9954a
49 измењених фајлова са 8662 додато и 11127 уклоњено
  1. 51 48
      .cproject
  2. 2 2
      .mxproject
  3. 3 0
      .settings/com.atollic.truestudio.tsp.prefs
  4. BIN
      Debug/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_i2c.o
  5. 57 0
      Debug/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_i2c.su
  6. BIN
      Debug/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_spi.o
  7. 55 0
      Debug/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_spi.su
  8. BIN
      Debug/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_spi_ex.o
  9. 1 0
      Debug/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_spi_ex.su
  10. BIN
      Debug/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim.o
  11. BIN
      Debug/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim_ex.o
  12. BIN
      Debug/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_uart.o
  13. BIN
      Debug/STM32F103_RGB_Controller.bin
  14. BIN
      Debug/STM32F103_RGB_Controller.binary
  15. BIN
      Debug/STM32F103_RGB_Controller.elf
  16. 822 912
      Debug/STM32F103_RGB_Controller.hex
  17. 5767 5150
      Debug/STM32F103_RGB_Controller.list
  18. 724 722
      Debug/STM32F103_RGB_Controller.map
  19. BIN
      Debug/Src/GPIO_SPI.o
  20. 7 0
      Debug/Src/GPIO_SPI.su
  21. BIN
      Debug/Src/RGB_Controller.o
  22. 4 3
      Debug/Src/RGB_Controller.su
  23. BIN
      Debug/Src/RGB_Lora.o
  24. 0 0
      Debug/Src/RGB_Lora.su
  25. BIN
      Debug/Src/SX1276.o
  26. 30 0
      Debug/Src/SX1276.su
  27. BIN
      Debug/Src/Uart.o
  28. 9 0
      Debug/Src/Uart.su
  29. BIN
      Debug/Src/main.o
  30. 11 15
      Debug/Src/main.su
  31. BIN
      Debug/Src/stm32f1xx_hal_msp.o
  32. 6 4
      Debug/Src/stm32f1xx_hal_msp.su
  33. BIN
      Debug/Src/stm32f1xx_it.o
  34. 12 13
      Debug/Src/stm32f1xx_it.su
  35. BIN
      Debug/Src/system_stm32f1xx.o
  36. 0 587
      Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_spi.h
  37. 0 3264
      Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_spi.c
  38. 0 231
      Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_spi_ex.c
  39. 12 0
      Inc/GPIO_SPI.h
  40. 302 0
      Inc/SX1276.h
  41. 1 0
      Inc/Uart.h
  42. 9 0
      Inc/main.h
  43. 1 1
      Inc/stm32f1xx_hal_conf.h
  44. 18 21
      STM32F103_RGBController.ioc
  45. 298 0
      Src/GPIO_SPI.c
  46. 371 0
      Src/SX1276.c
  47. 4 3
      Src/Uart.c
  48. 85 66
      Src/main.c
  49. 0 85
      Src/stm32f1xx_hal_msp.c

Разлика између датотеке није приказан због своје велике величине
+ 51 - 48
.cproject


Разлика између датотеке није приказан због своје велике величине
+ 2 - 2
.mxproject


+ 3 - 0
.settings/com.atollic.truestudio.tsp.prefs

@@ -0,0 +1,3 @@
1
+eclipse.preferences.version=1
2
+svd_custom_file_path=
3
+svd_file_path=C\:\\Program Files (x86)\\Atollic\\TrueSTUDIO for STM32 9.3.0\\ide\\plugins\\com.atollic.truestudio.tsp.stm32_1.0.0.20190212-0734\\tsp\\sfr\\STM32F103.svd

BIN
Debug/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_i2c.o


+ 57 - 0
Debug/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_i2c.su

@@ -0,0 +1,57 @@
1
+stm32f1xx_hal_i2c.c:5556:26:I2C_IsAcknowledgeFailed	0	static
2
+stm32f1xx_hal_i2c.c:5358:26:I2C_WaitOnMasterAddressFlagUntilTimeout	32	static
3
+stm32f1xx_hal_i2c.c:5324:26:I2C_WaitOnFlagUntilTimeout	32	static
4
+stm32f1xx_hal_i2c.c:5406:26:I2C_WaitOnTXEFlagUntilTimeout	16	static
5
+stm32f1xx_hal_i2c.c:4970:26:I2C_RequestMemoryWrite	40	static
6
+stm32f1xx_hal_i2c.c:5061:26:I2C_RequestMemoryRead	40	static
7
+stm32f1xx_hal_i2c.c:5514:26:I2C_WaitOnRXNEFlagUntilTimeout	16	static
8
+stm32f1xx_hal_i2c.c:5443:26:I2C_WaitOnBTFFlagUntilTimeout	16	static
9
+stm32f1xx_hal_i2c.c:493:14:HAL_I2C_MspInit	0	static
10
+stm32f1xx_hal_i2c.c:369:19:HAL_I2C_Init	16	static
11
+stm32f1xx_hal_i2c.c:508:14:HAL_I2C_MspDeInit	0	static
12
+stm32f1xx_hal_i2c.c:457:19:HAL_I2C_DeInit	8	static
13
+stm32f1xx_hal_i2c.c:596:19:HAL_I2C_Master_Transmit	40	static
14
+stm32f1xx_hal_i2c.c:728:19:HAL_I2C_Master_Receive	64	static
15
+stm32f1xx_hal_i2c.c:987:19:HAL_I2C_Slave_Transmit	40	static
16
+stm32f1xx_hal_i2c.c:1116:19:HAL_I2C_Slave_Receive	40	static
17
+stm32f1xx_hal_i2c.c:1243:19:HAL_I2C_Master_Transmit_IT	24	static
18
+stm32f1xx_hal_i2c.c:1320:19:HAL_I2C_Master_Receive_IT	24	static
19
+stm32f1xx_hal_i2c.c:1403:19:HAL_I2C_Master_Sequential_Transmit_IT	24	static
20
+stm32f1xx_hal_i2c.c:1506:19:HAL_I2C_Master_Sequential_Receive_IT	24	static
21
+stm32f1xx_hal_i2c.c:1607:19:HAL_I2C_Slave_Transmit_IT	16	static
22
+stm32f1xx_hal_i2c.c:1687:19:HAL_I2C_Slave_Receive_IT	16	static
23
+stm32f1xx_hal_i2c.c:1769:19:HAL_I2C_Slave_Sequential_Transmit_IT	24	static
24
+stm32f1xx_hal_i2c.c:1835:19:HAL_I2C_Slave_Sequential_Receive_IT	24	static
25
+stm32f1xx_hal_i2c.c:1897:19:HAL_I2C_EnableListen_IT	0	static
26
+stm32f1xx_hal_i2c.c:1930:19:HAL_I2C_DisableListen_IT	0	static
27
+stm32f1xx_hal_i2c.c:1967:19:HAL_I2C_Master_Transmit_DMA	24	static
28
+stm32f1xx_hal_i2c.c:2085:19:HAL_I2C_Master_Receive_DMA	24	static
29
+stm32f1xx_hal_i2c.c:2251:19:HAL_I2C_Slave_Transmit_DMA	24	static
30
+stm32f1xx_hal_i2c.c:2346:19:HAL_I2C_Slave_Receive_DMA	24	static
31
+stm32f1xx_hal_i2c.c:2445:19:HAL_I2C_Mem_Write	40	static
32
+stm32f1xx_hal_i2c.c:2579:19:HAL_I2C_Mem_Read	56	static
33
+stm32f1xx_hal_i2c.c:2844:19:HAL_I2C_Mem_Write_IT	32	static
34
+stm32f1xx_hal_i2c.c:2930:19:HAL_I2C_Mem_Read_IT	32	static
35
+stm32f1xx_hal_i2c.c:3021:19:HAL_I2C_Mem_Write_DMA	56	static
36
+stm32f1xx_hal_i2c.c:3142:19:HAL_I2C_Mem_Read_DMA	56	static
37
+stm32f1xx_hal_i2c.c:3302:19:HAL_I2C_IsDeviceReady	56	static
38
+stm32f1xx_hal_i2c.c:3608:13:HAL_I2C_MasterTxCpltCallback	0	static
39
+stm32f1xx_hal_i2c.c:3624:13:HAL_I2C_MasterRxCpltCallback	0	static
40
+stm32f1xx_hal_i2c.c:3639:13:HAL_I2C_SlaveTxCpltCallback	0	static
41
+stm32f1xx_hal_i2c.c:3655:13:HAL_I2C_SlaveRxCpltCallback	0	static
42
+stm32f1xx_hal_i2c.c:3673:13:HAL_I2C_AddrCallback	0	static
43
+stm32f1xx_hal_i2c.c:3691:13:HAL_I2C_ListenCpltCallback	0	static
44
+stm32f1xx_hal_i2c.c:3707:13:HAL_I2C_MemTxCpltCallback	0	static
45
+stm32f1xx_hal_i2c.c:3723:13:HAL_I2C_MemRxCpltCallback	0	static
46
+stm32f1xx_hal_i2c.c:3739:13:HAL_I2C_ErrorCallback	0	static
47
+stm32f1xx_hal_i2c.c:5252:13:I2C_DMAError	8	static
48
+stm32f1xx_hal_i2c.c:5188:13:I2C_DMAXferCplt	8	static
49
+stm32f1xx_hal_i2c.c:3755:13:HAL_I2C_AbortCpltCallback	0	static
50
+stm32f1xx_hal_i2c.c:4658:13:I2C_ITError	8	static
51
+stm32f1xx_hal_i2c.c:2202:19:HAL_I2C_Master_Abort_IT	8	static
52
+stm32f1xx_hal_i2c.c:3425:6:HAL_I2C_EV_IRQHandler	72	static
53
+stm32f1xx_hal_i2c.c:3531:6:HAL_I2C_ER_IRQHandler	24	static
54
+stm32f1xx_hal_i2c.c:5275:13:I2C_DMAAbort	8	static
55
+stm32f1xx_hal_i2c.c:3790:22:HAL_I2C_GetState	0	static
56
+stm32f1xx_hal_i2c.c:3802:21:HAL_I2C_GetMode	0	static
57
+stm32f1xx_hal_i2c.c:3813:10:HAL_I2C_GetError	0	static

BIN
Debug/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_spi.o


+ 55 - 0
Debug/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_spi.su

@@ -0,0 +1,55 @@
1
+stm32f1xx_hal_spi.c:3193:13:SPI_AbortRx_ISR	8	static
2
+stm32f1xx_hal_spi.c:3228:13:SPI_AbortTx_ISR	0	static
3
+stm32f1xx_hal_spi.c:2929:26:SPI_WaitFlagStateUntilTimeout	24	static
4
+stm32f1xx_hal_spi.c:2976:26:SPI_CheckFlag_BSY	16	static
5
+stm32f1xx_hal_spi.c:374:13:HAL_SPI_MspInit	0	static
6
+stm32f1xx_hal_spi.c:261:26:HAL_SPI_Init	8	static
7
+stm32f1xx_hal_spi.c:389:13:HAL_SPI_MspDeInit	0	static
8
+stm32f1xx_hal_spi.c:340:19:HAL_SPI_DeInit	8	static
9
+stm32f1xx_hal_spi.c:444:19:HAL_SPI_Transmit	40	static
10
+stm32f1xx_hal_spi.c:821:19:HAL_SPI_TransmitReceive	48	static
11
+stm32f1xx_hal_spi.c:614:19:HAL_SPI_Receive	32	static
12
+stm32f1xx_hal_spi.c:1053:19:HAL_SPI_Transmit_IT	0	static
13
+stm32f1xx_hal_spi.c:1235:19:HAL_SPI_TransmitReceive_IT	12	static
14
+stm32f1xx_hal_spi.c:1143:19:HAL_SPI_Receive_IT	12	static
15
+stm32f1xx_hal_spi.c:1321:19:HAL_SPI_Transmit_DMA	8	static
16
+stm32f1xx_hal_spi.c:1511:19:HAL_SPI_TransmitReceive_DMA	16	static
17
+stm32f1xx_hal_spi.c:1414:19:HAL_SPI_Receive_DMA	16	static
18
+stm32f1xx_hal_spi.c:1633:19:HAL_SPI_Abort	16	static
19
+stm32f1xx_hal_spi.c:1874:19:HAL_SPI_DMAPause	0	static
20
+stm32f1xx_hal_spi.c:1894:19:HAL_SPI_DMAResume	0	static
21
+stm32f1xx_hal_spi.c:1914:19:HAL_SPI_DMAStop	8	static
22
+stm32f1xx_hal_spi.c:2034:13:HAL_SPI_TxCpltCallback	0	static
23
+stm32f1xx_hal_spi.c:2049:13:HAL_SPI_RxCpltCallback	0	static
24
+stm32f1xx_hal_spi.c:2064:13:HAL_SPI_TxRxCpltCallback	0	static
25
+stm32f1xx_hal_spi.c:2079:13:HAL_SPI_TxHalfCpltCallback	0	static
26
+stm32f1xx_hal_spi.c:2408:13:SPI_DMAHalfTransmitCplt	8	static
27
+stm32f1xx_hal_spi.c:2094:13:HAL_SPI_RxHalfCpltCallback	0	static
28
+stm32f1xx_hal_spi.c:2421:13:SPI_DMAHalfReceiveCplt	8	static
29
+stm32f1xx_hal_spi.c:2109:13:HAL_SPI_TxRxHalfCpltCallback	0	static
30
+stm32f1xx_hal_spi.c:2434:13:SPI_DMAHalfTransmitReceiveCplt	8	static
31
+stm32f1xx_hal_spi.c:2124:14:HAL_SPI_ErrorCallback	0	static
32
+stm32f1xx_hal_spi.c:3138:13:SPI_CloseTx_ISR	16	static
33
+stm32f1xx_hal_spi.c:2875:13:SPI_TxISR_8BIT	4	static
34
+stm32f1xx_hal_spi.c:2899:13:SPI_TxISR_16BIT	4	static
35
+stm32f1xx_hal_spi.c:3078:13:SPI_CloseRx_ISR	16	static
36
+stm32f1xx_hal_spi.c:2786:13:SPI_RxISR_8BIT	0	static
37
+stm32f1xx_hal_spi.c:2842:13:SPI_RxISR_16BIT	0	static
38
+stm32f1xx_hal_spi.c:2993:13:SPI_CloseRxTx_ISR	16	static
39
+stm32f1xx_hal_spi.c:2639:13:SPI_2linesTxISR_8BIT	4	static
40
+stm32f1xx_hal_spi.c:2578:13:SPI_2linesRxISR_8BIT	0	static
41
+stm32f1xx_hal_spi.c:2730:13:SPI_2linesTxISR_16BIT	4	static
42
+stm32f1xx_hal_spi.c:2672:13:SPI_2linesRxISR_16BIT	4	static
43
+stm32f1xx_hal_spi.c:2447:13:SPI_DMAError	8	static
44
+stm32f1xx_hal_spi.c:2213:13:SPI_DMATransmitCplt	24	static
45
+stm32f1xx_hal_spi.c:2257:13:SPI_DMAReceiveCplt	8	static
46
+stm32f1xx_hal_spi.c:2334:13:SPI_DMATransmitReceiveCplt	16	static
47
+stm32f1xx_hal_spi.c:1945:6:HAL_SPI_IRQHandler	32	static
48
+stm32f1xx_hal_spi.c:2465:13:SPI_DMAAbortOnError	8	static
49
+stm32f1xx_hal_spi.c:2141:13:HAL_SPI_AbortCpltCallback	0	static
50
+stm32f1xx_hal_spi.c:1729:19:HAL_SPI_Abort_IT	24	static
51
+stm32f1xx_hal_spi.c:2534:13:SPI_DMARxAbortCallback	16	static
52
+stm32f1xx_hal_spi.c:2482:13:SPI_DMATxAbortCallback	16	static
53
+stm32f1xx_hal_spi.c:2176:22:HAL_SPI_GetState	0	static
54
+stm32f1xx_hal_spi.c:2188:10:HAL_SPI_GetError	0	static
55
+stm32f1xx_hal_spi.c:3244:16:SPI_ISCRCErrorValid	0	static

BIN
Debug/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_spi_ex.o


+ 1 - 0
Debug/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_spi_ex.su

@@ -0,0 +1 @@
1
+stm32f1xx_hal_spi_ex.c:98:19:HAL_SPI_Init	8	static

BIN
Debug/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim.o


BIN
Debug/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim_ex.o


BIN
Debug/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_uart.o


BIN
Debug/STM32F103_RGB_Controller.bin


BIN
Debug/STM32F103_RGB_Controller.binary


BIN
Debug/STM32F103_RGB_Controller.elf


Разлика између датотеке није приказан због своје велике величине
+ 822 - 912
Debug/STM32F103_RGB_Controller.hex


Разлика између датотеке није приказан због своје велике величине
+ 5767 - 5150
Debug/STM32F103_RGB_Controller.list


Разлика између датотеке није приказан због своје велике величине
+ 724 - 722
Debug/STM32F103_RGB_Controller.map


BIN
Debug/Src/GPIO_SPI.o


+ 7 - 0
Debug/Src/GPIO_SPI.su

@@ -0,0 +1,7 @@
1
+GPIO_SPI.c:58:6:SPI_Delay	8	static
2
+GPIO_SPI.c:70:6:SpiInOut	16	static
3
+GPIO_SPI.c:97:9:SpiRead	16	static
4
+GPIO_SPI.c:118:9:SPIGPIOTxRx	16	static
5
+GPIO_SPI.c:165:6:BLUECELL_SPI_Transmit	0	static
6
+GPIO_SPI.c:213:9:SPIReadByte	16	static
7
+GPIO_SPI.c:224:9:SPIWriteByte	8	static

BIN
Debug/Src/RGB_Controller.o


+ 4 - 3
Debug/Src/RGB_Controller.su

@@ -1,3 +1,4 @@
1
-RGB_Controller.c:7:6:RGB_Response_Func	0	static
2
-RGB_Controller.c:45:6:RGB_Alarm_Check	32	static
3
-RGB_Controller.c:137:6:RGB_Controller_Func	120	static
1
+RGB_Controller.c:7:6:RGB_Response_Func	8	static
2
+RGB_Controller.c:56:6:RGB_Alarm_Check	32	static
3
+RGB_Controller.c:84:9:RGB_DeviceStatusCheck	12	static
4
+RGB_Controller.c:94:6:RGB_Controller_Func	120	static

BIN
Debug/Src/RGB_Lora.o


+ 0 - 0
Debug/Src/RGB_Lora.su


BIN
Debug/Src/SX1276.o


+ 30 - 0
Debug/Src/SX1276.su

@@ -0,0 +1,30 @@
1
+SX1276.c:24:13:SX1276_hw_SetNSS	0	static
2
+SX1276.c:19:13:SX1276_hw_init	8	static
3
+SX1276.c:48:6:SX1276_hw_SPICommand	8	static
4
+SX1276.c:127:6:SX1276_SPIBurstWrite.part.1	24	static
5
+SX1276.c:63:9:SX1276_hw_SPIReadByte	8	static
6
+SX1276.c:73:13:SX1276_hw_DelayMs	0	static
7
+SX1276.c:29:13:SX1276_hw_Reset	8	static
8
+SX1276.c:77:12:SX1276_hw_GetDIO0	8	static
9
+SX1276.c:92:9:SX1276_SPIIDRead	16	static
10
+SX1276.c:85:9:SX1276_SPIRead	0	static
11
+SX1276.c:100:6:SX1276_SPIWrite	16	static
12
+SX1276.c:109:6:SX1276_SPIBurstRead	24	static
13
+SX1276.c:127:6:SX1276_SPIBurstWrite	0	static
14
+SX1276.c:197:6:SX1276_standby	8	static
15
+SX1276.c:202:6:SX1276_sleep	8	static
16
+SX1276.c:207:6:SX1276_entryLoRa	0	static
17
+SX1276.c:146:6:SX1276_config	24	static
18
+SX1276.c:141:6:SX1276_defaultConfig	16	static
19
+SX1276.c:211:6:SX1276_clearLoRaIrq	0	static
20
+SX1276.c:215:5:SX1276_LoRaEntryRx	16	static
21
+SX1276.c:247:9:SX1276_LoRaRxPacket	16	static
22
+SX1276.c:270:5:SX1276_LoRaEntryTx	16	static
23
+SX1276.c:301:5:SX1276_LoRaTxPacket	16	static
24
+SX1276.c:322:6:SX1276_begin	32	static
25
+SX1276.c:333:5:SX1276_transmit	24	static
26
+SX1276.c:341:5:SX1276_receive	0	static
27
+SX1276.c:345:9:SX1276_available	0	static
28
+SX1276.c:349:9:SX1276_read	16	static
29
+SX1276.c:358:9:SX1276_RSSI_LoRa	8	static
30
+SX1276.c:365:9:SX1276_RSSI	8	static


+ 9 - 0
Debug/Src/Uart.su

@@ -0,0 +1,9 @@
1
+Uart.c:31:6:HAL_UART_RxCpltCallback	8	static
2
+Uart.c:47:6:QueueCheck	24	static
3
+Uart.c:57:6:UartDataBufferCheck	8	static
4
+Uart.c:61:6:UartDataRecvSet	0	static
5
+Uart.c:64:9:UartDataRecvGet	0	static
6
+Uart.c:69:6:Uart2_Data_Send	0	static
7
+Uart.c:72:6:Uart1_Data_Send	0	static
8
+Uart.c:76:5:_write	8	static
9
+Uart.c:81:6:Uart_dataCheck	24	static


+ 11 - 15
Debug/Src/main.su

@@ -1,15 +1,11 @@
1
-main.c:116:6:HAL_UART_RxCpltCallback	8	static
2
-main.c:153:6:HAL_TIM_PeriodElapsedCallback	0	static
3
-main.c:163:6:UartDataRecvSet	0	static
4
-main.c:166:9:UartDataRecvGet	0	static
5
-main.c:169:6:RGB_SensorIDAutoSet	0	static
6
-main.c:172:9:RGB_SensorIDAutoGet	0	static
7
-main.c:176:6:Uart3_Data_Send	0	static
8
-main.c:179:6:Uart2_Data_Send	0	static
9
-main.c:182:6:Uart1_Data_Send	0	static
10
-main.c:186:5:_write	8	static
11
-main.c:191:6:Uart_dataCheck	24	static
12
-main.c:220:6:RGB_Sensor_PowerOnOff	8	static
13
-main.c:434:6:SystemClock_Config	72	static
14
-main.c:329:5:main	96	static
15
-main.c:688:6:Error_Handler	0	static
1
+main.c:109:6:HAL_TIM_PeriodElapsedCallback	0	static
2
+main.c:120:6:RGB_SensorIDAutoSet	0	static
3
+main.c:123:9:RGB_SensorIDAutoGet	0	static
4
+main.c:128:6:RGB_Sensor_PowerOnOff	8	static
5
+main.c:282:6:test_read	24	static
6
+main.c:301:6:Flash_RGB_Data_Write	16	static
7
+main.c:314:6:Flash_write	24	static
8
+main.c:367:6:Flash_InitRead	12	static
9
+main.c:558:6:SystemClock_Config	72	static
10
+main.c:404:5:main	112	static
11
+main.c:832:6:Error_Handler	0	static

BIN
Debug/Src/stm32f1xx_hal_msp.o


+ 6 - 4
Debug/Src/stm32f1xx_hal_msp.su

@@ -1,5 +1,7 @@
1 1
 stm32f1xx_hal_msp.c:84:6:HAL_MspInit	8	static
2
-stm32f1xx_hal_msp.c:110:6:HAL_TIM_Base_MspInit	8	static
3
-stm32f1xx_hal_msp.c:134:6:HAL_TIM_Base_MspDeInit	0	static
4
-stm32f1xx_hal_msp.c:160:6:HAL_UART_MspInit	48	static
5
-stm32f1xx_hal_msp.c:255:6:HAL_UART_MspDeInit	8	static
2
+stm32f1xx_hal_msp.c:110:6:HAL_I2C_MspInit	32	static
3
+stm32f1xx_hal_msp.c:146:6:HAL_I2C_MspDeInit	0	static
4
+stm32f1xx_hal_msp.c:176:6:HAL_TIM_Base_MspInit	8	static
5
+stm32f1xx_hal_msp.c:200:6:HAL_TIM_Base_MspDeInit	0	static
6
+stm32f1xx_hal_msp.c:226:6:HAL_UART_MspInit	40	static
7
+stm32f1xx_hal_msp.c:294:6:HAL_UART_MspDeInit	8	static

BIN
Debug/Src/stm32f1xx_it.o


+ 12 - 13
Debug/Src/stm32f1xx_it.su

@@ -1,13 +1,12 @@
1
-stm32f1xx_it.c:88:6:NMI_Handler	0	static
2
-stm32f1xx_it.c:101:6:HardFault_Handler	0	static
3
-stm32f1xx_it.c:116:6:MemManage_Handler	0	static
4
-stm32f1xx_it.c:131:6:BusFault_Handler	0	static
5
-stm32f1xx_it.c:146:6:UsageFault_Handler	0	static
6
-stm32f1xx_it.c:161:6:SVC_Handler	0	static
7
-stm32f1xx_it.c:174:6:DebugMon_Handler	0	static
8
-stm32f1xx_it.c:187:6:PendSV_Handler	0	static
9
-stm32f1xx_it.c:200:6:SysTick_Handler	0	static
10
-stm32f1xx_it.c:221:6:USART1_IRQHandler	0	static
11
-stm32f1xx_it.c:235:6:USART2_IRQHandler	0	static
12
-stm32f1xx_it.c:249:6:USART3_IRQHandler	0	static
13
-stm32f1xx_it.c:263:6:TIM6_IRQHandler	0	static
1
+stm32f1xx_it.c:87:6:NMI_Handler	0	static
2
+stm32f1xx_it.c:100:6:HardFault_Handler	0	static
3
+stm32f1xx_it.c:115:6:MemManage_Handler	0	static
4
+stm32f1xx_it.c:130:6:BusFault_Handler	0	static
5
+stm32f1xx_it.c:145:6:UsageFault_Handler	0	static
6
+stm32f1xx_it.c:160:6:SVC_Handler	0	static
7
+stm32f1xx_it.c:173:6:DebugMon_Handler	0	static
8
+stm32f1xx_it.c:186:6:PendSV_Handler	0	static
9
+stm32f1xx_it.c:199:6:SysTick_Handler	0	static
10
+stm32f1xx_it.c:220:6:USART1_IRQHandler	0	static
11
+stm32f1xx_it.c:234:6:USART2_IRQHandler	0	static
12
+stm32f1xx_it.c:248:6:TIM6_IRQHandler	0	static

BIN
Debug/Src/system_stm32f1xx.o


+ 0 - 587
Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_spi.h

@@ -1,587 +0,0 @@
1
-/**
2
-  ******************************************************************************
3
-  * @file    stm32f1xx_hal_spi.h
4
-  * @author  MCD Application Team
5
-  * @brief   Header file of SPI HAL module.
6
-  ******************************************************************************
7
-  * @attention
8
-  *
9
-  * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
10
-  *
11
-  * Redistribution and use in source and binary forms, with or without modification,
12
-  * are permitted provided that the following conditions are met:
13
-  *   1. Redistributions of source code must retain the above copyright notice,
14
-  *      this list of conditions and the following disclaimer.
15
-  *   2. Redistributions in binary form must reproduce the above copyright notice,
16
-  *      this list of conditions and the following disclaimer in the documentation
17
-  *      and/or other materials provided with the distribution.
18
-  *   3. Neither the name of STMicroelectronics nor the names of its contributors
19
-  *      may be used to endorse or promote products derived from this software
20
-  *      without specific prior written permission.
21
-  *
22
-  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23
-  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24
-  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25
-  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
26
-  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27
-  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28
-  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29
-  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30
-  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31
-  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
-  *
33
-  ******************************************************************************
34
-  */
35
-
36
-/* Define to prevent recursive inclusion -------------------------------------*/
37
-#ifndef __STM32F1xx_HAL_SPI_H
38
-#define __STM32F1xx_HAL_SPI_H
39
-
40
-#ifdef __cplusplus
41
- extern "C" {
42
-#endif
43
-
44
-/* Includes ------------------------------------------------------------------*/
45
-#include "stm32f1xx_hal_def.h"  
46
-
47
-/** @addtogroup STM32F1xx_HAL_Driver
48
-  * @{
49
-  */
50
-
51
-/** @addtogroup SPI
52
-  * @{
53
-  */
54
-
55
-/* Exported types ------------------------------------------------------------*/
56
-/** @defgroup SPI_Exported_Types SPI Exported Types
57
-  * @{
58
-  */
59
-
60
-/**
61
-  * @brief  SPI Configuration Structure definition
62
-  */
63
-typedef struct
64
-{
65
-  uint32_t Mode;               /*!< Specifies the SPI operating mode.
66
-                                    This parameter can be a value of @ref SPI_Mode */
67
-
68
-  uint32_t Direction;          /*!< Specifies the SPI Directional mode state.
69
-                                    This parameter can be a value of @ref SPI_Direction */
70
-
71
-  uint32_t DataSize;           /*!< Specifies the SPI data size.
72
-                                    This parameter can be a value of @ref SPI_Data_Size */
73
-
74
-  uint32_t CLKPolarity;        /*!< Specifies the serial clock steady state.
75
-                                    This parameter can be a value of @ref SPI_Clock_Polarity */
76
-
77
-  uint32_t CLKPhase;           /*!< Specifies the clock active edge for the bit capture.
78
-                                    This parameter can be a value of @ref SPI_Clock_Phase */
79
-
80
-  uint32_t NSS;                /*!< Specifies whether the NSS signal is managed by
81
-                                    hardware (NSS pin) or by software using the SSI bit.
82
-                                    This parameter can be a value of @ref SPI_Slave_Select_management */
83
-
84
-  uint32_t BaudRatePrescaler;  /*!< Specifies the Baud Rate prescaler value which will be
85
-                                    used to configure the transmit and receive SCK clock.
86
-                                    This parameter can be a value of @ref SPI_BaudRate_Prescaler
87
-                                    @note The communication clock is derived from the master
88
-                                     clock. The slave clock does not need to be set. */
89
-
90
-  uint32_t FirstBit;           /*!< Specifies whether data transfers start from MSB or LSB bit.
91
-                                    This parameter can be a value of @ref SPI_MSB_LSB_transmission */
92
-
93
-  uint32_t TIMode;             /*!< Specifies if the TI mode is enabled or not.
94
-                                    This parameter can be a value of @ref SPI_TI_mode */
95
-
96
-  uint32_t CRCCalculation;     /*!< Specifies if the CRC calculation is enabled or not.
97
-                                    This parameter can be a value of @ref SPI_CRC_Calculation */
98
-
99
-  uint32_t CRCPolynomial;      /*!< Specifies the polynomial used for the CRC calculation.
100
-                                    This parameter must be a number between Min_Data = 0 and Max_Data = 65535 */
101
-}SPI_InitTypeDef;
102
-
103
-/**
104
-  * @brief  HAL SPI State structure definition
105
-  */
106
-typedef enum
107
-{
108
-  HAL_SPI_STATE_RESET      = 0x00U,    /*!< Peripheral not Initialized                         */
109
-  HAL_SPI_STATE_READY      = 0x01U,    /*!< Peripheral Initialized and ready for use           */
110
-  HAL_SPI_STATE_BUSY       = 0x02U,    /*!< an internal process is ongoing                     */
111
-  HAL_SPI_STATE_BUSY_TX    = 0x03U,    /*!< Data Transmission process is ongoing               */
112
-  HAL_SPI_STATE_BUSY_RX    = 0x04U,    /*!< Data Reception process is ongoing                  */
113
-  HAL_SPI_STATE_BUSY_TX_RX = 0x05U,    /*!< Data Transmission and Reception process is ongoing */
114
-  HAL_SPI_STATE_ERROR      = 0x06U     /*!< SPI error state                                    */
115
-}HAL_SPI_StateTypeDef;
116
-
117
-/**
118
-  * @brief  SPI handle Structure definition
119
-  */
120
-typedef struct __SPI_HandleTypeDef
121
-{
122
-  SPI_TypeDef                *Instance;    /*!< SPI registers base address */
123
-
124
-  SPI_InitTypeDef            Init;         /*!< SPI communication parameters */
125
-
126
-  uint8_t                    *pTxBuffPtr;  /*!< Pointer to SPI Tx transfer Buffer */
127
-
128
-  uint16_t                   TxXferSize;   /*!< SPI Tx Transfer size */
129
-
130
-  __IO uint16_t              TxXferCount;  /*!< SPI Tx Transfer Counter */
131
-
132
-  uint8_t                    *pRxBuffPtr;  /*!< Pointer to SPI Rx transfer Buffer */
133
-
134
-  uint16_t                   RxXferSize;   /*!< SPI Rx Transfer size */
135
-
136
-  __IO uint16_t              RxXferCount;  /*!< SPI Rx Transfer Counter */
137
-
138
-  void                       (*RxISR)(struct __SPI_HandleTypeDef * hspi); /*!< function pointer on Rx ISR */
139
-
140
-  void                       (*TxISR)(struct __SPI_HandleTypeDef * hspi); /*!< function pointer on Tx ISR */
141
-
142
-  DMA_HandleTypeDef          *hdmatx;      /*!< SPI Tx DMA Handle parameters   */
143
-
144
-  DMA_HandleTypeDef          *hdmarx;      /*!< SPI Rx DMA Handle parameters   */
145
-
146
-  HAL_LockTypeDef            Lock;         /*!< Locking object                 */
147
-
148
-  __IO HAL_SPI_StateTypeDef  State;        /*!< SPI communication state */
149
-
150
-  __IO uint32_t              ErrorCode;    /*!< SPI Error code */
151
-
152
-}SPI_HandleTypeDef;
153
-
154
-/**
155
-  * @}
156
-  */
157
-
158
-/* Exported constants --------------------------------------------------------*/
159
-/** @defgroup SPI_Exported_Constants SPI Exported Constants
160
-  * @{
161
-  */
162
-
163
-/** @defgroup SPI_Error_Code SPI Error Code
164
-  * @{
165
-  */
166
-#define HAL_SPI_ERROR_NONE              0x00000000U   /*!< No error             */
167
-#define HAL_SPI_ERROR_MODF              0x00000001U   /*!< MODF error           */
168
-#define HAL_SPI_ERROR_CRC               0x00000002U   /*!< CRC error            */
169
-#define HAL_SPI_ERROR_OVR               0x00000004U   /*!< OVR error            */
170
-#define HAL_SPI_ERROR_FRE               0x00000008U   /*!< FRE error            */
171
-#define HAL_SPI_ERROR_DMA               0x00000010U   /*!< DMA transfer error   */
172
-#define HAL_SPI_ERROR_FLAG              0x00000020U   /*!< Flag: RXNE,TXE, BSY  */
173
-/**
174
-  * @}
175
-  */
176
-
177
-/** @defgroup SPI_Mode SPI Mode
178
-  * @{
179
-  */
180
-#define SPI_MODE_SLAVE                  0x00000000U
181
-#define SPI_MODE_MASTER                 (SPI_CR1_MSTR | SPI_CR1_SSI)
182
-/**
183
-  * @}
184
-  */
185
-
186
-/** @defgroup SPI_Direction SPI Direction Mode
187
-  * @{
188
-  */
189
-#define SPI_DIRECTION_2LINES            0x00000000U
190
-#define SPI_DIRECTION_2LINES_RXONLY     SPI_CR1_RXONLY
191
-#define SPI_DIRECTION_1LINE             SPI_CR1_BIDIMODE
192
-/**
193
-  * @}
194
-  */
195
-
196
-/** @defgroup SPI_Data_Size SPI Data Size
197
-  * @{
198
-  */
199
-#define SPI_DATASIZE_8BIT               0x00000000U
200
-#define SPI_DATASIZE_16BIT              SPI_CR1_DFF
201
-/**
202
-  * @}
203
-  */
204
-
205
-/** @defgroup SPI_Clock_Polarity SPI Clock Polarity
206
-  * @{
207
-  */
208
-#define SPI_POLARITY_LOW                0x00000000U
209
-#define SPI_POLARITY_HIGH               SPI_CR1_CPOL
210
-/**
211
-  * @}
212
-  */
213
-
214
-/** @defgroup SPI_Clock_Phase SPI Clock Phase
215
-  * @{
216
-  */
217
-#define SPI_PHASE_1EDGE                 0x00000000U
218
-#define SPI_PHASE_2EDGE                 SPI_CR1_CPHA
219
-/**
220
-  * @}
221
-  */
222
-
223
-/** @defgroup SPI_Slave_Select_management SPI Slave Select Management
224
-  * @{
225
-  */
226
-#define SPI_NSS_SOFT                    SPI_CR1_SSM
227
-#define SPI_NSS_HARD_INPUT              0x00000000U
228
-#define SPI_NSS_HARD_OUTPUT             ((uint32_t)(SPI_CR2_SSOE << 16))
229
-/**
230
-  * @}
231
-  */
232
-
233
-/** @defgroup SPI_BaudRate_Prescaler SPI BaudRate Prescaler
234
-  * @{
235
-  */
236
-#define SPI_BAUDRATEPRESCALER_2         0x00000000U
237
-#define SPI_BAUDRATEPRESCALER_4         SPI_CR1_BR_0
238
-#define SPI_BAUDRATEPRESCALER_8         SPI_CR1_BR_1
239
-#define SPI_BAUDRATEPRESCALER_16        (uint32_t)(SPI_CR1_BR_1 | SPI_CR1_BR_0)
240
-#define SPI_BAUDRATEPRESCALER_32        SPI_CR1_BR_2
241
-#define SPI_BAUDRATEPRESCALER_64        (uint32_t)(SPI_CR1_BR_2 | SPI_CR1_BR_0)
242
-#define SPI_BAUDRATEPRESCALER_128       (uint32_t)(SPI_CR1_BR_2 | SPI_CR1_BR_1)
243
-#define SPI_BAUDRATEPRESCALER_256       (uint32_t)(SPI_CR1_BR_2 | SPI_CR1_BR_1 | SPI_CR1_BR_0)
244
-
245
-/**
246
-  * @}
247
-  */
248
-
249
-/** @defgroup SPI_MSB_LSB_transmission SPI MSB LSB Transmission
250
-  * @{
251
-  */
252
-#define SPI_FIRSTBIT_MSB                0x00000000U
253
-#define SPI_FIRSTBIT_LSB                SPI_CR1_LSBFIRST
254
-/**
255
-  * @}
256
-  */
257
-
258
-/** @defgroup SPI_TI_mode SPI TI Mode
259
-  * @{
260
-  */
261
-#define SPI_TIMODE_DISABLE             0x00000000U
262
-/**
263
-  * @}
264
-  */
265
-
266
-/** @defgroup SPI_CRC_Calculation SPI CRC Calculation
267
-  * @{
268
-  */
269
-#define SPI_CRCCALCULATION_DISABLE     0x00000000U
270
-#define SPI_CRCCALCULATION_ENABLE      SPI_CR1_CRCEN
271
-/**
272
-  * @}
273
-  */
274
-
275
-/** @defgroup SPI_Interrupt_definition SPI Interrupt Definition
276
-  * @{
277
-  */
278
-#define SPI_IT_TXE                      SPI_CR2_TXEIE
279
-#define SPI_IT_RXNE                     SPI_CR2_RXNEIE
280
-#define SPI_IT_ERR                      SPI_CR2_ERRIE
281
-/**
282
-  * @}
283
-  */
284
-
285
-/** @defgroup SPI_Flags_definition SPI Flags Definition
286
-  * @{
287
-  */
288
-#define SPI_FLAG_RXNE                   SPI_SR_RXNE   /* SPI status flag: Rx buffer not empty flag */
289
-#define SPI_FLAG_TXE                    SPI_SR_TXE    /* SPI status flag: Tx buffer empty flag */
290
-#define SPI_FLAG_BSY                    SPI_SR_BSY    /* SPI status flag: Busy flag */
291
-#define SPI_FLAG_CRCERR                 SPI_SR_CRCERR /* SPI Error flag: CRC error flag */
292
-#define SPI_FLAG_MODF                   SPI_SR_MODF   /* SPI Error flag: Mode fault flag */
293
-#define SPI_FLAG_OVR                    SPI_SR_OVR    /* SPI Error flag: Overrun flag */
294
-/**
295
-  * @}
296
-  */
297
-
298
-/**
299
-  * @}
300
-  */
301
-
302
-/* Exported macro ------------------------------------------------------------*/
303
-/** @defgroup SPI_Exported_Macros SPI Exported Macros
304
-  * @{
305
-  */
306
-
307
-/** @brief  Reset SPI handle state.
308
-  * @param  __HANDLE__: specifies the SPI Handle.
309
-  *         This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
310
-  * @retval None
311
-  */
312
-#define __HAL_SPI_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_SPI_STATE_RESET)
313
-
314
-/** @brief  Enable the specified SPI interrupts.
315
-  * @param  __HANDLE__: specifies the SPI handle.
316
-  *         This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
317
-  * @param  __INTERRUPT__: specifies the interrupt source to enable.
318
-  *         This parameter can be one of the following values:
319
-  *            @arg SPI_IT_TXE: Tx buffer empty interrupt enable
320
-  *            @arg SPI_IT_RXNE: RX buffer not empty interrupt enable
321
-  *            @arg SPI_IT_ERR: Error interrupt enable
322
-  * @retval None
323
-  */
324
-#define __HAL_SPI_ENABLE_IT(__HANDLE__, __INTERRUPT__)   ((__HANDLE__)->Instance->CR2 |= (__INTERRUPT__))
325
-
326
-/** @brief  Disable the specified SPI interrupts.
327
-  * @param  __HANDLE__: specifies the SPI handle.
328
-  *         This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
329
-  * @param  __INTERRUPT__: specifies the interrupt source to disable.
330
-  *         This parameter can be one of the following values:
331
-  *            @arg SPI_IT_TXE: Tx buffer empty interrupt enable
332
-  *            @arg SPI_IT_RXNE: RX buffer not empty interrupt enable
333
-  *            @arg SPI_IT_ERR: Error interrupt enable
334
-  * @retval None
335
-  */
336
-#define __HAL_SPI_DISABLE_IT(__HANDLE__, __INTERRUPT__)  ((__HANDLE__)->Instance->CR2 &= (~(__INTERRUPT__)))
337
-
338
-/** @brief  Check whether the specified SPI interrupt source is enabled or not.
339
-  * @param  __HANDLE__: specifies the SPI Handle.
340
-  *         This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
341
-  * @param  __INTERRUPT__: specifies the SPI interrupt source to check.
342
-  *          This parameter can be one of the following values:
343
-  *             @arg SPI_IT_TXE: Tx buffer empty interrupt enable
344
-  *             @arg SPI_IT_RXNE: RX buffer not empty interrupt enable
345
-  *             @arg SPI_IT_ERR: Error interrupt enable
346
-  * @retval The new state of __IT__ (TRUE or FALSE).
347
-  */
348
-#define __HAL_SPI_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->CR2 & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET)
349
-
350
-/** @brief  Check whether the specified SPI flag is set or not.
351
-  * @param  __HANDLE__: specifies the SPI Handle.
352
-  *         This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
353
-  * @param  __FLAG__: specifies the flag to check.
354
-  *         This parameter can be one of the following values:
355
-  *            @arg SPI_FLAG_RXNE: Receive buffer not empty flag
356
-  *            @arg SPI_FLAG_TXE: Transmit buffer empty flag
357
-  *            @arg SPI_FLAG_CRCERR: CRC error flag
358
-  *            @arg SPI_FLAG_MODF: Mode fault flag
359
-  *            @arg SPI_FLAG_OVR: Overrun flag
360
-  *            @arg SPI_FLAG_BSY: Busy flag
361
-  * @retval The new state of __FLAG__ (TRUE or FALSE).
362
-  */
363
-#define __HAL_SPI_GET_FLAG(__HANDLE__, __FLAG__) ((((__HANDLE__)->Instance->SR) & (__FLAG__)) == (__FLAG__))
364
-
365
-/** @brief  Clear the SPI CRCERR pending flag.
366
-  * @param  __HANDLE__: specifies the SPI Handle.
367
-  *         This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
368
-  * @retval None
369
-  */
370
-#define __HAL_SPI_CLEAR_CRCERRFLAG(__HANDLE__) ((__HANDLE__)->Instance->SR = (uint16_t)(~SPI_FLAG_CRCERR))
371
-
372
-/** @brief  Clear the SPI MODF pending flag.
373
-  * @param  __HANDLE__: specifies the SPI Handle.
374
-  *         This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
375
-  * @retval None
376
-  */
377
-#define __HAL_SPI_CLEAR_MODFFLAG(__HANDLE__)       \
378
-do{                                                \
379
-    __IO uint32_t tmpreg_modf = 0x00U;             \
380
-    tmpreg_modf = (__HANDLE__)->Instance->SR;      \
381
-    (__HANDLE__)->Instance->CR1 &= (~SPI_CR1_SPE); \
382
-    UNUSED(tmpreg_modf);                           \
383
-  } while(0U)
384
-
385
-/** @brief  Clear the SPI OVR pending flag.
386
-  * @param  __HANDLE__: specifies the SPI Handle.
387
-  *         This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
388
-  * @retval None
389
-  */
390
-#define __HAL_SPI_CLEAR_OVRFLAG(__HANDLE__)        \
391
-do{                                                \
392
-    __IO uint32_t tmpreg_ovr = 0x00U;              \
393
-    tmpreg_ovr = (__HANDLE__)->Instance->DR;       \
394
-    tmpreg_ovr = (__HANDLE__)->Instance->SR;       \
395
-    UNUSED(tmpreg_ovr);                            \
396
-  } while(0U)
397
-
398
-
399
-/** @brief  Enable the SPI peripheral.
400
-  * @param  __HANDLE__: specifies the SPI Handle.
401
-  *         This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
402
-  * @retval None
403
-  */
404
-#define __HAL_SPI_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 |=  SPI_CR1_SPE)
405
-
406
-/** @brief  Disable the SPI peripheral.
407
-  * @param  __HANDLE__: specifies the SPI Handle.
408
-  *         This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
409
-  * @retval None
410
-  */
411
-#define __HAL_SPI_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 &= (~SPI_CR1_SPE))
412
-/**
413
-  * @}
414
-  */
415
-
416
-/* Exported functions --------------------------------------------------------*/
417
-/** @addtogroup SPI_Exported_Functions
418
-  * @{
419
-  */
420
-
421
-/** @addtogroup SPI_Exported_Functions_Group1
422
-  * @{
423
-  */
424
-/* Initialization/de-initialization functions  **********************************/
425
-HAL_StatusTypeDef HAL_SPI_Init(SPI_HandleTypeDef *hspi);
426
-HAL_StatusTypeDef HAL_SPI_DeInit (SPI_HandleTypeDef *hspi);
427
-void HAL_SPI_MspInit(SPI_HandleTypeDef *hspi);
428
-void HAL_SPI_MspDeInit(SPI_HandleTypeDef *hspi);
429
-/**
430
-  * @}
431
-  */
432
-
433
-/** @addtogroup SPI_Exported_Functions_Group2
434
-  * @{
435
-  */
436
-/* I/O operation functions  *****************************************************/
437
-HAL_StatusTypeDef HAL_SPI_Transmit(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size, uint32_t Timeout);
438
-HAL_StatusTypeDef HAL_SPI_Receive(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size, uint32_t Timeout);
439
-HAL_StatusTypeDef HAL_SPI_TransmitReceive(SPI_HandleTypeDef *hspi, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size, uint32_t Timeout);
440
-HAL_StatusTypeDef HAL_SPI_Transmit_IT(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size);
441
-HAL_StatusTypeDef HAL_SPI_Receive_IT(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size);
442
-HAL_StatusTypeDef HAL_SPI_TransmitReceive_IT(SPI_HandleTypeDef *hspi, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size);
443
-HAL_StatusTypeDef HAL_SPI_Transmit_DMA(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size);
444
-HAL_StatusTypeDef HAL_SPI_Receive_DMA(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size);
445
-HAL_StatusTypeDef HAL_SPI_TransmitReceive_DMA(SPI_HandleTypeDef *hspi, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size);
446
-HAL_StatusTypeDef HAL_SPI_DMAPause(SPI_HandleTypeDef *hspi);
447
-HAL_StatusTypeDef HAL_SPI_DMAResume(SPI_HandleTypeDef *hspi);
448
-HAL_StatusTypeDef HAL_SPI_DMAStop(SPI_HandleTypeDef *hspi);
449
-/* Transfer Abort functions */
450
-HAL_StatusTypeDef HAL_SPI_Abort(SPI_HandleTypeDef *hspi);
451
-HAL_StatusTypeDef HAL_SPI_Abort_IT(SPI_HandleTypeDef *hspi);
452
-
453
-void HAL_SPI_IRQHandler(SPI_HandleTypeDef *hspi);
454
-void HAL_SPI_TxCpltCallback(SPI_HandleTypeDef *hspi);
455
-void HAL_SPI_RxCpltCallback(SPI_HandleTypeDef *hspi);
456
-void HAL_SPI_TxRxCpltCallback(SPI_HandleTypeDef *hspi);
457
-void HAL_SPI_TxHalfCpltCallback(SPI_HandleTypeDef *hspi);
458
-void HAL_SPI_RxHalfCpltCallback(SPI_HandleTypeDef *hspi);
459
-void HAL_SPI_TxRxHalfCpltCallback(SPI_HandleTypeDef *hspi);
460
-void HAL_SPI_ErrorCallback(SPI_HandleTypeDef *hspi);
461
-void HAL_SPI_AbortCpltCallback(SPI_HandleTypeDef *hspi);
462
-/**
463
-  * @}
464
-  */
465
-
466
-/** @addtogroup SPI_Exported_Functions_Group3
467
-  * @{
468
-  */
469
-/* Peripheral State and Error functions ***************************************/
470
-HAL_SPI_StateTypeDef HAL_SPI_GetState(SPI_HandleTypeDef *hspi);
471
-uint32_t             HAL_SPI_GetError(SPI_HandleTypeDef *hspi);
472
-/**
473
-  * @}
474
-  */
475
-
476
-/**
477
-  * @}
478
-  */
479
-
480
-/* Private types -------------------------------------------------------------*/
481
-/* Private variables ---------------------------------------------------------*/
482
-/* Private constants ---------------------------------------------------------*/
483
-/** @defgroup SPI_Private_Constants SPI Private Constants
484
-  * @{
485
-  */
486
-#define SPI_INVALID_CRC_ERROR     0U          /* CRC error wrongly detected */
487
-#define SPI_VALID_CRC_ERROR       1U          /* CRC error is true */
488
-/**
489
-  * @}
490
-  */
491
-/* Private macros ------------------------------------------------------------*/
492
-/** @defgroup SPI_Private_Macros SPI Private Macros
493
-  * @{
494
-  */
495
-
496
-/** @brief  Set the SPI transmit-only mode.
497
-  * @param  __HANDLE__: specifies the SPI Handle.
498
-  *         This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
499
-  * @retval None
500
-  */
501
-#define SPI_1LINE_TX(__HANDLE__) ((__HANDLE__)->Instance->CR1 |= SPI_CR1_BIDIOE)
502
-
503
-/** @brief  Set the SPI receive-only mode.
504
-  * @param  __HANDLE__: specifies the SPI Handle.
505
-  *         This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
506
-  * @retval None
507
-  */
508
-#define SPI_1LINE_RX(__HANDLE__) ((__HANDLE__)->Instance->CR1 &= (~SPI_CR1_BIDIOE))
509
-
510
-/** @brief  Reset the CRC calculation of the SPI.
511
-  * @param  __HANDLE__: specifies the SPI Handle.
512
-  *         This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
513
-  * @retval None
514
-  */
515
-#define SPI_RESET_CRC(__HANDLE__) do{(__HANDLE__)->Instance->CR1 &= (uint16_t)(~SPI_CR1_CRCEN);\
516
-                                     (__HANDLE__)->Instance->CR1 |= SPI_CR1_CRCEN;}while(0U)
517
-
518
-#define IS_SPI_MODE(MODE) (((MODE) == SPI_MODE_SLAVE) || \
519
-                           ((MODE) == SPI_MODE_MASTER))
520
-
521
-#define IS_SPI_DIRECTION(MODE) (((MODE) == SPI_DIRECTION_2LINES)        || \
522
-                                ((MODE) == SPI_DIRECTION_2LINES_RXONLY) || \
523
-                                ((MODE) == SPI_DIRECTION_1LINE))
524
-
525
-#define IS_SPI_DIRECTION_2LINES(MODE) ((MODE) == SPI_DIRECTION_2LINES)
526
-
527
-#define IS_SPI_DIRECTION_2LINES_OR_1LINE(MODE) (((MODE) == SPI_DIRECTION_2LINES)  || \
528
-                                                ((MODE) == SPI_DIRECTION_1LINE))
529
-
530
-#define IS_SPI_DATASIZE(DATASIZE) (((DATASIZE) == SPI_DATASIZE_16BIT) || \
531
-                                   ((DATASIZE) == SPI_DATASIZE_8BIT))
532
-
533
-#define IS_SPI_CPOL(CPOL) (((CPOL) == SPI_POLARITY_LOW) || \
534
-                           ((CPOL) == SPI_POLARITY_HIGH))
535
-
536
-#define IS_SPI_CPHA(CPHA) (((CPHA) == SPI_PHASE_1EDGE) || \
537
-                           ((CPHA) == SPI_PHASE_2EDGE))
538
-
539
-#define IS_SPI_NSS(NSS) (((NSS) == SPI_NSS_SOFT)       || \
540
-                         ((NSS) == SPI_NSS_HARD_INPUT) || \
541
-                         ((NSS) == SPI_NSS_HARD_OUTPUT))
542
-
543
-#define IS_SPI_BAUDRATE_PRESCALER(PRESCALER) (((PRESCALER) == SPI_BAUDRATEPRESCALER_2)   || \
544
-                                              ((PRESCALER) == SPI_BAUDRATEPRESCALER_4)   || \
545
-                                              ((PRESCALER) == SPI_BAUDRATEPRESCALER_8)   || \
546
-                                              ((PRESCALER) == SPI_BAUDRATEPRESCALER_16)  || \
547
-                                              ((PRESCALER) == SPI_BAUDRATEPRESCALER_32)  || \
548
-                                              ((PRESCALER) == SPI_BAUDRATEPRESCALER_64)  || \
549
-                                              ((PRESCALER) == SPI_BAUDRATEPRESCALER_128) || \
550
-                                              ((PRESCALER) == SPI_BAUDRATEPRESCALER_256))
551
-
552
-#define IS_SPI_FIRST_BIT(BIT) (((BIT) == SPI_FIRSTBIT_MSB) || \
553
-                               ((BIT) == SPI_FIRSTBIT_LSB))
554
-
555
-#define IS_SPI_CRC_CALCULATION(CALCULATION) (((CALCULATION) == SPI_CRCCALCULATION_DISABLE) || \
556
-                                             ((CALCULATION) == SPI_CRCCALCULATION_ENABLE))
557
-
558
-#define IS_SPI_CRC_POLYNOMIAL(POLYNOMIAL) (((POLYNOMIAL) >= 0x01U) && ((POLYNOMIAL) <= 0xFFFFU))
559
-
560
-/**
561
-  * @}
562
-  */
563
-
564
-/* Private functions ---------------------------------------------------------*/
565
-/** @defgroup SPI_Private_Functions SPI Private Functions
566
-  * @{
567
-  */
568
-uint8_t SPI_ISCRCErrorValid(SPI_HandleTypeDef *hspi);
569
-/**
570
-  * @}
571
-  */
572
-
573
-/**
574
-  * @}
575
-  */
576
-
577
-/**
578
-  * @}
579
-  */
580
-
581
-#ifdef __cplusplus
582
-}
583
-#endif
584
-
585
-#endif /* __STM32F1xx_HAL_SPI_H */
586
-
587
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

Разлика између датотеке није приказан због своје велике величине
+ 0 - 3264
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_spi.c


+ 0 - 231
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_spi_ex.c

@@ -1,231 +0,0 @@
1
-/**
2
-  ******************************************************************************
3
-  * @file    stm32f1xx_hal_spi_ex.c
4
-  * @author  MCD Application Team
5
-  * @brief   Extended SPI HAL module driver.
6
-  *    
7
-  *          This file provides firmware functions to manage the following 
8
-  *          functionalities SPI extension peripheral:
9
-  *           + Extended Peripheral Control functions
10
-  *  
11
-  ******************************************************************************
12
-  * @attention
13
-  *
14
-  * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
15
-  *
16
-  * Redistribution and use in source and binary forms, with or without modification,
17
-  * are permitted provided that the following conditions are met:
18
-  *   1. Redistributions of source code must retain the above copyright notice,
19
-  *      this list of conditions and the following disclaimer.
20
-  *   2. Redistributions in binary form must reproduce the above copyright notice,
21
-  *      this list of conditions and the following disclaimer in the documentation
22
-  *      and/or other materials provided with the distribution.
23
-  *   3. Neither the name of STMicroelectronics nor the names of its contributors
24
-  *      may be used to endorse or promote products derived from this software
25
-  *      without specific prior written permission.
26
-  *
27
-  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
28
-  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29
-  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
30
-  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
31
-  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32
-  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
33
-  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
34
-  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
35
-  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36
-  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37
-  *
38
-  ******************************************************************************
39
-  */
40
-
41
-/* Includes ------------------------------------------------------------------*/
42
-#include "stm32f1xx_hal.h"
43
-
44
-/** @addtogroup STM32F1xx_HAL_Driver
45
-  * @{
46
-  */
47
-
48
-/** @addtogroup SPI
49
-  * @{
50
-  */
51
-#ifdef HAL_SPI_MODULE_ENABLED
52
-
53
-/** @defgroup SPI_Private_Variables SPI Private Variables
54
-  * @{
55
-  */
56
-#if (USE_SPI_CRC != 0U)
57
-/* Variable used to determine if device is impacted by implementation of workaround
58
-   related to wrong CRC errors detection on SPI2. Conditions in which this workaround has to be applied, are:
59
-    - STM32F101CDE/STM32F103CDE
60
-    - Revision ID : Z
61
-    - SPI2
62
-    - In receive only mode, with CRC calculation enabled, at the end of the CRC reception,
63
-      the software needs to check the CRCERR flag. If it is found set, read back the SPI_RXCRC:
64
-        + If the value is 0, the complete data transfer is successful.
65
-        + Otherwise, one or more errors have been detected during the data transfer by CPU or DMA.
66
-      If CRCERR is found reset, the complete data transfer is considered successful.
67
-*/
68
-uint8_t uCRCErrorWorkaroundCheck = 0U;
69
-#endif /* USE_SPI_CRC */
70
-/**
71
-  * @}
72
-  */
73
-
74
-
75
-/* Private typedef -----------------------------------------------------------*/
76
-/* Private define ------------------------------------------------------------*/
77
-/* Private macro -------------------------------------------------------------*/
78
-/* Private variables ---------------------------------------------------------*/
79
-/* Private function prototypes -----------------------------------------------*/
80
-/* Private functions ---------------------------------------------------------*/
81
-
82
-/** @addtogroup SPI_Exported_Functions
83
-  * @{
84
-  */
85
-
86
-/** @addtogroup SPI_Exported_Functions_Group1
87
-  *
88
-  * @{
89
-  */
90
-
91
-/**
92
-  * @brief  Initializes the SPI according to the specified parameters 
93
-  *         in the SPI_InitTypeDef and create the associated handle.
94
-  * @param  hspi: pointer to a SPI_HandleTypeDef structure that contains
95
-  *                the configuration information for SPI module.
96
-  * @retval HAL status
97
-  */
98
-HAL_StatusTypeDef HAL_SPI_Init(SPI_HandleTypeDef *hspi)
99
-{
100
-  /* Check the SPI handle allocation */
101
-  if(hspi == NULL)
102
-  {
103
-    return HAL_ERROR;
104
-  }
105
-
106
-  /* Check the parameters */
107
-  assert_param(IS_SPI_ALL_INSTANCE(hspi->Instance));
108
-  assert_param(IS_SPI_MODE(hspi->Init.Mode));
109
-  assert_param(IS_SPI_DIRECTION(hspi->Init.Direction));
110
-  assert_param(IS_SPI_DATASIZE(hspi->Init.DataSize));
111
-  assert_param(IS_SPI_CPOL(hspi->Init.CLKPolarity));
112
-  assert_param(IS_SPI_CPHA(hspi->Init.CLKPhase));
113
-  assert_param(IS_SPI_NSS(hspi->Init.NSS));
114
-  assert_param(IS_SPI_BAUDRATE_PRESCALER(hspi->Init.BaudRatePrescaler));
115
-  assert_param(IS_SPI_FIRST_BIT(hspi->Init.FirstBit));
116
-
117
-#if (USE_SPI_CRC != 0U)
118
-  assert_param(IS_SPI_CRC_CALCULATION(hspi->Init.CRCCalculation));
119
-  if(hspi->Init.CRCCalculation == SPI_CRCCALCULATION_ENABLE)
120
-  {
121
-    assert_param(IS_SPI_CRC_POLYNOMIAL(hspi->Init.CRCPolynomial));
122
-  }
123
-#else
124
-  hspi->Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
125
-#endif /* USE_SPI_CRC */
126
-
127
-  if(hspi->State == HAL_SPI_STATE_RESET)
128
-  {
129
-    /* Init the low level hardware : GPIO, CLOCK, NVIC... */
130
-    HAL_SPI_MspInit(hspi);
131
-  }
132
-  
133
-  hspi->State = HAL_SPI_STATE_BUSY;
134
-
135
-  /* Disble the selected SPI peripheral */
136
-  __HAL_SPI_DISABLE(hspi);
137
-
138
-  /*----------------------- SPIx CR1 & CR2 Configuration ---------------------*/
139
-  /* Configure : SPI Mode, Communication Mode, Data size, Clock polarity and phase, NSS management,
140
-  Communication speed, First bit and CRC calculation state */
141
-  WRITE_REG(hspi->Instance->CR1, (hspi->Init.Mode | hspi->Init.Direction | hspi->Init.DataSize |
142
-                                  hspi->Init.CLKPolarity | hspi->Init.CLKPhase | (hspi->Init.NSS & SPI_CR1_SSM) |
143
-                                  hspi->Init.BaudRatePrescaler | hspi->Init.FirstBit  | hspi->Init.CRCCalculation) );
144
-
145
-  /* Configure : NSS management */
146
-  WRITE_REG(hspi->Instance->CR2, (((hspi->Init.NSS >> 16U) & SPI_CR2_SSOE) | hspi->Init.TIMode));
147
-
148
-  /*---------------------------- SPIx CRCPOLY Configuration ------------------*/
149
-  /* Configure : CRC Polynomial */
150
-  WRITE_REG(hspi->Instance->CRCPR, hspi->Init.CRCPolynomial);
151
-
152
-#if defined(SPI_I2SCFGR_I2SMOD)
153
-  /* Activate the SPI mode (Make sure that I2SMOD bit in I2SCFGR register is reset) */
154
-  CLEAR_BIT(hspi->Instance->I2SCFGR, SPI_I2SCFGR_I2SMOD);
155
-#endif /* SPI_I2SCFGR_I2SMOD */
156
-
157
-#if (USE_SPI_CRC != 0U)
158
-#if defined (STM32F101xE) || defined (STM32F103xE)
159
-  /* Check RevisionID value for identifying if Device is Rev Z (0x0001) in order to enable workaround for
160
-     CRC errors wrongly detected */
161
-  /* Pb is that ES_STM32F10xxCDE also identify an issue in Debug registers access while not in Debug mode.
162
-     Revision ID information is only available in Debug mode, so Workaround could not be implemented
163
-     to distinguish Rev Z devices (issue present) from more recent version (issue fixed).
164
-     So, in case of Revison Z F101 or F103 devices, below variable should be assigned to 1 */
165
-  uCRCErrorWorkaroundCheck = 0U;
166
-#else
167
-  uCRCErrorWorkaroundCheck = 0U;
168
-#endif /* STM32F101xE || STM32F103xE */
169
-#endif /* USE_SPI_CRC */
170
-
171
-  hspi->ErrorCode = HAL_SPI_ERROR_NONE;
172
-  hspi->State = HAL_SPI_STATE_READY;
173
-  
174
-  return HAL_OK;
175
-}
176
-
177
-/**
178
-  * @}
179
-  */
180
-
181
-/**
182
-  * @}
183
-  */
184
-
185
-/** @addtogroup SPI_Private_Functions
186
-  * @{
187
-  */
188
-#if (USE_SPI_CRC != 0U)
189
-/**
190
-  * @brief  Checks if encountered CRC error could be corresponding to wrongly detected errors 
191
-  *         according to SPI instance, Device type, and revision ID.
192
-  * @param  hspi: pointer to a SPI_HandleTypeDef structure that contains
193
-  *               the configuration information for SPI module.
194
-  * @retval CRC error validity (SPI_INVALID_CRC_ERROR or SPI_VALID_CRC_ERROR).  
195
-*/
196
-uint8_t SPI_ISCRCErrorValid(SPI_HandleTypeDef *hspi)
197
-{
198
-#if defined(STM32F101xE) || defined(STM32F103xE)
199
-  /* Check how to handle this CRC error (workaround to be applied or not) */
200
-  /* If CRC errors could be wrongly detected (issue 2.15.2 in STM32F10xxC/D/E silicon limitations ES (DocID14732 Rev 13) */
201
-  if((uCRCErrorWorkaroundCheck != 0U) && (hspi->Instance == SPI2))
202
-  {
203
-    if(hspi->Instance->RXCRCR == 0U)
204
-    {
205
-      return (SPI_INVALID_CRC_ERROR);
206
-    }
207
-  }
208
-  return (SPI_VALID_CRC_ERROR);
209
-#else
210
-  /* Prevent unused argument(s) compilation warning */
211
-  UNUSED(hspi);
212
-
213
-  return (SPI_VALID_CRC_ERROR);
214
-#endif
215
-}
216
-#endif /* USE_SPI_CRC */
217
-
218
-/**
219
-  * @}
220
-  */
221
-
222
-#endif /* HAL_SPI_MODULE_ENABLED */
223
-/**
224
-  * @}
225
-  */
226
-
227
-/**
228
-  * @}
229
-  */
230
-
231
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

+ 12 - 0
Inc/GPIO_SPI.h

@@ -0,0 +1,12 @@
1
+#include "main.h"
2
+
3
+
4
+extern uint8_t SPIReadByte(uint8_t addr);
5
+extern uint8_t SPIWriteByte(uint8_t addr, uint8_t data);
6
+extern uint8_t SPIGPIOTxRx(uint8_t addr, uint8_t data);
7
+extern void BLUECELL_SPI_Transmit(uint8_t data);
8
+extern uint8_t SpiRead(void);
9
+extern void SpiInOut(uint8_t addr_write);
10
+
11
+
12
+

+ 302 - 0
Inc/SX1276.h

@@ -0,0 +1,302 @@
1
+/**
2
+ * Author Wojciech Domski <Wojciech.Domski@gmail.com>
3
+ * www: www.Domski.pl
4
+ *
5
+ * work based on DORJI.COM sample code and
6
+ * https://github.com/realspinner/SX1276_LoRa
7
+ */
8
+
9
+#ifndef __SX1276_H__
10
+#define __SX1276_H__
11
+#include <stdint.h>
12
+#include <stdbool.h>
13
+#include "main.h"
14
+
15
+#define SX1276_MAX_PACKET	256
16
+#define SX1276_DEFAULT_TIMEOUT		3000
17
+
18
+//Error Coding rate (CR)setting
19
+#define SX1276_CR_4_5
20
+//#define SX1276_CR_4_6
21
+//#define SX1276_CR_4_7
22
+//#define SX1276_CR_4_8
23
+#ifdef   SX1276_CR_4_5
24
+#define SX1276_CR	0x01
25
+#else
26
+#ifdef   SX1276_CR_4_6
27
+#define SX1276_CR    0x02
28
+#else
29
+#ifdef   SX1276_CR_4_7
30
+#define SX1276_CR    0x03
31
+#else
32
+#ifdef   SX1276_CR_4_8
33
+#define SX1276_CR    0x04
34
+#endif
35
+#endif
36
+#endif
37
+#endif
38
+
39
+//CRC Enable
40
+#define SX1276_CRC_EN
41
+#ifdef  SX1276_CRC_EN
42
+#define SX1276_CRC   0x01
43
+#else
44
+#define SX1276_CRC   0x00
45
+#endif
46
+//RFM98 Internal registers Address
47
+/********************LoRa mode***************************/
48
+#define LR_RegFifo                                  0x00
49
+// Common settings
50
+#define LR_RegOpMode                                0x01
51
+#define LR_RegFrMsb                                 0x06
52
+#define LR_RegFrMid                                 0x07
53
+#define LR_RegFrLsb                                 0x08
54
+// Tx settings
55
+#define LR_RegPaConfig                              0x09
56
+#define LR_RegPaRamp                                0x0A
57
+#define LR_RegOcp                                   0x0B
58
+// Rx settings
59
+#define LR_RegLna                                   0x0C
60
+// LoRa registers
61
+#define LR_RegFifoAddrPtr                           0x0D
62
+#define LR_RegFifoTxBaseAddr                        0x0E
63
+#define LR_RegFifoRxBaseAddr                        0x0F
64
+#define LR_RegFifoRxCurrentaddr                     0x10
65
+#define LR_RegIrqFlagsMask                          0x11
66
+#define LR_RegIrqFlags                              0x12
67
+#define LR_RegRxNbBytes                             0x13
68
+#define LR_RegRxHeaderCntValueMsb                   0x14
69
+#define LR_RegRxHeaderCntValueLsb                   0x15
70
+#define LR_RegRxPacketCntValueMsb                   0x16
71
+#define LR_RegRxPacketCntValueLsb                   0x17
72
+#define LR_RegModemStat                             0x18
73
+#define LR_RegPktSnrValue                           0x19
74
+#define LR_RegPktRssiValue                          0x1A
75
+#define LR_RegRssiValue                             0x1B
76
+#define LR_RegHopChannel                            0x1C
77
+#define LR_RegModemConfig1                          0x1D
78
+#define LR_RegModemConfig2                          0x1E
79
+#define LR_RegSymbTimeoutLsb                        0x1F
80
+#define LR_RegPreambleMsb                           0x20
81
+#define LR_RegPreambleLsb                           0x21
82
+#define LR_RegPayloadLength                         0x22
83
+#define LR_RegMaxPayloadLength                      0x23
84
+#define LR_RegHopPeriod                             0x24
85
+#define LR_RegFifoRxByteAddr                        0x25
86
+// I/O settings
87
+#define REG_LR_DIOMAPPING1                          0x40
88
+#define REG_LR_DIOMAPPING2                          0x41
89
+// Version
90
+#define REG_LR_VERSION                              0x42
91
+// Additional settings
92
+#define REG_LR_PLLHOP                               0x44
93
+#define REG_LR_TCXO                                 0x4B
94
+#define REG_LR_PADAC                                0x4D
95
+#define REG_LR_FORMERTEMP                           0x5B
96
+#define REG_LR_AGCREF                               0x61
97
+#define REG_LR_AGCTHRESH1                           0x62
98
+#define REG_LR_AGCTHRESH2                           0x63
99
+#define REG_LR_AGCTHRESH3                           0x64
100
+
101
+/********************FSK/ook mode***************************/
102
+#define  RegFIFO                0x00
103
+#define  RegOpMode              0x01
104
+#define  RegBitRateMsb      	0x02
105
+#define  RegBitRateLsb      	0x03
106
+#define  RegFdevMsb             0x04
107
+#define  RegFdevLsb             0x05
108
+#define  RegFreqMsb             0x06
109
+#define  RegFreqMid             0x07
110
+#define  RegFreqLsb         	0x08
111
+#define  RegPaConfig            0x09
112
+#define  RegPaRamp              0x0a
113
+#define  RegOcp                 0x0b
114
+#define  RegLna                 0x0c
115
+#define  RegRxConfig            0x0d
116
+#define  RegRssiConfig      	0x0e
117
+#define  RegRssiCollision 		0x0f
118
+#define  RegRssiThresh      	0x10
119
+#define  RegRssiValue           0x11
120
+#define  RegRxBw                0x12
121
+#define  RegAfcBw               0x13
122
+#define  RegOokPeak             0x14
123
+#define  RegOokFix              0x15
124
+#define  RegOokAvg              0x16
125
+#define  RegAfcFei              0x1a
126
+#define  RegAfcMsb              0x1b
127
+#define  RegAfcLsb              0x1c
128
+#define  RegFeiMsb              0x1d
129
+#define  RegFeiLsb              0x1e
130
+#define  RegPreambleDetect  	0x1f
131
+#define  RegRxTimeout1      	0x20
132
+#define  RegRxTimeout2      	0x21
133
+#define  RegRxTimeout3      	0x22
134
+#define  RegRxDelay             0x23
135
+#define  RegOsc                 0x24
136
+#define  RegPreambleMsb     	0x25
137
+#define  RegPreambleLsb     	0x26
138
+#define  RegSyncConfig      	0x27
139
+#define  RegSyncValue1      	0x28
140
+#define  RegSyncValue2      	0x29
141
+#define  RegSyncValue3      	0x2a
142
+#define  RegSyncValue4      	0x2b
143
+#define  RegSyncValue5      	0x2c
144
+#define  RegSyncValue6      	0x2d
145
+#define  RegSyncValue7      	0x2e
146
+#define  RegSyncValue8      	0x2f
147
+#define  RegPacketConfig1       0x30
148
+#define  RegPacketConfig2       0x31
149
+#define  RegPayloadLength       0x32
150
+#define  RegNodeAdrs            0x33
151
+#define  RegBroadcastAdrs       0x34
152
+#define  RegFifoThresh      	0x35
153
+#define  RegSeqConfig1      	0x36
154
+#define  RegSeqConfig2      	0x37
155
+#define  RegTimerResol      	0x38
156
+#define  RegTimer1Coef      	0x39
157
+#define  RegTimer2Coef      	0x3a
158
+#define  RegImageCal            0x3b
159
+#define  RegTemp                0x3c
160
+#define  RegLowBat              0x3d
161
+#define  RegIrqFlags1           0x3e
162
+#define  RegIrqFlags2           0x3f
163
+#define  RegDioMapping1			0x40
164
+#define  RegDioMapping2			0x41
165
+#define  RegVersion				0x42
166
+#define  RegPllHop				0x44
167
+#define  RegPaDac				0x4d
168
+#define  RegBitRateFrac			0x5d
169
+
170
+/**********************************************************
171
+ **Parameter table define
172
+ **********************************************************/
173
+#define SX1276_917MHZ			0
174
+
175
+static const uint8_t SX1276_Frequency[1][3] = { { 0xE5, 0x40, 0x26 }, //916.9MHz
176
+		};/*°ø½Ä  :  61.035 * 0xE5 40 26    = 916.9Mhz
177
+                            (À̰ªÀÌ º¯¼ö)  */
178
+#define SX1276_POWER_20DBM		0
179
+#define SX1276_POWER_17DBM		1
180
+#define SX1276_POWER_14DBM		2
181
+#define SX1276_POWER_11DBM		3
182
+
183
+static const uint8_t SX1276_Power[4] = { 0xFF, //20dbm
184
+		0xFC, //17dbm
185
+		0xF9, //14dbm
186
+		0xF6, //11dbm
187
+		};
188
+
189
+#define SX1276_LORA_SF_6		0
190
+#define SX1276_LORA_SF_7		1
191
+#define SX1276_LORA_SF_8		2
192
+#define SX1276_LORA_SF_9		3
193
+#define SX1276_LORA_SF_10		4
194
+#define SX1276_LORA_SF_11		5
195
+#define SX1276_LORA_SF_12		6
196
+
197
+static const uint8_t SX1276_SpreadFactor[7] = { 6, 7, 8, 9, 10, 11, 12 };
198
+
199
+#define	SX1276_LORA_BW_7_8KHZ		0
200
+#define	SX1276_LORA_BW_10_4KHZ		1
201
+#define	SX1276_LORA_BW_15_6KHZ		2
202
+#define	SX1276_LORA_BW_20_8KHZ		3
203
+#define	SX1276_LORA_BW_31_2KHZ		4
204
+#define	SX1276_LORA_BW_41_7KHZ		5
205
+#define	SX1276_LORA_BW_62_5KHZ		6
206
+#define	SX1276_LORA_BW_125KHZ		7
207
+#define	SX1276_LORA_BW_250KHZ		8
208
+#define	SX1276_LORA_BW_500KHZ		9
209
+
210
+static const uint8_t SX1276_LoRaBandwidth[10] = { 0, //   7.8KHz,
211
+		1, //  10.4KHz,
212
+		2, //  15.6KHz,
213
+		3, //  20.8KHz,
214
+		4, //  31.2KHz,
215
+		5, //  41.7KHz,
216
+		6, //  62.5KHz,
217
+		7, // 125.0KHz,
218
+		8, // 250.0KHz,
219
+		9  // 500.0KHz
220
+		};
221
+
222
+typedef enum _SX1276_STATUS {
223
+	SLEEP, STANDBY, TX, RX
224
+} SX1276_Status_t;
225
+
226
+typedef struct {
227
+	int pin;
228
+	void * port;
229
+} SX1276_hw_dio_t;
230
+
231
+typedef struct {
232
+	SX1276_hw_dio_t reset;
233
+	SX1276_hw_dio_t dio0;
234
+	SX1276_hw_dio_t nss;
235
+	void * spi;
236
+} SX1276_hw_t;
237
+
238
+typedef struct {
239
+	SX1276_hw_t * hw;
240
+
241
+	uint8_t frequency;
242
+	uint8_t power;
243
+	uint8_t LoRa_Rate;
244
+	uint8_t LoRa_BW;
245
+	uint8_t packetLength;
246
+
247
+	SX1276_Status_t status;
248
+
249
+	uint8_t rxBuffer[SX1276_MAX_PACKET];
250
+	uint8_t readBytes;
251
+} SX1276_t;
252
+
253
+//hardware
254
+__weak void SX1276_hw_init(SX1276_hw_t * hw);
255
+__weak void SX1276_hw_SetNSS(SX1276_hw_t * hw, int value);
256
+__weak void SX1276_hw_Reset(SX1276_hw_t * hw);
257
+__weak void SX1276_hw_SPICommand(SX1276_hw_t * hw, uint8_t cmd);
258
+__weak uint8_t SX1276_hw_SPIReadByte(SX1276_hw_t * hw);
259
+__weak void SX1276_hw_DelayMs(uint32_t msec);
260
+__weak int SX1276_hw_GetDIO0(SX1276_hw_t * hw);
261
+
262
+//logic
263
+
264
+uint8_t SX1276_SPIRead(SX1276_t * module, uint8_t addr);
265
+void SX1276_SPIWrite(SX1276_t * module, uint8_t addr, uint8_t cmd);
266
+void SX1276_SPIBurstRead(SX1276_t * module, uint8_t addr, uint8_t *rxBuf,
267
+		uint8_t length);
268
+void SX1276_SPIBurstWrite(SX1276_t * module, uint8_t addr, uint8_t *txBuf,
269
+		uint8_t length);
270
+void SX1276_DIO0_InterruptHandler(SX1276_t * module);
271
+
272
+void SX1276_config(SX1276_t * module, uint8_t frequency, uint8_t power,
273
+		uint8_t LoRa_Rate, uint8_t LoRa_BW);
274
+void SX1276_defaultConfig(SX1276_t * module);
275
+
276
+void SX1276_entryLoRa(SX1276_t * module);
277
+void SX1276_clearLoRaIrq(SX1276_t * module);
278
+int SX1276_LoRaEntryRx(SX1276_t * module, uint8_t length, uint32_t timeout);
279
+uint8_t SX1276_LoRaRxPacket(SX1276_t * module);
280
+int SX1276_LoRaEntryTx(SX1276_t * module, uint8_t length, uint32_t timeout);
281
+int SX1276_LoRaTxModeSet(SX1276_t * module, uint8_t length, uint32_t timeout);
282
+int SX1276_LoRaRxModeSet(SX1276_t * module, uint8_t length, uint32_t timeout);
283
+
284
+int SX1276_LoRaTxPacket(SX1276_t * module, uint8_t *txBuf, uint8_t length,
285
+		uint32_t timeout);
286
+
287
+void SX1276_begin(SX1276_t * module, uint8_t frequency, uint8_t power,
288
+		uint8_t LoRa_Rate, uint8_t LoRa_BW, uint8_t packetLength);
289
+
290
+int SX1276_transmit(SX1276_t * module, uint8_t *txBuf, uint8_t length,
291
+		uint32_t timeout);
292
+int SX1276_(SX1276_t * module, uint8_t length, uint32_t timeoutT);
293
+uint8_t SX1276_available(SX1276_t * module);
294
+uint8_t SX1276_read(SX1276_t * module, uint8_t *rxBuf, uint8_t length);
295
+
296
+uint8_t SX1276_RSSI_LoRa(SX1276_t * module);
297
+uint8_t SX1276_RSSI(SX1276_t * module);
298
+
299
+void SX1276_standby(SX1276_t * module);
300
+void SX1276_sleep(SX1276_t * module);
301
+uint8_t SX1276_SPIIDRead(SX1276_t * module, uint8_t addr);
302
+#endif

+ 1 - 0
Inc/Uart.h

@@ -9,6 +9,7 @@ extern void Uart1_Data_Send(uint8_t* data,uint8_t size);
9 9
 extern int _write (int file, uint8_t *ptr, uint16_t len);
10 10
 extern void Uart_dataCheck(uint8_t Usart_Num ,uint8_t* cnt);
11 11
 extern void UartDataBufferCheck(void);
12
+extern void QueueCheck(uint8_t Usart_Num,uint8_t* header,uint8_t* tail);
12 13
 
13 14
 #define USART_CNT 2
14 15
 #define buf_size 100

+ 9 - 0
Inc/main.h

@@ -58,6 +58,7 @@ extern "C" {
58 58
 #include "core_cm3.h"
59 59
 #include <stdint.h>
60 60
 #include "Uart.h"
61
+#include "SX1276.h"
61 62
 /* USER CODE END Includes */
62 63
 
63 64
 /* Exported types ------------------------------------------------------------*/
@@ -174,6 +175,8 @@ extern uint8_t rx3_data[1];
174 175
 #define SENSOR_EN7_GPIO_Port GPIOC
175 176
 #define SENSOR_EN8_Pin GPIO_PIN_8
176 177
 #define SENSOR_EN8_GPIO_Port GPIOA
178
+#define SX1276_NSS_Pin GPIO_PIN_15
179
+#define SX1276_NSS_GPIO_Port GPIOA
177 180
 #define LED_CH1_Pin GPIO_PIN_10
178 181
 #define LED_CH1_GPIO_Port GPIOC
179 182
 #define LED_CH2_Pin GPIO_PIN_11
@@ -182,6 +185,12 @@ extern uint8_t rx3_data[1];
182 185
 #define LED_CH3_GPIO_Port GPIOC
183 186
 #define LED_CH4_Pin GPIO_PIN_2
184 187
 #define LED_CH4_GPIO_Port GPIOD
188
+#define SX1276_CLK_Pin GPIO_PIN_3
189
+#define SX1276_CLK_GPIO_Port GPIOB
190
+#define SX1276_MISO_Pin GPIO_PIN_4
191
+#define SX1276_MISO_GPIO_Port GPIOB
192
+#define SX1276_MOSI_Pin GPIO_PIN_5
193
+#define SX1276_MOSI_GPIO_Port GPIOB
185 194
 #define LED_CH5_Pin GPIO_PIN_6
186 195
 #define LED_CH5_GPIO_Port GPIOB
187 196
 #define LED_CH6_Pin GPIO_PIN_7

+ 1 - 1
Inc/stm32f1xx_hal_conf.h

@@ -76,7 +76,7 @@
76 76
 /*#define HAL_MMC_MODULE_ENABLED   */
77 77
 /*#define HAL_SDRAM_MODULE_ENABLED   */
78 78
 /*#define HAL_SMARTCARD_MODULE_ENABLED   */
79
-#define HAL_SPI_MODULE_ENABLED
79
+/*#define HAL_SPI_MODULE_ENABLED   */
80 80
 /*#define HAL_SRAM_MODULE_ENABLED   */
81 81
 #define HAL_TIM_MODULE_ENABLED
82 82
 #define HAL_UART_MODULE_ENABLED

+ 18 - 21
STM32F103_RGBController.ioc

@@ -5,12 +5,11 @@ Mcu.Family=STM32F1
5 5
 Mcu.IP0=I2C2
6 6
 Mcu.IP1=NVIC
7 7
 Mcu.IP2=RCC
8
-Mcu.IP3=SPI1
9
-Mcu.IP4=SYS
10
-Mcu.IP5=TIM6
11
-Mcu.IP6=USART1
12
-Mcu.IP7=USART2
13
-Mcu.IPNb=8
8
+Mcu.IP3=SYS
9
+Mcu.IP4=TIM6
10
+Mcu.IP5=USART1
11
+Mcu.IP6=USART2
12
+Mcu.IPNb=7
14 13
 Mcu.Name=STM32F103R(C-D-E)Tx
15 14
 Mcu.Package=LQFP64
16 15
 Mcu.Pin0=PC15-OSC32_OUT
@@ -80,9 +79,10 @@ PA13.Locked=true
80 79
 PA13.Signal=SYS_JTMS-SWDIO
81 80
 PA14.Locked=true
82 81
 PA14.Signal=SYS_JTCK-SWCLK
82
+PA15.GPIOParameters=GPIO_Label
83
+PA15.GPIO_Label=SX1276_NSS
83 84
 PA15.Locked=true
84
-PA15.Mode=NSS_Signal_Hard_Output
85
-PA15.Signal=SPI1_NSS
85
+PA15.Signal=GPIO_Output
86 86
 PA2.Mode=Asynchronous
87 87
 PA2.Signal=USART2_TX
88 88
 PA3.Mode=Asynchronous
@@ -134,15 +134,18 @@ PB15.GPIOParameters=GPIO_Label
134 134
 PB15.GPIO_Label=SENSOR_EN3
135 135
 PB15.Locked=true
136 136
 PB15.Signal=GPIO_Output
137
+PB3.GPIOParameters=GPIO_Label
138
+PB3.GPIO_Label=SX1276_CLK
137 139
 PB3.Locked=true
138
-PB3.Mode=Full_Duplex_Master
139
-PB3.Signal=SPI1_SCK
140
+PB3.Signal=GPIO_Output
141
+PB4.GPIOParameters=GPIO_Label
142
+PB4.GPIO_Label=SX1276_MISO
140 143
 PB4.Locked=true
141
-PB4.Mode=Full_Duplex_Master
142
-PB4.Signal=SPI1_MISO
144
+PB4.Signal=GPIO_Input
145
+PB5.GPIOParameters=GPIO_Label
146
+PB5.GPIO_Label=SX1276_MOSI
143 147
 PB5.Locked=true
144
-PB5.Mode=Full_Duplex_Master
145
-PB5.Signal=SPI1_MOSI
148
+PB5.Signal=GPIO_Output
146 149
 PB6.GPIOParameters=GPIO_Label
147 150
 PB6.GPIO_Label=LED_CH5
148 151
 PB6.Locked=true
@@ -242,7 +245,7 @@ ProjectManager.StackSize=0x400
242 245
 ProjectManager.TargetToolchain=TrueSTUDIO
243 246
 ProjectManager.ToolChainLocation=
244 247
 ProjectManager.UnderRoot=true
245
-ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-SystemClock_Config-RCC-false-HAL-false,3-MX_TIM6_Init-TIM6-false-HAL-true,4-MX_USART1_UART_Init-USART1-false-HAL-true,5-MX_USART2_UART_Init-USART2-false-HAL-true,6-MX_SPI1_Init-SPI1-false-HAL-true,7-MX_I2C2_Init-I2C2-false-HAL-true
248
+ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-SystemClock_Config-RCC-false-HAL-false,3-MX_TIM6_Init-TIM6-false-HAL-true,4-MX_USART1_UART_Init-USART1-false-HAL-true,5-MX_USART2_UART_Init-USART2-false-HAL-true,6-MX_I2C2_Init-I2C2-false-HAL-true
246 249
 RCC.ADCFreqValue=8000000
247 250
 RCC.AHBFreq_Value=16000000
248 251
 RCC.APB1CLKDivider=RCC_HCLK_DIV2
@@ -267,12 +270,6 @@ RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK
267 270
 RCC.TimSysFreq_Value=16000000
268 271
 RCC.USBFreq_Value=16000000
269 272
 RCC.VCOOutput2Freq_Value=8000000
270
-SPI1.CalculateBaudRate=8.0 MBits/s
271
-SPI1.Direction=SPI_DIRECTION_2LINES
272
-SPI1.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate,VirtualNSS
273
-SPI1.Mode=SPI_MODE_MASTER
274
-SPI1.VirtualNSS=VM_NSSHARD
275
-SPI1.VirtualType=VM_MASTER
276 273
 TIM6.IPParameters=Prescaler,Period
277 274
 TIM6.Period=10-1
278 275
 TIM6.Prescaler=1600-1

+ 298 - 0
Src/GPIO_SPI.c

@@ -0,0 +1,298 @@
1
+/*
2
+개념
3
+Falling Edge 
4
+ 
5
+1  LOW CS
6
+2. HIGH MOSI
7
+3. LOW CLK
8
+
9
+4. LOOP
10
+   int i;
11
+   for (i = 0; i < 7; i++)
12
+   {
13
+	   GPIO_MOSI = DATA(i);
14
+	   GPIO_MISO = DATA(i);
15
+	   HIGH CLK
16
+	   LOW  CLK
17
+   }
18
+
19
+5. HIGH MOSI
20
+6. HIGH CS
21
+
22
+
23
+소스코드 예졔1
24
+*/
25
+#include "GPIO_SPI.h"
26
+#define SDA_SETUP_TIME 4
27
+#define CS_SETUP_TIME  SDA_SETUP_TIME
28
+// LSB 방식
29
+
30
+uint8_t  dummy_data;
31
+/*=========== GPIO Port F ===============*/
32
+#define Lora_NCS_CLR        HAL_GPIO_WritePin(GPIOB,SX1276_NSS_Pin,RESET)
33
+#define Lora_NCS_SET        HAL_GPIO_WritePin(GPIOB,SX1276_NSS_Pin,SET)
34
+
35
+#define Lora_SCLK_CLR        HAL_GPIO_WritePin(GPIOB,SX1276_CLK_Pin,RESET)
36
+#define Lora_SCLK_SET        HAL_GPIO_WritePin(GPIOB,SX1276_CLK_Pin,SET)
37
+//
38
+//#define Lora_MISO_CLR        HAL_GPIO_WritePin(GPIOB,SX1276_MISO_Pin,RESET)
39
+//#define Lora_MISO_SET        HAL_GPIO_WritePin(GPIOB,SX1276_MISO_Pin,SET)
40
+
41
+#define Lora_MOSI_CLR        HAL_GPIO_WritePin(GPIOB,SX1276_MOSI_Pin,RESET)
42
+#define Lora_MOSI_SET        HAL_GPIO_WritePin(GPIOB,SX1276_MOSI_Pin,SET)
43
+
44
+#define Lora_MISO_READ       HAL_GPIO_ReadPin(GPIOB,SX1276_MISO_Pin)
45
+
46
+
47
+#define Read_SX1278_SDO()  Lora_MISO_READ
48
+#define Set_SX1278_SDI()   Lora_MOSI_SET
49
+#define Set_SX1278_SCK()   Lora_SCLK_SET
50
+ 
51
+#define Clr_SX1278_SDI()   Lora_MOSI_CLR
52
+#define Clr_SX1278_SCK()   Lora_SCLK_CLR
53
+
54
+uint8_t SPIReadByte(uint8_t addr);
55
+uint8_t SPIWriteByte(uint8_t addr, uint8_t data);
56
+uint8_t SPIGPIOTxRx(uint8_t addr, uint8_t data);
57
+
58
+void SPI_Delay(int ustime)
59
+{
60
+	volatile int i;
61
+	volatile int k;
62
+	for(i = 0; i < ustime; i++)
63
+	{
64
+		k++;
65
+	}
66
+}
67
+
68
+#if 1 // PYJ.2019.04.02_BEGIN -- 
69
+#ifdef STM32F1
70
+void SpiInOut(uint8_t addr_write)
71
+{
72
+ 
73
+    uint8_t i;
74
+
75
+    for (i = 0; i < 8; i++)
76
+    {
77
+        SPI_Delay(SDA_SETUP_TIME);
78
+
79
+        Clr_SX1278_SCK();
80
+        if (addr_write & 0x80)
81
+        {
82
+            Set_SX1278_SDI();
83
+        }
84
+        else
85
+        {
86
+            Clr_SX1278_SDI();
87
+        }
88
+        SPI_Delay(SDA_SETUP_TIME);
89
+
90
+        Set_SX1278_SCK();
91
+        addr_write = addr_write << 1;
92
+        SPI_Delay(SDA_SETUP_TIME);
93
+    }
94
+    Clr_SX1278_SCK();
95
+ 
96
+}
97
+uint8_t SpiRead(void)
98
+{
99
+ 
100
+    uint8_t i = 0,Readdata = 0;
101
+ 
102
+    for (i = 0; i < 8; i++)   
103
+    {
104
+        Readdata <<= 1;
105
+        SPI_Delay(SDA_SETUP_TIME);
106
+        Set_SX1278_SCK();
107
+        if (Read_SX1278_SDO())
108
+            Readdata |= 0x01;
109
+        else
110
+            Readdata &= 0xfe;
111
+        SPI_Delay(SDA_SETUP_TIME);
112
+        Clr_SX1278_SCK();
113
+    }
114
+    
115
+    return Readdata;
116
+}
117
+#if 1 // PYJ.2019.04.02_BEGIN -- 
118
+uint8_t SPIGPIOTxRx(uint8_t addr, uint8_t data){
119
+    uint8_t readdata;
120
+     Lora_NCS_CLR;
121
+    SpiInOut(addr);
122
+    SpiInOut(data);
123
+    readdata = SpiRead(); 
124
+     Lora_NCS_SET;
125
+    return readdata;
126
+}
127
+#endif // PYJ.2019.04.02_END -- 
128
+
129
+#endif
130
+
131
+
132
+//#else
133
+#if 0 // PYJ.2019.04.02_BEGIN -- 
134
+void BLUECELL_SPI_Transmit(uint8_t data) // int 가 16Bit 일때
135
+{
136
+	int i;
137
+	Lora_MOSI_SET; 
138
+//	Lora_NCS_SET;
139
+
140
+	Lora_SCLK_CLR;  // CLK Low
141
+//	Lora_NCS_CLR;   // 
142
+    
143
+    SPI_Delay(CS_SETUP_TIME);
144
+	for(i = 0; i < 8; i++)
145
+	{
146
+		Lora_SCLK_CLR;   // CLK LOW
147
+		SPI_Delay(SDA_SETUP_TIME);
148
+		if(data & 0x80) {
149
+			Lora_MOSI_SET;
150
+		}
151
+		else {
152
+			Lora_MOSI_CLR;
153
+		}
154
+
155
+		SPI_Delay(SDA_SETUP_TIME);
156
+		data <<= 1 ;
157
+		Lora_SCLK_SET;
158
+		SPI_Delay(SDA_SETUP_TIME);
159
+	}
160
+//	Lora_NCS_SET;
161
+//	Lora_MOSI_SET;
162
+//	SPI_Delay(SDA_SETUP_TIME);
163
+}
164
+#else
165
+void BLUECELL_SPI_Transmit(uint8_t data) {
166
+    SpiInOut(data);
167
+}
168
+
169
+#endif // PYJ.2019.04.02_END -- 
170
+#if 0 // PYJ.2019.04.01_BEGIN -- 
171
+
172
+// MSB 방식
173
+void SOUT(int data) // int 가 16Bit 일때
174
+{
175
+	int i;
176
+	uint16_t mask = 0x8000;
177
+	SET_SPI_MOSI; 
178
+	SET_SPI_CS;
179
+
180
+	CLR_SPI_SCL;  // CLK Low
181
+	CLR_SPI_CS;   // 
182
+ 
183
+    SPI_Delay(CS_SETUP_TIME);
184
+
185
+	for(i = 0; i < 16; i++)
186
+	{
187
+		CLR_SPI_SCL;   // CLK LOW
188
+		SPI_Delay(SCL_LOW_TIME);
189
+		if(data & mask)) {
190
+			SET_SPI_SDA;
191
+		}
192
+		else {
193
+			CLR_SPI_SDA;
194
+		}
195
+
196
+		SPI_Delay(SDA_SETUP_TIME);
197
+		mask >> =1;
198
+		SET_SPI_SCL;
199
+		SPI_Delay(SCL_HIGH_TIME);
200
+	}
201
+	SET_SPI_CS;
202
+	SET_SPI_SDA;
203
+	SPI_Delay(CS_PULSE_TIME);
204
+}
205
+#endif // PYJ.2019.04.01_END -- 
206
+
207
+
208
+
209
+
210
+//소스 예제 2 Read 시는 Addr 의 취상위비트가 0, Write 시에는 취상위비트가 1
211
+
212
+
213
+uint8_t SPIReadByte(uint8_t addr)
214
+{
215
+    /* Read Command */
216
+    uint8_t readdata;
217
+     Lora_NCS_CLR;
218
+    SpiInOut(addr);
219
+    readdata = SpiRead(); 
220
+    Lora_NCS_SET;
221
+    return readdata;
222
+}
223
+
224
+uint8_t SPIWriteByte(uint8_t addr, uint8_t data)
225
+{
226
+    /* Write Command */
227
+    addr |= 0x80;
228
+    dummy_data = SPIGPIOTxRx(addr, data);
229
+
230
+    //return SPIGPIOTxRx(data);
231
+    return dummy_data;
232
+}
233
+
234
+#if 0 // PYJ.2019.04.02_BEGIN -- 
235
+uint8_t SPIGPIOTxRx(uint8_t addr, uint8_t data)
236
+{
237
+    uint8_t i;
238
+    uint8_t rx;
239
+    uint8_t mask;
240
+    uint16_t wdata, wmask;
241
+    
242
+    rx         = 0;
243
+    mask       = 0x80;
244
+    wmask      = 0x8000;
245
+
246
+    Lora_SCLK_CLR;
247
+    Lora_NCS_CLR;
248
+          
249
+    if ( addr & 0x80 ) {
250
+
251
+      wdata = (uint16_t)(addr << 8) | data;
252
+      // write
253
+      for ( i = 0 ; i < 16 ; i++ ) {
254
+
255
+          if ( wdata & wmask ) Lora_MOSI_SET;
256
+          else                 Lora_MOSI_CLR;
257
+    
258
+          Lora_SCLK_SET;
259
+
260
+          if ( Lora_MISO_READ ) rx |= wmask;
261
+          else              rx &= ~wmask;
262
+
263
+          wmask <<= 1;
264
+
265
+          Lora_SCLK_CLR;
266
+
267
+      }      
268
+    } 
269
+      else {
270
+        
271
+      // read
272
+      for ( i = 0 ; i < 8 ; i++ ) {
273
+          Lora_SCLK_SET;
274
+          SPI_Delay(SDA_SETUP_TIME);
275
+          if ( addr & mask ) Lora_MOSI_SET;
276
+          else               Lora_MOSI_CLR;
277
+          SPI_Delay(SDA_SETUP_TIME);
278
+          Lora_SCLK_CLR ;
279
+          mask <<= 1;
280
+      }
281
+      Lora_NCS_SET;
282
+       for ( i = 0 ; i < 8 ; i++ ){    
283
+           Lora_SCLK_SET;
284
+          if ( Lora_MISO_READ ) rx |= mask;
285
+          else              rx &= ~mask;
286
+          Lora_SCLK_CLR ;
287
+       }
288
+    }
289
+
290
+    Lora_NCS_SET;
291
+    Lora_SCLK_CLR;
292
+    Lora_MOSI_CLR;
293
+
294
+    return rx;
295
+}
296
+#endif // PYJ.2019.04.02_END -- 
297
+#endif // PYJ.2019.04.02_END -- 
298
+

+ 371 - 0
Src/SX1276.c

@@ -0,0 +1,371 @@
1
+/**
2
+ * Author Wojciech Domski <Wojciech.Domski@gmail.com>
3
+ * www: www.Domski.pl
4
+ *
5
+ * work based on DORJI.COM sample code and
6
+ * https://github.com/realspinner/SX1276_LoRa
7
+ */
8
+
9
+#include "SX1276.h"
10
+#include <string.h>
11
+
12
+//#include "gpio.h"
13
+//#include "spi.h"
14
+
15
+//////////////////////////////////
16
+// logic
17
+//////////////////////////////////
18
+
19
+__weak void SX1276_hw_init(SX1276_hw_t * hw) {
20
+	SX1276_hw_SetNSS(hw, 1);
21
+	HAL_GPIO_WritePin(hw->reset.port, hw->reset.pin, GPIO_PIN_SET);
22
+}
23
+
24
+__weak void SX1276_hw_SetNSS(SX1276_hw_t * hw, int value) {
25
+	HAL_GPIO_WritePin(hw->nss.port, hw->nss.pin,
26
+			(value == 1) ? GPIO_PIN_SET : GPIO_PIN_RESET);
27
+}
28
+
29
+__weak void SX1276_hw_Reset(SX1276_hw_t * hw) {
30
+	SX1276_hw_SetNSS(hw, 1);
31
+	HAL_GPIO_WritePin(hw->reset.port, hw->reset.pin, GPIO_PIN_RESET);
32
+
33
+	SX1276_hw_DelayMs(1);
34
+
35
+	HAL_GPIO_WritePin(hw->reset.port, hw->reset.pin, GPIO_PIN_SET);
36
+
37
+	SX1276_hw_DelayMs(100);
38
+}
39
+
40
+#if 0 // PYJ.2019.04.01_BEGIN -- 
41
+__weak void SX1276_hw_SPICommand(SX1276_hw_t * hw, uint8_t cmd) {
42
+	SX1276_hw_SetNSS(hw, 0);
43
+	HAL_SPI_Transmit(hw->spi, &cmd, 1, 1000);
44
+	while (HAL_SPI_GetState(hw->spi) != HAL_SPI_STATE_READY)
45
+		;
46
+}
47
+#endif // PYJ.2019.04.01_END -- 
48
+void SX1276_hw_SPICommand(SX1276_hw_t * hw, uint8_t cmd) {
49
+	SX1276_hw_SetNSS(hw, 0);
50
+	BLUECELL_SPI_Transmit(cmd);
51
+}
52
+
53
+#if 0 // PYJ.2019.04.01_BEGIN -- 
54
+__weak uint8_t SX1276_hw_SPIReadByte(SX1276_hw_t * hw) {
55
+	uint8_t txByte = 0x00;
56
+	uint8_t rxByte = 0x00;
57
+
58
+	SX1276_hw_SetNSS(hw, 0);
59
+	HAL_SPI_TransmitReceive(hw->spi, &txByte, &rxByte, 1, 1000);
60
+	return rxByte;
61
+}
62
+#endif // PYJ.2019.04.01_END -- 
63
+uint8_t SX1276_hw_SPIReadByte(SX1276_hw_t * hw) {
64
+	uint8_t txByte = 0x00;
65
+	uint8_t rxByte = 0x00;
66
+
67
+	SX1276_hw_SetNSS(hw, 0);
68
+//	HAL_SPI_TransmitReceive(hw->spi, &txByte, &rxByte, 1, 1000);
69
+    rxByte = SpiRead();
70
+	return rxByte;
71
+}
72
+
73
+__weak void SX1276_hw_DelayMs(uint32_t msec) {
74
+	HAL_Delay(msec);
75
+}
76
+
77
+__weak int SX1276_hw_GetDIO0(SX1276_hw_t * hw) {
78
+	return (HAL_GPIO_ReadPin(hw->dio0.port, hw->dio0.pin) == GPIO_PIN_SET);
79
+}
80
+
81
+//////////////////////////////////
82
+// logic
83
+//////////////////////////////////
84
+
85
+uint8_t SX1276_SPIRead(SX1276_t * module, uint8_t addr) {
86
+	uint8_t tmp;
87
+	SX1276_hw_SPICommand(module->hw, addr);
88
+	tmp = SX1276_hw_SPIReadByte(module->hw);
89
+	SX1276_hw_SetNSS(module->hw, 1);
90
+	return tmp;
91
+}
92
+uint8_t SX1276_SPIIDRead(SX1276_t * module, uint8_t addr) {
93
+	uint8_t tmp;
94
+	SX1276_hw_SPICommand(module->hw, addr);
95
+	tmp = SX1276_hw_SPIReadByte(module->hw);
96
+	SX1276_hw_SetNSS(module->hw, 1);
97
+	return tmp;
98
+}
99
+
100
+void SX1276_SPIWrite(SX1276_t * module, uint8_t addr, uint8_t cmd) {
101
+	SX1276_hw_SetNSS(module->hw, 0);
102
+	SX1276_hw_SPICommand(module->hw, addr | 0x80);
103
+	SX1276_hw_SPICommand(module->hw, cmd);
104
+//    SPIGPIOTxRx(addr | 0x80,cmd);
105
+
106
+	SX1276_hw_SetNSS(module->hw, 1);
107
+}
108
+
109
+void SX1276_SPIBurstRead(SX1276_t * module, uint8_t addr, uint8_t* rxBuf,
110
+		uint8_t length) {
111
+	uint8_t i;
112
+	if (length <= 1) {
113
+		return;
114
+	} else {
115
+		SX1276_hw_SetNSS(module->hw, 0);
116
+		SX1276_hw_SPICommand(module->hw, addr);
117
+		//printf("Test Data:");
118
+		for (i = 0; i < length; i++) {
119
+			rxBuf[i] = SX1276_hw_SPIReadByte(module->hw);
120
+			//printf("%02x ",rxBuf[i]);
121
+		}
122
+		//printf("\n");
123
+		SX1276_hw_SetNSS(module->hw, 1);
124
+	}
125
+}
126
+
127
+void SX1276_SPIBurstWrite(SX1276_t * module, uint8_t addr, uint8_t* txBuf,
128
+		uint8_t length) {
129
+	uint8_t i;
130
+	if (length <= 1) {
131
+		return;
132
+	} else {
133
+		SX1276_hw_SetNSS(module->hw, 0);
134
+		SX1276_hw_SPICommand(module->hw, addr | 0x80);
135
+		for (i = 0; i < length; i++) {
136
+			SX1276_hw_SPICommand(module->hw, txBuf[i]);
137
+		}
138
+		SX1276_hw_SetNSS(module->hw, 1);
139
+	}
140
+}
141
+void SX1276_defaultConfig(SX1276_t * module) {
142
+	SX1276_config(module, module->frequency, module->power, module->LoRa_Rate,
143
+			module->LoRa_BW);
144
+}
145
+
146
+void SX1276_config(SX1276_t * module, uint8_t frequency, uint8_t power,
147
+		uint8_t LoRa_Rate, uint8_t LoRa_BW) {
148
+	SX1276_sleep(module); //Change modem mode Must in Sleep mode
149
+	SX1276_hw_DelayMs(15);
150
+
151
+	SX1276_entryLoRa(module);
152
+	//SX1276_SPIWrite(module, 0x5904); //?? Change digital regulator form 1.6V to 1.47V: see errata note
153
+
154
+	SX1276_SPIBurstWrite(module, LR_RegFrMsb,
155
+			(uint8_t*) SX1276_Frequency[frequency], 3); //setting  frequency parameter
156
+
157
+	//setting base parameter
158
+	SX1276_SPIWrite(module, LR_RegPaConfig, SX1276_Power[power]); //Setting output power parameter
159
+
160
+	SX1276_SPIWrite(module, LR_RegOcp, 0x0B);			//RegOcp,Close Ocp
161
+	SX1276_SPIWrite(module, LR_RegLna, 0x23);		//RegLNA,High & LNA Enable
162
+	if (SX1276_SpreadFactor[LoRa_Rate] == 6) {	//SFactor=6
163
+		uint8_t tmp;
164
+		SX1276_SPIWrite(module,
165
+		LR_RegModemConfig1,
166
+				((SX1276_LoRaBandwidth[LoRa_BW] << 4) + (SX1276_CR << 1) + 0x01)); //Implicit Enable CRC Enable(0x02) & Error Coding rate 4/5(0x01), 4/6(0x02), 4/7(0x03), 4/8(0x04)
167
+
168
+		SX1276_SPIWrite(module,
169
+		LR_RegModemConfig2,
170
+				((SX1276_SpreadFactor[LoRa_Rate] << 4) + (SX1276_CRC << 2)
171
+						+ 0x03));
172
+
173
+		tmp = SX1276_SPIRead(module, 0x31);
174
+		tmp &= 0xF8;
175
+		tmp |= 0x05;
176
+		SX1276_SPIWrite(module, 0x31, tmp);
177
+		SX1276_SPIWrite(module, 0x37, 0x0C);
178
+	} else {
179
+		SX1276_SPIWrite(module,
180
+		LR_RegModemConfig1,
181
+				((SX1276_LoRaBandwidth[LoRa_BW] << 4) + (SX1276_CR << 1) + 0x00)); //Explicit Enable CRC Enable(0x02) & Error Coding rate 4/5(0x01), 4/6(0x02), 4/7(0x03), 4/8(0x04)
182
+
183
+		SX1276_SPIWrite(module,
184
+		LR_RegModemConfig2,
185
+				((SX1276_SpreadFactor[LoRa_Rate] << 4) + (SX1276_CRC << 2)
186
+						+ 0x03)); //SFactor &  LNA gain set by the internal AGC loop
187
+	}
188
+
189
+	SX1276_SPIWrite(module, LR_RegSymbTimeoutLsb, 0xFF); //RegSymbTimeoutLsb Timeout = 0x3FF(Max)
190
+	SX1276_SPIWrite(module, LR_RegPreambleMsb, 0x00); //RegPreambleMsb
191
+	SX1276_SPIWrite(module, LR_RegPreambleLsb, 12); //RegPreambleLsb 8+4=12byte Preamble
192
+	SX1276_SPIWrite(module, REG_LR_DIOMAPPING2, 0x01); //RegDioMapping2 DIO5=00, DIO4=01
193
+	module->readBytes = 0;
194
+	SX1276_standby(module); //Entry standby mode
195
+}
196
+
197
+void SX1276_standby(SX1276_t * module) {
198
+	SX1276_SPIWrite(module, LR_RegOpMode, 0x09);
199
+	module->status = STANDBY;
200
+}
201
+
202
+void SX1276_sleep(SX1276_t * module) {
203
+	SX1276_SPIWrite(module, LR_RegOpMode, 0x08);
204
+	module->status = SLEEP;
205
+}
206
+
207
+void SX1276_entryLoRa(SX1276_t * module) {
208
+	SX1276_SPIWrite(module, LR_RegOpMode, 0x88);
209
+}
210
+
211
+void SX1276_clearLoRaIrq(SX1276_t * module) {
212
+	SX1276_SPIWrite(module, LR_RegIrqFlags, 0xFF);
213
+}
214
+
215
+int SX1276_LoRaEntryRx(SX1276_t * module, uint8_t length, uint32_t timeout) {
216
+	uint8_t addr;
217
+
218
+	module->packetLength = length;
219
+
220
+	SX1276_defaultConfig(module);		//Setting base parameter
221
+	SX1276_SPIWrite(module, REG_LR_PADAC, 0x84);	//Normal and RX
222
+	SX1276_SPIWrite(module, LR_RegHopPeriod, 0xFF); //No FHSS
223
+	SX1276_SPIWrite(module, REG_LR_DIOMAPPING1, 0x01);//DIO=00,DIO1=00,DIO2=00, DIO3=01
224
+	SX1276_SPIWrite(module, LR_RegIrqFlagsMask, 0x3F);//Open RxDone interrupt & Timeout
225
+	SX1276_clearLoRaIrq(module);
226
+	SX1276_SPIWrite(module, LR_RegPayloadLength, length);//Payload Length 21byte(this register must difine when the data long of one byte in SF is 6)
227
+	addr = SX1276_SPIRead(module, LR_RegFifoRxBaseAddr); //Read RxBaseAddr
228
+	SX1276_SPIWrite(module, LR_RegFifoAddrPtr, addr); //RxBaseAddr->FiFoAddrPtr
229
+	SX1276_SPIWrite(module, LR_RegOpMode, 0x85);	//Mode//Low Frequency Mode
230
+	//SX1276_SPIWrite(module, LR_RegOpMode,0x05);	//Continuous Rx Mode //High Frequency Mode
231
+	module->readBytes = 0;
232
+
233
+	while (1) {
234
+		if ((SX1276_SPIRead(module, LR_RegModemStat) & 0x04) == 0x04) { //Rx-on going RegModemStat
235
+			module->status = RX;
236
+			return 1;
237
+		}
238
+		if (--timeout == 0) {
239
+			SX1276_hw_Reset(module->hw);
240
+			SX1276_defaultConfig(module);
241
+			return 0;
242
+		}
243
+		SX1276_hw_DelayMs(1);
244
+	}
245
+}
246
+
247
+uint8_t SX1276_LoRaRxPacket(SX1276_t * module) {
248
+	unsigned char addr;
249
+	unsigned char packet_size;
250
+
251
+	if (SX1276_hw_GetDIO0(module->hw)) {
252
+		memset(module->rxBuffer, 0x00, SX1276_MAX_PACKET);
253
+
254
+		addr = SX1276_SPIRead(module, LR_RegFifoRxCurrentaddr); //last packet addr
255
+		SX1276_SPIWrite(module, LR_RegFifoAddrPtr, addr); //RxBaseAddr -> FiFoAddrPtr
256
+
257
+		if (module->LoRa_Rate == SX1276_LORA_SF_6) { //When SpreadFactor is six,will used Implicit Header mode(Excluding internal packet length)
258
+			packet_size = module->packetLength;
259
+		} else {
260
+			packet_size = SX1276_SPIRead(module, LR_RegRxNbBytes); //Number for received bytes
261
+		}
262
+
263
+		SX1276_SPIBurstRead(module, 0x00, module->rxBuffer, packet_size);
264
+		module->readBytes = packet_size;
265
+		SX1276_clearLoRaIrq(module);
266
+	}
267
+	return module->readBytes;
268
+}
269
+
270
+int SX1276_LoRaEntryTx(SX1276_t * module, uint8_t length, uint32_t timeout) {
271
+	uint8_t addr;
272
+	uint8_t temp;
273
+
274
+	module->packetLength = length;
275
+
276
+	SX1276_defaultConfig(module); //setting base parameter
277
+	SX1276_SPIWrite(module, REG_LR_PADAC, 0x87);	//Tx for 20dBm
278
+	SX1276_SPIWrite(module, LR_RegHopPeriod, 0x00); //RegHopPeriod NO FHSS
279
+	SX1276_SPIWrite(module, REG_LR_DIOMAPPING1, 0x41); //DIO0=01, DIO1=00,DIO2=00, DIO3=01
280
+	SX1276_clearLoRaIrq(module);
281
+	SX1276_SPIWrite(module, LR_RegIrqFlagsMask, 0xF7); //Open TxDone interrupt
282
+	SX1276_SPIWrite(module, LR_RegPayloadLength, length); //RegPayloadLength 21byte
283
+	addr = SX1276_SPIRead(module, LR_RegFifoTxBaseAddr); //RegFiFoTxBaseAddr
284
+	SX1276_SPIWrite(module, LR_RegFifoAddrPtr, addr); //RegFifoAddrPtr
285
+
286
+	while (1) {
287
+		temp = SX1276_SPIRead(module, LR_RegPayloadLength);
288
+		if (temp == length) {
289
+			module->status = TX;
290
+			return 1;
291
+		}
292
+
293
+		if (--timeout == 0) {
294
+			SX1276_hw_Reset(module->hw);
295
+			SX1276_defaultConfig(module);
296
+			return 0;
297
+		}
298
+	}
299
+}
300
+
301
+int SX1276_LoRaTxPacket(SX1276_t * module, uint8_t* txBuffer, uint8_t length,
302
+		uint32_t timeout) {
303
+	SX1276_SPIBurstWrite(module, 0x00, txBuffer, length);
304
+	SX1276_SPIWrite(module, LR_RegOpMode, 0x8b);	//Tx Mode
305
+	while (1) {
306
+		if (SX1276_hw_GetDIO0(module->hw)) { //if(Get_NIRQ()) //Packet send over
307
+			SX1276_SPIRead(module, LR_RegIrqFlags);
308
+			SX1276_clearLoRaIrq(module); //Clear irq
309
+			SX1276_standby(module); //Entry Standby mode
310
+			return 1;
311
+		}
312
+
313
+		if (--timeout == 0) {
314
+			SX1276_hw_Reset(module->hw);
315
+			SX1276_defaultConfig(module);
316
+			return 0;
317
+		}
318
+		SX1276_hw_DelayMs(1);
319
+	}
320
+}
321
+
322
+void SX1276_begin(SX1276_t * module, uint8_t frequency, uint8_t power,
323
+		uint8_t LoRa_Rate, uint8_t LoRa_BW, uint8_t packetLength) {
324
+	SX1276_hw_init(module->hw);
325
+	module->frequency = frequency;
326
+	module->power = power;
327
+	module->LoRa_Rate = LoRa_Rate;
328
+	module->LoRa_BW = LoRa_BW;
329
+	module->packetLength = packetLength;
330
+	SX1276_defaultConfig(module);
331
+}
332
+
333
+int SX1276_transmit(SX1276_t * module, uint8_t* txBuf, uint8_t length,
334
+		uint32_t timeout) {
335
+	if (SX1276_LoRaEntryTx(module, length, timeout)) {
336
+		return SX1276_LoRaTxPacket(module, txBuf, length, timeout);
337
+	}
338
+	return 0;
339
+}
340
+
341
+int SX1276_receive(SX1276_t * module, uint8_t length, uint32_t timeout) {
342
+	return SX1276_LoRaEntryRx(module, length, timeout);
343
+}
344
+
345
+uint8_t SX1276_available(SX1276_t * module) {
346
+	return SX1276_LoRaRxPacket(module);
347
+}
348
+
349
+uint8_t SX1276_read(SX1276_t * module, uint8_t* rxBuf, uint8_t length) {
350
+	if (length != module->readBytes)
351
+		length = module->readBytes;
352
+	memcpy(rxBuf, module->rxBuffer, length);
353
+	rxBuf[length] = '\0';
354
+	module->readBytes = 0;
355
+	return length;
356
+}
357
+
358
+uint8_t SX1276_RSSI_LoRa(SX1276_t * module) {
359
+	uint32_t temp = 10;
360
+	temp = SX1276_SPIRead(module, LR_RegRssiValue); //Read RegRssiValue, Rssi value
361
+	temp = temp + 127 - 137; //127:Max RSSI, 137:RSSI offset
362
+	return (uint8_t) temp;
363
+}
364
+
365
+uint8_t SX1276_RSSI(SX1276_t * module) {
366
+	uint8_t temp = 0xff;
367
+	temp = SX1276_SPIRead(module, 0x11);
368
+	temp = 127 - (temp >> 1);	//127:Max RSSI
369
+	return temp;
370
+}
371
+

+ 4 - 3
Src/Uart.c

@@ -30,7 +30,7 @@ typedef struct{
30 30
     
31 31
 void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
32 32
 {
33
-    if(huart->Instance == USART1)//RGB Comunication 
33
+    if(huart->Instance == USART1)
34 34
     {
35 35
         buf[USART1_CNT][count_in1] = rx1_data[0];
36 36
         if(++count_in1>=100){ count_in1 = 0; }
@@ -47,7 +47,8 @@ void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
47 47
 void QueueCheck(uint8_t Usart_Num,uint8_t* header,uint8_t* tail){
48 48
 
49 49
      if(*tail != *header){ 
50
-        Uart_RxData[Usart_Num][Uart_Rxcnt++] = buf[Usart_Num][*tail++];
50
+        Uart_RxData[Usart_Num][Uart_Rxcnt++] = buf[Usart_Num][(*tail)++];
51
+        printf("%02x ",Uart_RxData[Usart_Num][Uart_Rxcnt - 1]);
51 52
         if(*tail>= 100){ *tail = 0; }
52 53
         UartTimerCnt = 0;
53 54
         UartDataRecvSet(Usart_Num + 1);
@@ -92,7 +93,7 @@ void Uart_dataCheck(uint8_t Usart_Num ,uint8_t* cnt){
92 93
         for(uint8_t i = 0; i < (*cnt); i++){
93 94
             printf("%02x ",Uart_RxData[Usart_Num][i]);
94 95
         }
95
-        printf("Original CRC : %02x RecvCRC : %02x \r\n",crccheck,Uart_RxData[Usart_Num][Uart_RxData[Usart_Num][blucell_length] + 1]);
96
+     //   printf("Original CRC : %02x RecvCRC : %02x \r\n",crccheck,Uart_RxData[Usart_Num][Uart_RxData[Usart_Num][blucell_length] + 1]);
96 97
     }
97 98
     else if(crccheck == NO_ERROR){
98 99
         RGB_Controller_Func(&Uart_RxData[Usart_Num][blucell_stx]);\

+ 85 - 66
Src/main.c

@@ -64,8 +64,6 @@
64 64
 /* Private variables ---------------------------------------------------------*/
65 65
 I2C_HandleTypeDef hi2c2;
66 66
 
67
-SPI_HandleTypeDef hspi1;
68
-
69 67
 TIM_HandleTypeDef htim6;
70 68
 
71 69
 UART_HandleTypeDef huart1;
@@ -94,7 +92,6 @@ static void MX_GPIO_Init(void);
94 92
 static void MX_TIM6_Init(void);
95 93
 static void MX_USART1_UART_Init(void);
96 94
 static void MX_USART2_UART_Init(void);
97
-static void MX_SPI1_Init(void);
98 95
 static void MX_I2C2_Init(void);
99 96
 static void MX_NVIC_Init(void);
100 97
 /* USER CODE BEGIN PFP */
@@ -246,10 +243,10 @@ void RGB_Sensor_PowerOnOff(uint8_t id){
246 243
 #define END_ADDR    FLASH_USER + 262144 // 256K
247 244
 //----------------------------------------------------
248 245
 #if 0 // PYJ.2019.03.20_BEGIN -- 
249
-void test_write() // 쓰기함수
246
+void test_write() // ?��기함?��
250 247
 {
251 248
 
252
-    __HAL_RCC_TIM7_CLK_DISABLE(); // 매인타이머를 정지합니다
249
+    __HAL_RCC_TIM7_CLK_DISABLE(); // 매인???��머�?? ?����??��?��?��
253 250
     uint32_t  Address = 0;
254 251
     Address = StartAddr;
255 252
 //    printf("================First============ \r\n");
@@ -260,10 +257,10 @@ void test_write() // 쓰기함수
260 257
 //        Address += 4;
261 258
 //    }  
262 259
 
263
-//    HAL_FLASH_Unlock(); // lock 풀기
260
+//    HAL_FLASH_Unlock(); // lock ??篣?
264 261
 //    HAL_FLASH_Program(FLASH_TYPEPROGRAM_WORD, START_ADDR, (uint32_t)0x12345678); //test
265
-//    HAL_FLASH_Lock(); // lock 그기
266
-//    __HAL_RCC_TIM7_CLK_ENABLE(); // 매인타이머를 재시작합니다
262
+//    HAL_FLASH_Lock(); // lock ?��그기
263
+//    __HAL_RCC_TIM7_CLK_ENABLE(); // 매인???��머�?? ?��?��?��?��?��?��
267 264
     Address = StartAddr;
268 265
     printf("================Second============ \r\n");
269 266
 
@@ -282,7 +279,7 @@ void test_write() // 쓰기함수
282 279
 
283 280
 
284 281
 #if 1 // PYJ.2019.03.20_BEGIN -- 
285
-void test_read(void) // 쓰기함수
282
+void test_read(void) // ?��기함?��
286 283
 {
287 284
     uint32_t Address = 0x08000000;
288 285
     uint8_t aa = 0;
@@ -314,7 +311,7 @@ void Flash_RGB_Data_Write(uint32_t Addr,uint8_t* data){
314 311
     HAL_FLASH_Program(FLASH_TYPEPROGRAM_HALFWORD,Addr + 4 ,   (uint16_t)temp_Blue);
315 312
 
316 313
 }
317
-void Flash_write(uint8_t* data) // 쓰기함수
314
+void Flash_write(uint8_t* data) // ?��기함?��
318 315
 {
319 316
    
320 317
     /*Variable used for Erase procedure*/
@@ -327,8 +324,8 @@ void Flash_write(uint8_t* data) // 쓰기함수
327 324
 //    EraseInitStruct.NbPages     = (FLASH_USER_END_ADDR - FLASH_USER_START_ADDR) / FLASH_PAGE_SIZE;
328 325
      Address = START_ADDR;
329 326
 
330
-    __HAL_RCC_TIM7_CLK_DISABLE(); // 매인타이머를 정지합니다
331
-    HAL_FLASH_Unlock(); // lock 풀기
327
+    __HAL_RCC_TIM7_CLK_DISABLE(); // 매인???��머�?? ?����??��?��?��
328
+    HAL_FLASH_Unlock(); // lock ??篣?
332 329
 //    if (HAL_FLASHEx_Erase(&EraseInitStruct, &PAGEError) != HAL_OK){
333 330
 //        printf("Erase Failed \r\n");
334 331
 //    }else{
@@ -363,11 +360,11 @@ void Flash_write(uint8_t* data) // 쓰기함수
363 360
 
364 361
     }
365 362
     Flash_RGB_Data_Write(Address,&data[blucell_stx]);
366
-    HAL_FLASH_Lock(); // lock 그기
367
-    __HAL_RCC_TIM7_CLK_ENABLE(); // 매인타이머를 재시작합니다
363
+    HAL_FLASH_Lock(); // lock ?��그기
364
+    __HAL_RCC_TIM7_CLK_ENABLE(); // 매인???��머�?? ?��?��?��?��?��?��
368 365
 
369 366
 }
370
-void Flash_InitRead(void) // 쓰기함수
367
+void Flash_InitRead(void) // ?��기함?��
371 368
 {
372 369
     uint32_t  Address = 0;
373 370
     Address = StartAddr;
@@ -387,6 +384,16 @@ void Flash_InitRead(void) // 쓰기함수
387 384
 
388 385
 
389 386
 #endif // PYJ.2019.03.19_END -- 
387
+SX1276_hw_t SX1276_hw;
388
+SX1276_t SX1276;
389
+
390
+int master;
391
+int ret;
392
+
393
+char buffer[64];
394
+
395
+int message;
396
+int message_length;
390 397
 
391 398
 /* USER CODE END 0 */
392 399
 
@@ -400,6 +407,7 @@ int main(void)
400 407
   uint8_t StatusRequest_data[RGB_SensorDataRequest_Length] = {0xbe,RGB_Status_Data_Request,RGB_SensorDataRequest_Length - 3,MyControllerID,SensorID,STH30_CreateCrc(&StatusRequest_data[blucell_type],StatusRequest_data[blucell_length]),0xeb};
401 408
   uint8_t IDAutoSetRequest_data[RGB_SensorIDAutoSetRequest_Length] = {0xbe,RGB_SensorID_SET,RGB_SensorIDAutoSetRequest_Length - 3,MyControllerID,SensorID,STH30_CreateCrc(&IDAutoSetRequest_data[blucell_type],IDAutoSetRequest_data[blucell_length]),0xeb};  
402 409
   uint8_t temp_sensorid = 0;
410
+  uint8_t uartdatarecv= 0;
403 411
   /* USER CODE END 1 */
404 412
 
405 413
   /* MCU Configuration--------------------------------------------------------*/
@@ -423,7 +431,6 @@ int main(void)
423 431
   MX_TIM6_Init();
424 432
   MX_USART1_UART_Init();
425 433
   MX_USART2_UART_Init();
426
-  MX_SPI1_Init();
427 434
   MX_I2C2_Init();
428 435
 
429 436
   /* Initialize interrupts */
@@ -432,7 +439,7 @@ int main(void)
432 439
   HAL_TIM_Base_Start_IT(&htim6);
433 440
   HAL_UART_Receive_IT(&huart1, &rx1_data[0],1);
434 441
   HAL_UART_Receive_IT(&huart2, &rx2_data[0],1);
435
-  setbuf(stdout, NULL); // \n 을 적을 떄만 
442
+  setbuf(stdout, NULL); // \n ?�� ?��?�� ?����? 
436 443
 #if 1 // PYJ.2019.03.04_BEGIN -- 
437 444
       printf("****************************************\r\n");
438 445
       printf("RGB Project\r\n");
@@ -446,10 +453,32 @@ int main(void)
446 453
 
447 454
   /* Infinite loop */
448 455
   /* USER CODE BEGIN WHILE */
456
+  //initialize LoRa module
457
+   SX1276_hw.dio0.port = SX1276_DIO0_GPIO_Port;
458
+   SX1276_hw.dio0.pin = SX1276_DIO0_Pin;
459
+   SX1276_hw.nss.port = GPIOA;
460
+   SX1276_hw.nss.pin = GPIO_PIN_15;
461
+   SX1276_hw.reset.port = SX1276_RESET_GPIO_Port;
462
+   SX1276_hw.reset.pin = SX1276_RESET_Pin;
463
+  
464
+  // SX1276_hw.spi = &hspi3;
465
+   
466
+   SX1276.hw = &SX1276_hw;
467
+
468
+   printf("Configuring LoRa module\r\n");
469
+   SX1276_begin(&SX1276, SX1276_917MHZ, SX1276_POWER_17DBM, SX1276_LORA_SF_8,
470
+           SX1276_LORA_BW_20_8KHZ, 10);
471
+   printf("Done configuring LoRaModule\r\n");
472
+   if (master == 1) {
473
+       ret = SX1276_LoRaEntryTx(&SX1276, 16, 2000);
474
+   } else {
475
+       ret = SX1276_LoRaEntryRx(&SX1276, 16, 2000);
476
+   }
477
+   
449 478
 
450 479
   while (1)
451 480
   {
452
-#if 0 // PYJ.2019.04.11_BEGIN -- 
481
+#if 1 // PYJ.2019.04.11_BEGIN -- 
453 482
     uartdatarecv = UartDataRecvGet(); 
454 483
     if(uartdatarecv != 0){
455 484
         if(uartdatarecv == 1){
@@ -460,6 +489,28 @@ int main(void)
460 489
         UartDataRecvSet(0);
461 490
     }
462 491
 #else
492
+
493
+#if 0 // PYJ.2019.04.13_BEGIN -- 
494
+    if (master == 1) {
495
+        message_length = sprintf(buffer, "Hello %d", message);
496
+        ret = SX1276_LoRaEntryTx(&SX1276, message_length, 2000);
497
+        ret = SX1276_LoRaTxPacket(&SX1276, (uint8_t *) buffer, message_length,
498
+                2000);
499
+        message += 1;
500
+        printf("Transmission: %d\r\n", ret);
501
+    
502
+    } else {
503
+        ret = SX1276_LoRaRxPacket(&SX1276);
504
+        printf("Received: %d\r\n", ret);
505
+        if (ret > 0) {
506
+            SX1276_read(&SX1276, (uint8_t *) buffer, ret);
507
+            printf("Content (%d): %s\r\n", ret, buffer);
508
+        }
509
+    }
510
+#endif // PYJ.2019.04.13_END -- 
511
+
512
+    
513
+
463 514
     UartDataBufferCheck();
464 515
     if(UartDataRecvGet() >= 1 && UartTimerCnt > 100){
465 516
         Uart_dataCheck(USART1_CNT,&count_in1);
@@ -478,7 +529,7 @@ int main(void)
478 529
                     SensorID = 0;
479 530
                 }else{
480 531
                     RGB_Sensor_PowerOnOff(IDAutoSetRequest_data[4]);
481
-                    HAL_Delay(500);
532
+                    HAL_Delay(5000);
482 533
                     RGB_Controller_Func(&IDAutoSetRequest_data[blucell_stx]);
483 534
                     HAL_Delay(500);
484 535
                 }
@@ -589,44 +640,6 @@ static void MX_I2C2_Init(void)
589 640
 
590 641
 }
591 642
 
592
-/**
593
-  * @brief SPI1 Initialization Function
594
-  * @param None
595
-  * @retval None
596
-  */
597
-static void MX_SPI1_Init(void)
598
-{
599
-
600
-  /* USER CODE BEGIN SPI1_Init 0 */
601
-
602
-  /* USER CODE END SPI1_Init 0 */
603
-
604
-  /* USER CODE BEGIN SPI1_Init 1 */
605
-
606
-  /* USER CODE END SPI1_Init 1 */
607
-  /* SPI1 parameter configuration*/
608
-  hspi1.Instance = SPI1;
609
-  hspi1.Init.Mode = SPI_MODE_MASTER;
610
-  hspi1.Init.Direction = SPI_DIRECTION_2LINES;
611
-  hspi1.Init.DataSize = SPI_DATASIZE_8BIT;
612
-  hspi1.Init.CLKPolarity = SPI_POLARITY_LOW;
613
-  hspi1.Init.CLKPhase = SPI_PHASE_1EDGE;
614
-  hspi1.Init.NSS = SPI_NSS_HARD_OUTPUT;
615
-  hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_2;
616
-  hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB;
617
-  hspi1.Init.TIMode = SPI_TIMODE_DISABLE;
618
-  hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
619
-  hspi1.Init.CRCPolynomial = 10;
620
-  if (HAL_SPI_Init(&hspi1) != HAL_OK)
621
-  {
622
-    Error_Handler();
623
-  }
624
-  /* USER CODE BEGIN SPI1_Init 2 */
625
-
626
-  /* USER CODE END SPI1_Init 2 */
627
-
628
-}
629
-
630 643
 /**
631 644
   * @brief TIM6 Initialization Function
632 645
   * @param None
@@ -753,12 +766,12 @@ static void MX_GPIO_Init(void)
753 766
 
754 767
   /*Configure GPIO pin Output Level */
755 768
   HAL_GPIO_WritePin(GPIOA, SX1276_DIO0_Pin|SX1276_DIO1_Pin|SX1276_DIO2_Pin|SX1276_DIO3_Pin 
756
-                          |SENSOR_EN8_Pin, GPIO_PIN_RESET);
769
+                          |SENSOR_EN8_Pin|SX1276_NSS_Pin, GPIO_PIN_RESET);
757 770
 
758 771
   /*Configure GPIO pin Output Level */
759 772
   HAL_GPIO_WritePin(GPIOB, SX1276_RESET_Pin|LED_ALARM_Pin|SENSOR_EN1_Pin|SENSOR_EN2_Pin 
760
-                          |SENSOR_EN3_Pin|LED_CH5_Pin|LED_CH6_Pin|LED_CH7_Pin 
761
-                          |LED_CH8_Pin, GPIO_PIN_RESET);
773
+                          |SENSOR_EN3_Pin|SX1276_CLK_Pin|SX1276_MOSI_Pin|LED_CH5_Pin 
774
+                          |LED_CH6_Pin|LED_CH7_Pin|LED_CH8_Pin, GPIO_PIN_RESET);
762 775
 
763 776
   /*Configure GPIO pin Output Level */
764 777
   HAL_GPIO_WritePin(LED_CH4_GPIO_Port, LED_CH4_Pin, GPIO_PIN_RESET);
@@ -775,20 +788,20 @@ static void MX_GPIO_Init(void)
775 788
   HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
776 789
 
777 790
   /*Configure GPIO pins : SX1276_DIO0_Pin SX1276_DIO1_Pin SX1276_DIO2_Pin SX1276_DIO3_Pin 
778
-                           SENSOR_EN8_Pin */
791
+                           SENSOR_EN8_Pin SX1276_NSS_Pin */
779 792
   GPIO_InitStruct.Pin = SX1276_DIO0_Pin|SX1276_DIO1_Pin|SX1276_DIO2_Pin|SX1276_DIO3_Pin 
780
-                          |SENSOR_EN8_Pin;
793
+                          |SENSOR_EN8_Pin|SX1276_NSS_Pin;
781 794
   GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
782 795
   GPIO_InitStruct.Pull = GPIO_NOPULL;
783 796
   GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
784 797
   HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
785 798
 
786 799
   /*Configure GPIO pins : SX1276_RESET_Pin LED_ALARM_Pin SENSOR_EN1_Pin SENSOR_EN2_Pin 
787
-                           SENSOR_EN3_Pin LED_CH5_Pin LED_CH6_Pin LED_CH7_Pin 
788
-                           LED_CH8_Pin */
800
+                           SENSOR_EN3_Pin SX1276_CLK_Pin SX1276_MOSI_Pin LED_CH5_Pin 
801
+                           LED_CH6_Pin LED_CH7_Pin LED_CH8_Pin */
789 802
   GPIO_InitStruct.Pin = SX1276_RESET_Pin|LED_ALARM_Pin|SENSOR_EN1_Pin|SENSOR_EN2_Pin 
790
-                          |SENSOR_EN3_Pin|LED_CH5_Pin|LED_CH6_Pin|LED_CH7_Pin 
791
-                          |LED_CH8_Pin;
803
+                          |SENSOR_EN3_Pin|SX1276_CLK_Pin|SX1276_MOSI_Pin|LED_CH5_Pin 
804
+                          |LED_CH6_Pin|LED_CH7_Pin|LED_CH8_Pin;
792 805
   GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
793 806
   GPIO_InitStruct.Pull = GPIO_NOPULL;
794 807
   GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
@@ -801,6 +814,12 @@ static void MX_GPIO_Init(void)
801 814
   GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
802 815
   HAL_GPIO_Init(LED_CH4_GPIO_Port, &GPIO_InitStruct);
803 816
 
817
+  /*Configure GPIO pin : SX1276_MISO_Pin */
818
+  GPIO_InitStruct.Pin = SX1276_MISO_Pin;
819
+  GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
820
+  GPIO_InitStruct.Pull = GPIO_NOPULL;
821
+  HAL_GPIO_Init(SX1276_MISO_GPIO_Port, &GPIO_InitStruct);
822
+
804 823
 }
805 824
 
806 825
 /* USER CODE BEGIN 4 */

+ 0 - 85
Src/stm32f1xx_hal_msp.c

@@ -167,91 +167,6 @@ void HAL_I2C_MspDeInit(I2C_HandleTypeDef* hi2c)
167 167
 
168 168
 }
169 169
 
170
-/**
171
-* @brief SPI MSP Initialization
172
-* This function configures the hardware resources used in this example
173
-* @param hspi: SPI handle pointer
174
-* @retval None
175
-*/
176
-void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi)
177
-{
178
-
179
-  GPIO_InitTypeDef GPIO_InitStruct = {0};
180
-  if(hspi->Instance==SPI1)
181
-  {
182
-  /* USER CODE BEGIN SPI1_MspInit 0 */
183
-
184
-  /* USER CODE END SPI1_MspInit 0 */
185
-    /* Peripheral clock enable */
186
-    __HAL_RCC_SPI1_CLK_ENABLE();
187
-  
188
-    __HAL_RCC_GPIOA_CLK_ENABLE();
189
-    __HAL_RCC_GPIOB_CLK_ENABLE();
190
-    /**SPI1 GPIO Configuration    
191
-    PA15     ------> SPI1_NSS
192
-    PB3     ------> SPI1_SCK
193
-    PB4     ------> SPI1_MISO
194
-    PB5     ------> SPI1_MOSI 
195
-    */
196
-    GPIO_InitStruct.Pin = GPIO_PIN_15;
197
-    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
198
-    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
199
-    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
200
-
201
-    GPIO_InitStruct.Pin = GPIO_PIN_3|GPIO_PIN_5;
202
-    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
203
-    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
204
-    HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
205
-
206
-    GPIO_InitStruct.Pin = GPIO_PIN_4;
207
-    GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
208
-    GPIO_InitStruct.Pull = GPIO_NOPULL;
209
-    HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
210
-
211
-    __HAL_AFIO_REMAP_SPI1_ENABLE();
212
-
213
-  /* USER CODE BEGIN SPI1_MspInit 1 */
214
-
215
-  /* USER CODE END SPI1_MspInit 1 */
216
-  }
217
-
218
-}
219
-
220
-/**
221
-* @brief SPI MSP De-Initialization
222
-* This function freeze the hardware resources used in this example
223
-* @param hspi: SPI handle pointer
224
-* @retval None
225
-*/
226
-
227
-void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi)
228
-{
229
-
230
-  if(hspi->Instance==SPI1)
231
-  {
232
-  /* USER CODE BEGIN SPI1_MspDeInit 0 */
233
-
234
-  /* USER CODE END SPI1_MspDeInit 0 */
235
-    /* Peripheral clock disable */
236
-    __HAL_RCC_SPI1_CLK_DISABLE();
237
-  
238
-    /**SPI1 GPIO Configuration    
239
-    PA15     ------> SPI1_NSS
240
-    PB3     ------> SPI1_SCK
241
-    PB4     ------> SPI1_MISO
242
-    PB5     ------> SPI1_MOSI 
243
-    */
244
-    HAL_GPIO_DeInit(GPIOA, GPIO_PIN_15);
245
-
246
-    HAL_GPIO_DeInit(GPIOB, GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5);
247
-
248
-  /* USER CODE BEGIN SPI1_MspDeInit 1 */
249
-
250
-  /* USER CODE END SPI1_MspDeInit 1 */
251
-  }
252
-
253
-}
254
-
255 170
 /**
256 171
 * @brief TIM_Base MSP Initialization
257 172
 * This function configures the hardware resources used in this example