1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057 |
- /* USER CODE BEGIN Header */
- /**
- ******************************************************************************
- * @file : main.c
- * @brief : Main program body
- ******************************************************************************
- ** This notice applies to any and all portions of this file
- * that are not between comment pairs USER CODE BEGIN and
- * USER CODE END. Other portions of this file, whether
- * inserted by the user or by software development tools
- * are owned by their respective copyright owners.
- *
- * COPYRIGHT(c) 2019 STMicroelectronics
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of STMicroelectronics nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,p THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- ******************************************************************************
- */
- /* USER CODE END Header */
- /* Includes ------------------------------------------------------------------*/
- #include "main.h"
- /* Private includes ----------------------------------------------------------*/
- /* USER CODE BEGIN Includes */
- /* USER CODE END Includes */
- /* Private typedef -----------------------------------------------------------*/
- /* USER CODE BEGIN PTD */
- /* USER CODE END PTD */
- /* Private define ------------------------------------------------------------*/
- /* USER CODE BEGIN PD */
- #define LORA_TIMER_CNT 600000 / 2
- /* USER CODE END PD */
- /* Private macro -------------------------------------------------------------*/
- /* USER CODE BEGIN PM */
- /* USER CODE END PM */
- /* Private variables ---------------------------------------------------------*/
- I2C_HandleTypeDef hi2c2;
- TIM_HandleTypeDef htim6;
- UART_HandleTypeDef huart1;
- UART_HandleTypeDef huart2;
- /* USER CODE BEGIN PV */
- uint8_t rx1_data[1];
- uint8_t rx2_data[1];
- uint8_t ring_buf[buf_size];
- uint8_t count_in1 = 0, count_out1 = 0;
- uint8_t count_in2 = 0, count_out2 = 0;
- //uint8_t count_in3 = 0, count_out = 0;
- uint8_t UartDataisReved;
- uint8_t LoraDataSend;
- uint8_t RGB_SensorIDAutoset = 0;
- volatile uint32_t UartTimerCnt = 0;
- volatile uint32_t LedTimerCnt = 0;
- volatile uint32_t LoraTxTimerCnt = 0;
- volatile uint32_t LoraAckTimerCnt = 0;
- uint8_t buf[buf_size] = {0,};
- uint8_t buf1[buf_size] = {0,};
- uint8_t buf2[buf_size] = {0,};
- uint8_t MyControllerID = 0;
- uint8_t SensorID = 0;
- typedef enum{
- LoraRx_mode = 0,
- LoraTx_mode ,
- };
- /* USER CODE END PV */
- /* Private function prototypes -----------------------------------------------*/
- void SystemClock_Config(void);
- static void MX_GPIO_Init(void);
- static void MX_TIM6_Init(void);
- static void MX_USART1_UART_Init(void);
- static void MX_USART2_UART_Init(void);
- static void MX_I2C2_Init(void);
- static void MX_NVIC_Init(void);
- /* USER CODE BEGIN PFP */
- void RGB_SensorIDAutoSet(uint8_t set);
- uint8_t RGB_SensorIDAutoGet(void);
- void UartDataRecvSet(uint8_t val);
- #if 0 // PYJ.2019.04.19_BEGIN --
- void Uart_dataCheck(uint8_t* cnt);
- #else
- void Uart_dataCheck(uint8_t*,uint8_t* cnt);
- #endif // PYJ.2019.04.19_END --
- void Uart1_Data_Send(uint8_t* data,uint8_t size);
- /* USER CODE END PFP */
- /* Private user code ---------------------------------------------------------*/
- /* USER CODE BEGIN 0 */
- void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
- {
- if(huart->Instance == USART1)//RGB Comunication
- {
- buf1[count_in1] = rx1_data[0];//(uint8_t)USART2->DR;
- if(++count_in1>=buf_size){ count_in1 = 0; }
- // printf("data %02x \r\n",rx1_data[0]);
- #if 0 // PYJ.2019.04.19_BEGIN --
- if(buf[count_in1++] == 0xEB){
- if(buf[bluecell_length] == (count_in1 - 3))
- UartDataRecvSet(1);
- else
- count_in1 = 0;
- }
- #endif // PYJ.2019.04.19_END --
- HAL_UART_Receive_IT(&huart1,&rx1_data[0],1);
- }
- if(huart->Instance == USART2) // Lora?? ?†µ?‹ ?•˜?Š” ?¬?Џ
- {
- buf2[count_in2] = rx2_data[0];//(uint8_t)USART2->DR;
- if(++count_in2>=buf_size){ count_in2 = 0; }
- // if(buf[count_in++] == 0xEB)UartDataRecvSet(1);
- #if 0 // PYJ.2019.04.19_BEGIN --
- if(buf[count_in2++] == 0xEB){
- if(buf[bluecell_length] == (count_in2 - 3))
- UartDataRecvSet(2);
- else
- count_in1 = 0;
- // printf("UART 2 %d",((count_in2 -1) - 3));
- }
- #endif // PYJ.2019.04.19_END --
- HAL_UART_Receive_IT(&huart2,&rx2_data[0],1);
- }
- #if 0 // PYJ.2019.04.13_BEGIN --
- if(huart->Instance == USART3) //GUI ?? ?†µ?‹ ?•˜?Š” Port
- {
- buf[count_in3] = rx3_data[0];//(uint8_t)USART2->DR;
- if(buf[count_in3++] == 0xEB)UartDataRecvSet(3);
- /*ring_buf[count_in] = rx2_data[0];//(uint8_t)USART2->DR;
- if(++count_in>=buf_size) count_in=0;*/
- HAL_UART_Receive_IT(&huart3,&rx3_data[0],1);
- }
- #endif // PYJ.2019.04.13_END --
-
- }
- void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
- {
- if(htim->Instance == TIM6){
- UartTimerCnt++;
- LedTimerCnt++;
- LoraTxTimerCnt++;
- LoraAckTimerCnt++;
- }
- }
- void LoraDataSendSet(uint8_t val){
- LoraDataSend = val;
- }
- uint8_t LoraDataSendGet(void){
- return LoraDataSend;
- }
- void UartDataRecvSet(uint8_t val){
- UartDataisReved = val;
- }
- uint8_t UartDataRecvGet(void){
- return UartDataisReved;
- }
- void RGB_SensorIDAutoSet(uint8_t set){
- RGB_SensorIDAutoset = set;
- }
- uint8_t RGB_SensorIDAutoGet(void){
- return RGB_SensorIDAutoset;
- }
- void Uart2_Data_Send(uint8_t* data,uint8_t size){
- HAL_UART_Transmit(&huart2, data,size, 10);
- }
- void Uart1_Data_Send(uint8_t* data,uint8_t size){
- HAL_UART_Transmit(&huart1, data,size, 10);
- }
- int _write (int file, uint8_t *ptr, uint16_t len)
- {
- HAL_UART_Transmit (&huart1, ptr, len, 10);
- return len;
- }
- #if 0 // PYJ.2019.04.19_BEGIN --
- void Uart_dataCheck(uint8_t* cnt){
- etError crccheck = 0;
- #if 0
- for(uint8_t i = 0; i < (* cnt); i++){
- printf("%02x ",buf[i]);
- }
- printf("\r\n");
- #endif
- crccheck = STH30_CheckCrc(&buf[bluecell_type],buf[bluecell_length],buf[buf[bluecell_length] + 1]);
- if(crccheck == CHECKSUM_ERROR){
- for(uint8_t i = 0; i < (*cnt); i++){
- printf("%02x ",buf[i]);
- }
- printf("Original CRC : %02x RecvCRC : %02x \r\n",crccheck,buf[buf[bluecell_length] + 1]);
- }
- else if(crccheck == NO_ERROR){
- RGB_Controller_Func(&buf[bluecell_stx]);
- }
- else{
- printf("What Happen?\r\n");
- /*NOP*/
- }
- *cnt = 0;
-
- memset(buf,0x00,buf_size);
- }
- #else
- void Uart_dataCheck(uint8_t* Que_Buf,uint8_t* cnt){
- etError crccheck = 0;
- #if 0
- for(uint8_t i = 0; i < (* cnt); i++){
- printf("%02x ",buf[i]);
- }
- printf("\r\n");
- #endif
- crccheck = STH30_CheckCrc(&Que_Buf[bluecell_type],Que_Buf[bluecell_length],Que_Buf[Que_Buf[bluecell_length] + 1]);
- if(crccheck == CHECKSUM_ERROR){
- for(uint8_t i = 0; i < (*cnt); i++){
- printf("%02x ",Que_Buf[i]);
- }
- printf("Original CRC : %02x RecvCRC : %02x \r\n",crccheck,Que_Buf[Que_Buf[bluecell_length] + 1]);
- }
- else if(crccheck == NO_ERROR){
- RGB_Controller_Func(&Que_Buf[bluecell_stx]);
- }
- else{
- printf("What Happen?\r\n");
- /*NOP*/
- }
- //*cnt = 0;
-
- memset(Que_Buf,0x00,buf_size);
- }
- #endif // PYJ.2019.04.19_END --
- void RGB_Sensor_PowerOnOff(uint8_t id){
- printf("%d Power ON \r\n",id);
- switch(id){
- case 0:
- HAL_GPIO_WritePin(SENSOR_EN1_GPIO_Port,SENSOR_EN1_Pin,GPIO_PIN_SET);
- HAL_GPIO_WritePin(SENSOR_EN2_GPIO_Port,SENSOR_EN2_Pin,GPIO_PIN_SET);
- HAL_GPIO_WritePin(SENSOR_EN3_GPIO_Port,SENSOR_EN3_Pin,GPIO_PIN_SET);
- HAL_GPIO_WritePin(SENSOR_EN4_GPIO_Port,SENSOR_EN4_Pin,GPIO_PIN_SET);
- HAL_GPIO_WritePin(SENSOR_EN5_GPIO_Port,SENSOR_EN5_Pin,GPIO_PIN_SET);
- HAL_GPIO_WritePin(SENSOR_EN6_GPIO_Port,SENSOR_EN6_Pin,GPIO_PIN_SET);
- HAL_GPIO_WritePin(SENSOR_EN7_GPIO_Port,SENSOR_EN7_Pin,GPIO_PIN_SET);
- HAL_GPIO_WritePin(SENSOR_EN8_GPIO_Port,SENSOR_EN8_Pin,GPIO_PIN_SET);
- break;
- case 1:
- HAL_GPIO_WritePin(SENSOR_EN1_GPIO_Port,SENSOR_EN1_Pin,GPIO_PIN_RESET);
- HAL_Delay(50);
- HAL_GPIO_WritePin(SENSOR_EN1_GPIO_Port,SENSOR_EN1_Pin,GPIO_PIN_SET);
- HAL_GPIO_WritePin(SENSOR_EN2_GPIO_Port,SENSOR_EN2_Pin,GPIO_PIN_RESET);
- HAL_GPIO_WritePin(SENSOR_EN3_GPIO_Port,SENSOR_EN3_Pin,GPIO_PIN_RESET);
- HAL_GPIO_WritePin(SENSOR_EN4_GPIO_Port,SENSOR_EN4_Pin,GPIO_PIN_RESET);
- HAL_GPIO_WritePin(SENSOR_EN5_GPIO_Port,SENSOR_EN5_Pin,GPIO_PIN_RESET);
- HAL_GPIO_WritePin(SENSOR_EN6_GPIO_Port,SENSOR_EN6_Pin,GPIO_PIN_RESET);
- HAL_GPIO_WritePin(SENSOR_EN7_GPIO_Port,SENSOR_EN7_Pin,GPIO_PIN_RESET);
- HAL_GPIO_WritePin(SENSOR_EN8_GPIO_Port,SENSOR_EN8_Pin,GPIO_PIN_RESET);
- break;
- case 2:
- HAL_GPIO_WritePin(SENSOR_EN1_GPIO_Port,SENSOR_EN1_Pin,GPIO_PIN_SET);
- HAL_GPIO_WritePin(SENSOR_EN2_GPIO_Port,SENSOR_EN2_Pin,GPIO_PIN_SET);
- HAL_GPIO_WritePin(SENSOR_EN3_GPIO_Port,SENSOR_EN3_Pin,GPIO_PIN_RESET);
- HAL_GPIO_WritePin(SENSOR_EN4_GPIO_Port,SENSOR_EN4_Pin,GPIO_PIN_RESET);
- HAL_GPIO_WritePin(SENSOR_EN5_GPIO_Port,SENSOR_EN5_Pin,GPIO_PIN_RESET);
- HAL_GPIO_WritePin(SENSOR_EN6_GPIO_Port,SENSOR_EN6_Pin,GPIO_PIN_RESET);
- HAL_GPIO_WritePin(SENSOR_EN7_GPIO_Port,SENSOR_EN7_Pin,GPIO_PIN_RESET);
- HAL_GPIO_WritePin(SENSOR_EN8_GPIO_Port,SENSOR_EN8_Pin,GPIO_PIN_RESET);
- break;
- case 3:
- HAL_GPIO_WritePin(SENSOR_EN1_GPIO_Port,SENSOR_EN1_Pin,GPIO_PIN_SET);
- HAL_GPIO_WritePin(SENSOR_EN2_GPIO_Port,SENSOR_EN2_Pin,GPIO_PIN_SET);
- HAL_GPIO_WritePin(SENSOR_EN3_GPIO_Port,SENSOR_EN3_Pin,GPIO_PIN_SET);
- HAL_GPIO_WritePin(SENSOR_EN4_GPIO_Port,SENSOR_EN4_Pin,GPIO_PIN_RESET);
- HAL_GPIO_WritePin(SENSOR_EN5_GPIO_Port,SENSOR_EN5_Pin,GPIO_PIN_RESET);
- HAL_GPIO_WritePin(SENSOR_EN6_GPIO_Port,SENSOR_EN6_Pin,GPIO_PIN_RESET);
- HAL_GPIO_WritePin(SENSOR_EN7_GPIO_Port,SENSOR_EN7_Pin,GPIO_PIN_RESET);
- HAL_GPIO_WritePin(SENSOR_EN8_GPIO_Port,SENSOR_EN8_Pin,GPIO_PIN_RESET);
- break;
- case 4:
- HAL_GPIO_WritePin(SENSOR_EN1_GPIO_Port,SENSOR_EN1_Pin,GPIO_PIN_SET);
- HAL_GPIO_WritePin(SENSOR_EN2_GPIO_Port,SENSOR_EN2_Pin,GPIO_PIN_SET);
- HAL_GPIO_WritePin(SENSOR_EN3_GPIO_Port,SENSOR_EN3_Pin,GPIO_PIN_SET);
- HAL_GPIO_WritePin(SENSOR_EN4_GPIO_Port,SENSOR_EN4_Pin,GPIO_PIN_SET);
- HAL_GPIO_WritePin(SENSOR_EN5_GPIO_Port,SENSOR_EN5_Pin,GPIO_PIN_RESET);
- HAL_GPIO_WritePin(SENSOR_EN6_GPIO_Port,SENSOR_EN6_Pin,GPIO_PIN_RESET);
- HAL_GPIO_WritePin(SENSOR_EN7_GPIO_Port,SENSOR_EN7_Pin,GPIO_PIN_RESET);
- HAL_GPIO_WritePin(SENSOR_EN8_GPIO_Port,SENSOR_EN8_Pin,GPIO_PIN_RESET);
- break;
- case 5:
- HAL_GPIO_WritePin(SENSOR_EN1_GPIO_Port,SENSOR_EN1_Pin,GPIO_PIN_SET);
- HAL_GPIO_WritePin(SENSOR_EN2_GPIO_Port,SENSOR_EN2_Pin,GPIO_PIN_SET);
- HAL_GPIO_WritePin(SENSOR_EN3_GPIO_Port,SENSOR_EN3_Pin,GPIO_PIN_SET);
- HAL_GPIO_WritePin(SENSOR_EN4_GPIO_Port,SENSOR_EN4_Pin,GPIO_PIN_SET);
- HAL_GPIO_WritePin(SENSOR_EN5_GPIO_Port,SENSOR_EN5_Pin,GPIO_PIN_SET);
- HAL_GPIO_WritePin(SENSOR_EN6_GPIO_Port,SENSOR_EN6_Pin,GPIO_PIN_RESET);
- HAL_GPIO_WritePin(SENSOR_EN7_GPIO_Port,SENSOR_EN7_Pin,GPIO_PIN_RESET);
- HAL_GPIO_WritePin(SENSOR_EN8_GPIO_Port,SENSOR_EN8_Pin,GPIO_PIN_RESET);
- break;
- case 6:
- HAL_GPIO_WritePin(SENSOR_EN1_GPIO_Port,SENSOR_EN1_Pin,GPIO_PIN_SET);
- HAL_GPIO_WritePin(SENSOR_EN2_GPIO_Port,SENSOR_EN2_Pin,GPIO_PIN_SET);
- HAL_GPIO_WritePin(SENSOR_EN3_GPIO_Port,SENSOR_EN3_Pin,GPIO_PIN_SET);
- HAL_GPIO_WritePin(SENSOR_EN4_GPIO_Port,SENSOR_EN4_Pin,GPIO_PIN_SET);
- HAL_GPIO_WritePin(SENSOR_EN5_GPIO_Port,SENSOR_EN5_Pin,GPIO_PIN_SET);
- HAL_GPIO_WritePin(SENSOR_EN6_GPIO_Port,SENSOR_EN6_Pin,GPIO_PIN_SET);
- HAL_GPIO_WritePin(SENSOR_EN7_GPIO_Port,SENSOR_EN7_Pin,GPIO_PIN_RESET);
- HAL_GPIO_WritePin(SENSOR_EN8_GPIO_Port,SENSOR_EN8_Pin,GPIO_PIN_RESET);
- break;
- case 7:
- HAL_GPIO_WritePin(SENSOR_EN1_GPIO_Port,SENSOR_EN1_Pin,GPIO_PIN_SET);
- HAL_GPIO_WritePin(SENSOR_EN2_GPIO_Port,SENSOR_EN2_Pin,GPIO_PIN_SET);
- HAL_GPIO_WritePin(SENSOR_EN3_GPIO_Port,SENSOR_EN3_Pin,GPIO_PIN_SET);
- HAL_GPIO_WritePin(SENSOR_EN4_GPIO_Port,SENSOR_EN4_Pin,GPIO_PIN_SET);
- HAL_GPIO_WritePin(SENSOR_EN5_GPIO_Port,SENSOR_EN5_Pin,GPIO_PIN_SET);
- HAL_GPIO_WritePin(SENSOR_EN6_GPIO_Port,SENSOR_EN6_Pin,GPIO_PIN_SET);
- HAL_GPIO_WritePin(SENSOR_EN7_GPIO_Port,SENSOR_EN7_Pin,GPIO_PIN_SET);
- HAL_GPIO_WritePin(SENSOR_EN8_GPIO_Port,SENSOR_EN8_Pin,GPIO_PIN_RESET);
- break;
- case 8:
- HAL_GPIO_WritePin(SENSOR_EN1_GPIO_Port,SENSOR_EN1_Pin,GPIO_PIN_SET);
- HAL_GPIO_WritePin(SENSOR_EN2_GPIO_Port,SENSOR_EN2_Pin,GPIO_PIN_SET);
- HAL_GPIO_WritePin(SENSOR_EN3_GPIO_Port,SENSOR_EN3_Pin,GPIO_PIN_SET);
- HAL_GPIO_WritePin(SENSOR_EN4_GPIO_Port,SENSOR_EN4_Pin,GPIO_PIN_SET);
- HAL_GPIO_WritePin(SENSOR_EN5_GPIO_Port,SENSOR_EN5_Pin,GPIO_PIN_SET);
- HAL_GPIO_WritePin(SENSOR_EN6_GPIO_Port,SENSOR_EN6_Pin,GPIO_PIN_SET);
- HAL_GPIO_WritePin(SENSOR_EN7_GPIO_Port,SENSOR_EN7_Pin,GPIO_PIN_SET);
- HAL_GPIO_WritePin(SENSOR_EN8_GPIO_Port,SENSOR_EN8_Pin,GPIO_PIN_SET);
- break;
- }
- }
- #define StartAddr ((uint32_t)0x08030000)
- #if 1 // PYJ.2019.03.19_BEGIN --
- //----------------------------------------------------
- #define FLASH_USER StartAddr
- #define START_ADDR FLASH_USER
- #define END_ADDR FLASH_USER + 262144 // 256K
- //----------------------------------------------------
- #if 0 // PYJ.2019.03.20_BEGIN --
- void test_write() // 쓰기함수
- {
- __HAL_RCC_TIM7_CLK_DISABLE(); // 매인타이머를 정지합니다
- uint32_t Address = 0;
- Address = StartAddr;
- // printf("================First============ \r\n");
- // for(uint8_t i=0;i<16;i++)
- // {
- // printf("%08x: %X\r\n", Address, *(uint32_t*)Address);
- // Address += 4;
- // }
- // HAL_FLASH_Unlock(); // lock 풀기
- // HAL_FLASH_Program(FLASH_TYPEPROGRAM_WORD, START_ADDR, (uint32_t)0x12345678); //test
- // HAL_FLASH_Lock(); // lock 잠그기
- // __HAL_RCC_TIM7_CLK_ENABLE(); // 매인타이머를 재시작합니다
- Address = StartAddr;
- printf("================Second============ \r\n");
- //while(Address < 0x0803FFFF)
- for(uint16_t i = 0; i<37273 ; i++)
- {
- printf("%02X", *(uint8_t*)Address);
- Address ++;
- }
- printf("%08x:",Address);
- }
- #endif // PYJ.2019.03.20_END --
- #define DATA_16_1 ((uint32_t)0x1234)
- #define DATA_16_2 ((uint32_t)0x5678)
- #if 1 // PYJ.2019.03.20_BEGIN --
- void test_read(void) // 쓰기함수
- {
- uint32_t Address = 0x08000000;
- uint8_t aa = 0;
- for(uint32_t i = Address; i <= Address + 0x35d8; i++ ){
- printf("%02X ",*(uint8_t*)i);
- aa++;
- if(aa > 15){
- printf("\n");
- aa= 0;
- }
- }
-
- }
- #endif // PYJ.2019.03.20_END --
- #define ADDR_FLASH_PAGE_TEST ((uint32_t)0x08030000) /* Base @ of Page 127, 1 Kbytes */
- #define FLASH_USER_START_ADDR ADDR_FLASH_PAGE_TEST /* Start @ of user Flash area */
- #define FLASH_USER_END_ADDR ADDR_FLASH_PAGE_TEST + ((uint32_t)0x0000FFFF) /* End @ of user Flash area */
- void Flash_RGB_Data_Write(uint32_t Addr,uint8_t* data){
- uint16_t temp_Red = 0,temp_Green = 0,temp_Blue = 0;
- temp_Red = ((data[bluecell_red_H] << 8) |data[bluecell_red_L]); //R
- temp_Green= ((data[bluecell_green_H] << 8) |data[bluecell_green_L]); //G
- temp_Blue = ((data[bluecell_blue_H] << 8) |data[bluecell_blue_L]); //B
- HAL_FLASH_Program(FLASH_TYPEPROGRAM_HALFWORD,Addr + 0 , (uint16_t)temp_Red);
- HAL_FLASH_Program(FLASH_TYPEPROGRAM_HALFWORD,Addr + 2 , (uint16_t)temp_Green);
- HAL_FLASH_Program(FLASH_TYPEPROGRAM_HALFWORD,Addr + 4 , (uint16_t)temp_Blue);
- }
- void Flash_write(uint8_t* data) // 쓰기함수
- {
-
- /*Variable used for Erase procedure*/
- // static FLASH_EraseInitTypeDef EraseInitStruct;
- uint32_t Address = 0;//, PAGEError = 0;
-
- /* Fill EraseInit structure*/
- // EraseInitStruct.TypeErase = FLASH_TYPEERASE_PAGES;
- // EraseInitStruct.PageAddress = FLASH_USER_START_ADDR;
- // EraseInitStruct.NbPages = (FLASH_USER_END_ADDR - FLASH_USER_START_ADDR) / FLASH_PAGE_SIZE;
- Address = START_ADDR;
- __HAL_RCC_TIM7_CLK_DISABLE(); // 매인타이머를 정지합니다
- HAL_FLASH_Unlock(); // lock 풀기
- // if (HAL_FLASHEx_Erase(&EraseInitStruct, &PAGEError) != HAL_OK){
- // printf("Erase Failed \r\n");
- // }else{
- // printf("Erase Success \r\n");
- // }
-
- switch(data[bluecell_dstid]){
- case 1:
- Address += 0;
- break;
- case 2:
- Address += 6;
- break;
- case 3:
- Address += 12;
- break;
- case 4:
- Address += 18;
- break;
- case 5:
- Address += 24;
- break;
- case 6:
- Address += 30;
- break;
- case 7:
- Address += 36;
- break;
- case 8:
- Address += 42;
- break;
- }
- Flash_RGB_Data_Write(Address,&data[bluecell_stx]);
- HAL_FLASH_Lock(); // lock 잠그기
- __HAL_RCC_TIM7_CLK_ENABLE(); // 매인타이머를 재시작합니다
- }
- void Flash_InitRead(void) // 쓰기함수
- {
- uint32_t Address = 0;
- Address = StartAddr;
- for(uint8_t i = 1; i <= 8; i++ ){
- RGB_SensorRedLimit_Buf[i] = (*(uint16_t*)Address);
- // printf("%08x : %04X \n",Address ,*(uint16_t*)Address);
- Address += 2;
- RGB_SensorGreenLimit_Buf[i] = (*(uint16_t*)Address);
- // printf("%08x : %04X \n",Address ,*(uint16_t*)Address);
- Address += 2;
- RGB_SensorBlueLimit_Buf[i] = (*(uint16_t*)Address);
- // printf("%08x : %04X \n",Address ,*(uint16_t*)Address);
- Address += 2;
- }
- }
- #endif // PYJ.2019.03.19_END --
- SX1276_hw_t SX1276_hw;
- SX1276_t SX1276;
- int master;
- int ret;
- char buffer[100];
- int message_length;
- int message;
- /* USER CODE END 0 */
- /**
- * @brief The application entry point.
- * @retval int
- */
- int main(void)
- {
- /* USER CODE BEGIN 1 */
- uint8_t StatusRequest_data[RGB_SensorDataRequest_Length] = {0xbe,RGB_Status_Data_Request,RGB_SensorDataRequest_Length - 3,MyControllerID,SensorID,STH30_CreateCrc(&StatusRequest_data[bluecell_type],StatusRequest_data[bluecell_length]),0xeb};
- uint8_t IDAutoSetRequest_data[RGB_SensorIDAutoSetRequest_Length] = {0xbe,RGB_SensorID_SET,RGB_SensorIDAutoSetRequest_Length - 3,MyControllerID,SensorID,STH30_CreateCrc(&IDAutoSetRequest_data[bluecell_type],IDAutoSetRequest_data[bluecell_length]),0xeb};
- uint8_t temp_sensorid = 0;
- uint8_t uartdatarecv= 0;
- /* USER CODE END 1 */
- /* MCU Configuration--------------------------------------------------------*/
- /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
- HAL_Init();
- /* USER CODE BEGIN Init */
- /* USER CODE END Init */
- /* Configure the system clock */
- SystemClock_Config();
- /* USER CODE BEGIN SysInit */
- /* USER CODE END SysInit */
- /* Initialize all configured peripherals */
- MX_GPIO_Init();
- MX_TIM6_Init();
- MX_USART1_UART_Init();
- MX_USART2_UART_Init();
- MX_I2C2_Init();
- /* Initialize interrupts */
- MX_NVIC_Init();
- /* USER CODE BEGIN 2 */
- HAL_TIM_Base_Start_IT(&htim6);
- HAL_UART_Receive_IT(&huart1, &rx1_data[0],1);
- HAL_UART_Receive_IT(&huart2, &rx2_data[0],1);
- setbuf(stdout, NULL); // \n 을 적을 떄만
- #if 1 // PYJ.2019.03.04_BEGIN --
- printf("****************************************\r\n");
- printf("RGB Project\r\n");
- printf("Build at %s %s\r\n", __DATE__, __TIME__);
- printf("Copyright (c) 2019. BLUECELL\r\n");
- printf("****************************************\r\n");
- #endif // PYJ.2019.03.04_END --
- RGB_SensorIDAutoSet(1);
- Flash_InitRead();
- RGB_Data_Init();
- /* USER CODE END 2 */
- /* Infinite loop */
- /* USER CODE BEGIN WHILE */
- //initialize LoRa module
- SX1276_hw.dio0.port = SX1276_DIO0_GPIO_Port;
- SX1276_hw.dio0.pin = SX1276_DIO0_Pin;
- SX1276_hw.nss.port = GPIOA;
- SX1276_hw.nss.pin = GPIO_PIN_15;
- SX1276_hw.reset.port = SX1276_RESET_GPIO_Port;
- SX1276_hw.reset.pin = SX1276_RESET_Pin;
- // SX1276_hw.spi = &hspi3;
- SX1276.hw = &SX1276_hw;
- printf("Configuring LoRa module\r\n");
- SX1276_begin(&SX1276, SX1276_917MHZ, SX1276_POWER_17DBM, SX1276_LORA_SF_8,
- SX1276_LORA_BW_20_8KHZ, 10);
- printf("Done configuring LoRaModule\r\n");
- master = 0;
- if (master == 1) {
- ret = SX1276_LoRaEntryTx(&SX1276, LORA_MAX_DATA_CNT, 2000);
- } else {
- ret = SX1276_LoRaEntryRx(&SX1276, LORA_MAX_DATA_CNT, 2000);
- }
- #if 0 // PYJ.2019.04.16_BEGIN --
- for(uint8_t i = 0; i < 100; i++){
- Test_data[i] = i;
- M24C32_Data_Write(&hi2c2,&Test_data[i],(uint16_t)i,1);
- }
-
- for(uint8_t i = 0; i < 100; i++){
- printf("%d \n",M24C32_Data_Read(&hi2c2,(uint16_t)i));
- }
- #endif // PYJ.2019.04.16_END --
-
- uint8_t data1[100]= {0,};
- uint8_t data2[100]= {0,};
- uint8_t uartrecv1=0,uartrecv2=0,cnt1 = 0,cnt2=0;
- while (1)
- {
- if(LoraTxTimerCnt > LORA_TIMER_CNT){
- LoraTxTimerCnt = 0;
- // LoraDataSendSet(1);
- }
- RGB_Alarm_Operate();//LED ALARM CHECK
- if(LoraDataSendGet() == LoraTx_mode){
- // LoraDataSendSet(0);
- memcpy(&buffer[0],&Lora_Buf[0],LORA_MAX_DATA_CNT);
- message_length = Lora_Max_Amount + 3;////RGB Data 60byte + stx + etx + crc
- ret = SX1276_LoRaEntryTx(&SX1276, message_length, 2000);
- ret = SX1276_LoRaTxPacket(&SX1276, &buffer[0], message_length, 2000);
- LoraDataSendSet(0);
- ret = SX1276_LoRaEntryRx(&SX1276, LORA_MAX_DATA_CNT, 2000);
- }else {
- ret = SX1276_LoRaRxPacket(&SX1276);
- if (ret > 0) {
- SX1276_read(&SX1276, &buffer[0], ret);
- #if 1 // PYJ.2019.04.22_BEGIN --
- printf("Received Data : ");
- for(uint8_t i = 0; i < ret; i++)
- printf("%02x ", buffer[i]);
- printf("\n");
- #endif // PYJ.2019.04.22_END --
- Uart_dataCheck(&buffer[bluecell_stx],&ret);
- }
- }
-
- if(count_in1 != count_out1){ // <-------
- data1[cnt1++] = buf1[count_out1++];
- if(count_out1 >= 100){ count_out1 = 0; }
- UartTimerCnt = 0;
- // uartrecv1 = 1;
- UartDataRecvSet(1);
- }
- if(count_in2 != count_out2){ // <-------
- data2[cnt2++] = buf2[count_out2++];
- if(count_out2 >= 100){ count_out2 = 0; }
- UartTimerCnt = 0;
- // uartrecv2 = 1;
- UartDataRecvSet(2);
- }
- #if 0 // PYJ.2019.04.19_BEGIN --
- uartdatarecv = UartDataRecvGet();
- if(uartdatarecv != 0){
- if(uartdatarecv == 1){
- Uart_dataCheck(data1,&count_in1);
- }else if(uartdatarecv == 2){
- Uart_dataCheck(data2,&count_in2);
- }
- UartDataRecvSet(0);
- }
- #endif // PYJ.2019.04.19_END --
- uartdatarecv = UartDataRecvGet();
- if(uartdatarecv == 1 && UartTimerCnt > 100){
- cnt1 = 0;
- UartDataRecvSet(0);
- Uart_dataCheck(&data1[0],&count_in1);
- memset(&data1[0],0,100);
- }
- if(uartdatarecv == 2 && UartTimerCnt > 100){
- cnt2 = 0;
- UartDataRecvSet(0);
- Uart_dataCheck(&data2[0],&count_in2);
- memset(&data2[0],0,100);
- }
- else{
- if(LedTimerCnt > 500){
- if(RGB_SensorIDAutoGet() == 1){
- if(SensorID == 0){memset(&SensorID_buf[0],0x00,8);SensorID_Cnt = 0;}
- IDAutoSetRequest_data[bluecell_srcid + 1] = ++SensorID;//DST ID
- if(IDAutoSetRequest_data[bluecell_srcid + 1] > 8){
- RGB_SensorIDAutoSet(0);
- RGB_Sensor_PowerOnOff(0);
- SensorID = 0;
- }else{
- RGB_Sensor_PowerOnOff(IDAutoSetRequest_data[4]);
- HAL_Delay(500);
- RGB_Controller_Func(&IDAutoSetRequest_data[bluecell_stx]);
- HAL_Delay(500);
- }
- }
- else{
- StatusRequest_data[bluecell_srcid + 1] = SensorID_buf[temp_sensorid++];
- if(temp_sensorid > (SensorID_Cnt)){
- temp_sensorid = 0;
- }
- RGB_Controller_Func(&StatusRequest_data[bluecell_stx]);
- }
- HAL_GPIO_TogglePin(GPIOC,GPIO_PIN_15);
- LedTimerCnt = 0;
- }
- }
- /* USER CODE END WHILE */
- /* USER CODE BEGIN 3 */
- }
- /* USER CODE END 3 */
- }
- /**
- * @brief System Clock Configuration
- * @retval None
- */
- void SystemClock_Config(void)
- {
- RCC_OscInitTypeDef RCC_OscInitStruct = {0};
- RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
- /**Initializes the CPU, AHB and APB busses clocks
- */
- RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
- RCC_OscInitStruct.HSEState = RCC_HSE_ON;
- RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1;
- RCC_OscInitStruct.HSIState = RCC_HSI_ON;
- RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
- RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
- RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL2;
- if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
- {
- Error_Handler();
- }
- /**Initializes the CPU, AHB and APB busses clocks
- */
- RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
- |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
- RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
- RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
- RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
- RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
- if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0) != HAL_OK)
- {
- Error_Handler();
- }
- }
- /**
- * @brief NVIC Configuration.
- * @retval None
- */
- static void MX_NVIC_Init(void)
- {
- /* USART2_IRQn interrupt configuration */
- HAL_NVIC_SetPriority(USART2_IRQn, 0, 0);
- HAL_NVIC_EnableIRQ(USART2_IRQn);
- /* USART1_IRQn interrupt configuration */
- HAL_NVIC_SetPriority(USART1_IRQn, 0, 0);
- HAL_NVIC_EnableIRQ(USART1_IRQn);
- /* TIM6_IRQn interrupt configuration */
- HAL_NVIC_SetPriority(TIM6_IRQn, 0, 0);
- HAL_NVIC_EnableIRQ(TIM6_IRQn);
- }
- /**
- * @brief I2C2 Initialization Function
- * @param None
- * @retval None
- */
- static void MX_I2C2_Init(void)
- {
- /* USER CODE BEGIN I2C2_Init 0 */
- /* USER CODE END I2C2_Init 0 */
- /* USER CODE BEGIN I2C2_Init 1 */
- /* USER CODE END I2C2_Init 1 */
- hi2c2.Instance = I2C2;
- hi2c2.Init.ClockSpeed = 100000;
- hi2c2.Init.DutyCycle = I2C_DUTYCYCLE_2;
- hi2c2.Init.OwnAddress1 = 0;
- hi2c2.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
- hi2c2.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
- hi2c2.Init.OwnAddress2 = 0;
- hi2c2.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
- hi2c2.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
- if (HAL_I2C_Init(&hi2c2) != HAL_OK)
- {
- Error_Handler();
- }
- /* USER CODE BEGIN I2C2_Init 2 */
- /* USER CODE END I2C2_Init 2 */
- }
- /**
- * @brief TIM6 Initialization Function
- * @param None
- * @retval None
- */
- static void MX_TIM6_Init(void)
- {
- /* USER CODE BEGIN TIM6_Init 0 */
- /* USER CODE END TIM6_Init 0 */
- TIM_MasterConfigTypeDef sMasterConfig = {0};
- /* USER CODE BEGIN TIM6_Init 1 */
- /* USER CODE END TIM6_Init 1 */
- htim6.Instance = TIM6;
- htim6.Init.Prescaler = 1600-1;
- htim6.Init.CounterMode = TIM_COUNTERMODE_UP;
- htim6.Init.Period = 10-1;
- htim6.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
- if (HAL_TIM_Base_Init(&htim6) != HAL_OK)
- {
- Error_Handler();
- }
- sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
- sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
- if (HAL_TIMEx_MasterConfigSynchronization(&htim6, &sMasterConfig) != HAL_OK)
- {
- Error_Handler();
- }
- /* USER CODE BEGIN TIM6_Init 2 */
- /* USER CODE END TIM6_Init 2 */
- }
- /**
- * @brief USART1 Initialization Function
- * @param None
- * @retval None
- */
- static void MX_USART1_UART_Init(void)
- {
- /* USER CODE BEGIN USART1_Init 0 */
- /* USER CODE END USART1_Init 0 */
- /* USER CODE BEGIN USART1_Init 1 */
- /* USER CODE END USART1_Init 1 */
- huart1.Instance = USART1;
- huart1.Init.BaudRate = 115200;
- huart1.Init.WordLength = UART_WORDLENGTH_8B;
- huart1.Init.StopBits = UART_STOPBITS_1;
- huart1.Init.Parity = UART_PARITY_NONE;
- huart1.Init.Mode = UART_MODE_TX_RX;
- huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;
- huart1.Init.OverSampling = UART_OVERSAMPLING_16;
- if (HAL_UART_Init(&huart1) != HAL_OK)
- {
- Error_Handler();
- }
- /* USER CODE BEGIN USART1_Init 2 */
- /* USER CODE END USART1_Init 2 */
- }
- /**
- * @brief USART2 Initialization Function
- * @param None
- * @retval None
- */
- static void MX_USART2_UART_Init(void)
- {
- /* USER CODE BEGIN USART2_Init 0 */
- /* USER CODE END USART2_Init 0 */
- /* USER CODE BEGIN USART2_Init 1 */
- /* USER CODE END USART2_Init 1 */
- huart2.Instance = USART2;
- huart2.Init.BaudRate = 115200;
- huart2.Init.WordLength = UART_WORDLENGTH_8B;
- huart2.Init.StopBits = UART_STOPBITS_1;
- huart2.Init.Parity = UART_PARITY_NONE;
- huart2.Init.Mode = UART_MODE_TX_RX;
- huart2.Init.HwFlowCtl = UART_HWCONTROL_NONE;
- huart2.Init.OverSampling = UART_OVERSAMPLING_16;
- if (HAL_UART_Init(&huart2) != HAL_OK)
- {
- Error_Handler();
- }
- /* USER CODE BEGIN USART2_Init 2 */
- /* USER CODE END USART2_Init 2 */
- }
- /**
- * @brief GPIO Initialization Function
- * @param None
- * @retval None
- */
- static void MX_GPIO_Init(void)
- {
- GPIO_InitTypeDef GPIO_InitStruct = {0};
- /* GPIO Ports Clock Enable */
- __HAL_RCC_GPIOC_CLK_ENABLE();
- __HAL_RCC_GPIOD_CLK_ENABLE();
- __HAL_RCC_GPIOA_CLK_ENABLE();
- __HAL_RCC_GPIOB_CLK_ENABLE();
- /*Configure GPIO pin Output Level */
- HAL_GPIO_WritePin(GPIOC, BOOT_LED_Pin|SX1276_DIO4_Pin|SX1276_DIO5_Pin|SENSOR_EN4_Pin
- |SENSOR_EN5_Pin|SENSOR_EN6_Pin|SENSOR_EN7_Pin|LED_CH1_Pin
- |LED_CH2_Pin|LED_CH3_Pin, GPIO_PIN_RESET);
- /*Configure GPIO pin Output Level */
- HAL_GPIO_WritePin(GPIOA, SX1276_DIO0_Pin|SX1276_DIO1_Pin|SX1276_DIO2_Pin|SX1276_DIO3_Pin
- |SENSOR_EN8_Pin|SX1276_NSS_Pin, GPIO_PIN_RESET);
- /*Configure GPIO pin Output Level */
- HAL_GPIO_WritePin(GPIOB, SX1276_RESET_Pin|LED_ALARM_Pin|SENSOR_EN1_Pin|SENSOR_EN2_Pin
- |SENSOR_EN3_Pin|SX1276_CLK_Pin|SX1276_MOSI_Pin|LED_CH5_Pin
- |LED_CH6_Pin|LED_CH7_Pin|LED_CH8_Pin, GPIO_PIN_RESET);
- /*Configure GPIO pin Output Level */
- HAL_GPIO_WritePin(LED_CH4_GPIO_Port, LED_CH4_Pin, GPIO_PIN_RESET);
- /*Configure GPIO pins : BOOT_LED_Pin SX1276_DIO4_Pin SX1276_DIO5_Pin SENSOR_EN4_Pin
- SENSOR_EN5_Pin SENSOR_EN6_Pin SENSOR_EN7_Pin LED_CH1_Pin
- LED_CH2_Pin LED_CH3_Pin */
- GPIO_InitStruct.Pin = BOOT_LED_Pin|SX1276_DIO4_Pin|SX1276_DIO5_Pin|SENSOR_EN4_Pin
- |SENSOR_EN5_Pin|SENSOR_EN6_Pin|SENSOR_EN7_Pin|LED_CH1_Pin
- |LED_CH2_Pin|LED_CH3_Pin;
- GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
- GPIO_InitStruct.Pull = GPIO_NOPULL;
- GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
- HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
- /*Configure GPIO pins : SX1276_DIO0_Pin SX1276_DIO1_Pin SX1276_DIO2_Pin SX1276_DIO3_Pin
- SENSOR_EN8_Pin SX1276_NSS_Pin */
- GPIO_InitStruct.Pin = SX1276_DIO0_Pin|SX1276_DIO1_Pin|SX1276_DIO2_Pin|SX1276_DIO3_Pin
- |SENSOR_EN8_Pin|SX1276_NSS_Pin;
- GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
- GPIO_InitStruct.Pull = GPIO_NOPULL;
- GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
- HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
- /*Configure GPIO pins : SX1276_RESET_Pin LED_ALARM_Pin SENSOR_EN1_Pin SENSOR_EN2_Pin
- SENSOR_EN3_Pin SX1276_CLK_Pin SX1276_MOSI_Pin LED_CH5_Pin
- LED_CH6_Pin LED_CH7_Pin LED_CH8_Pin */
- GPIO_InitStruct.Pin = SX1276_RESET_Pin|LED_ALARM_Pin|SENSOR_EN1_Pin|SENSOR_EN2_Pin
- |SENSOR_EN3_Pin|SX1276_CLK_Pin|SX1276_MOSI_Pin|LED_CH5_Pin
- |LED_CH6_Pin|LED_CH7_Pin|LED_CH8_Pin;
- GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
- GPIO_InitStruct.Pull = GPIO_NOPULL;
- GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
- HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
- /*Configure GPIO pin : LED_CH4_Pin */
- GPIO_InitStruct.Pin = LED_CH4_Pin;
- GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
- GPIO_InitStruct.Pull = GPIO_NOPULL;
- GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
- HAL_GPIO_Init(LED_CH4_GPIO_Port, &GPIO_InitStruct);
- /*Configure GPIO pin : SX1276_MISO_Pin */
- GPIO_InitStruct.Pin = SX1276_MISO_Pin;
- GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
- GPIO_InitStruct.Pull = GPIO_NOPULL;
- HAL_GPIO_Init(SX1276_MISO_GPIO_Port, &GPIO_InitStruct);
- }
- /* USER CODE BEGIN 4 */
- /* USER CODE END 4 */
- /**
- * @brief This function is executed in case of error occurrence.
- * @retval None
- */
- void Error_Handler(void)
- {
- /* USER CODE BEGIN Error_Handler_Debug */
- /* User can add his own implementation to report the HAL error return state */
- /* USER CODE END Error_Handler_Debug */
- }
- #ifdef USE_FULL_ASSERT
- /**
- * @brief Reports the name of the source file and the source line number
- * where the assert_param error has occurred.
- * @param file: pointer to the source file name
- * @param line: assert_param error line source number
- * @retval None
- */
- void assert_failed(uint8_t *file, uint32_t line)
- {
- /* USER CODE BEGIN 6 */
- /* User can add his own implementation to report the file name and line number,
- tex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
- /* USER CODE END 6 */
- }
- #endif /* USE_FULL_ASSERT */
- /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|