| | |
| | | #define NSH1 0x0001 |
| | | #define GP 0x0002 |
| | | #define FLASH_HARDWARE_VERSION_MAP (uint32_t)0x08004F00 //硬件版本号和批次信息位置 |
| | | #define DEBUG_MODE |
| | | //#define DEBUG_MODE |
| | | /* USER CODE END Includes */ |
| | | |
| | | /* Private typedef -----------------------------------------------------------*/ |
| | |
| | | __HAL_LPTIM_COMPARE_SET(&hlptim1, lpcount); |
| | | |
| | | } |
| | | |
| | | /* 返回ch字符在sign数组中的序号 */ |
| | | int getIndexOfSigns(char ch) |
| | | { |
| | | if(ch >= '0' && ch <= '9') |
| | | { |
| | | return ch - '0'; |
| | | } |
| | | if(ch >= 'A' && ch <='F') |
| | | { |
| | | return ch - 'A' + 10; |
| | | } |
| | | if(ch >= 'a' && ch <= 'f') |
| | | { |
| | | return ch - 'a' + 10; |
| | | } |
| | | return -1; |
| | | } |
| | | /* 十六进制数转换为十进制数 */ |
| | | long hexToDec(char *source) |
| | | { |
| | | long sum = 0; |
| | | long t = 1; |
| | | int i, len; |
| | | |
| | | len = strlen(source); |
| | | for(i=len-1; i>=0; i--) |
| | | { |
| | | sum += t * getIndexOfSigns(*(source + i)); |
| | | t *= 16; |
| | | } |
| | | |
| | | return sum; |
| | | } |
| | | |
| | | u32 Loratx_frequency; |
| | | u8 active_flag,nomovesleeptime; |
| | | void GetLoratx_frequency(void) |
| | | { |
| | | if(g_com_map[NEARBASE_ID1]==0x470) |
| | | {Loratx_frequency=470000000;} |
| | | if(g_com_map[NEARBASE_ID1]==0x471) |
| | | {Loratx_frequency=471000000;} |
| | | if(g_com_map[NEARBASE_ID1]==0x472) |
| | | {Loratx_frequency=472000000;} |
| | | if(g_com_map[NEARBASE_ID1]==0x473) |
| | | {Loratx_frequency=473000000;} |
| | | if(g_com_map[NEARBASE_ID1]==0x474) |
| | | {Loratx_frequency=474000000;} |
| | | if(g_com_map[NEARBASE_ID1]==0x475) |
| | | {Loratx_frequency=475000000;} |
| | | if(g_com_map[NEARBASE_ID1]==0x476) |
| | | {Loratx_frequency=476000000;} |
| | | if(g_com_map[NEARBASE_ID1]==0x477) |
| | | {Loratx_frequency=477000000;} |
| | | if(g_com_map[NEARBASE_ID1]==0x478) |
| | | {Loratx_frequency=478000000;} |
| | | if(g_com_map[NEARBASE_ID1]==0x479) |
| | | {Loratx_frequency=479000000;} |
| | | if(g_com_map[NEARBASE_ID1]==0x480) |
| | | {Loratx_frequency=480000000;} |
| | | if(g_com_map[NEARBASE_ID1]==0x481) |
| | | {Loratx_frequency=481000000;} |
| | | if(g_com_map[NEARBASE_ID1]==0x482) |
| | | {Loratx_frequency=482000000;} |
| | | if(g_com_map[NEARBASE_ID1]==0x483) |
| | | {Loratx_frequency=483000000;} |
| | | if(g_com_map[NEARBASE_ID1]==0x484) |
| | | {Loratx_frequency=484000000;} |
| | | if(g_com_map[NEARBASE_ID1]==0x485) |
| | | {Loratx_frequency=485000000;} |
| | | if(g_com_map[NEARBASE_ID1]==0x486) |
| | | {Loratx_frequency=486000000;} |
| | | if(g_com_map[NEARBASE_ID1]==0x487) |
| | | {Loratx_frequency=487000000;} |
| | | if(g_com_map[NEARBASE_ID1]==0x488) |
| | | {Loratx_frequency=488000000;} |
| | | if(g_com_map[NEARBASE_ID1]==0x489) |
| | | {Loratx_frequency=489000000;} |
| | | if(g_com_map[NEARBASE_ID1]==0x490) |
| | | {Loratx_frequency=490000000;} |
| | | } |
| | | void Program_Init(void) |
| | | { float temp; |
| | | uint16_t temp2; |
| | |
| | | g_com_map[IMU_ENABLE] = 0; |
| | | imu_enable=g_com_map[IMU_ENABLE]; |
| | | motor_enable=g_com_map[MOTOR_ENABLE]; |
| | | GetLoratx_frequency(); |
| | | |
| | | group_id=g_com_map[GROUP_ID]; |
| | | dev_id = g_com_map[DEV_ID]; |
| | |
| | | /* Initialize all configured peripherals */ |
| | | MX_GPIO_Init(); |
| | | MX_LPTIM1_Init(); |
| | | MX_DMA_Init(); |
| | | MX_USART1_UART_Init(); |
| | | MX_SPI1_Init(); |
| | | MX_ADC_Init(); |
| | | MX_DMA_Init(); |
| | | |
| | | MX_IWDG_Init(); |
| | | /* USER CODE BEGIN 2 */ |
| | | // LED_LG_ON; |
| | |
| | | HAL_GPIO_WritePin(GPIOB, BAT_MEAS_GND_Pin|SDA_Pin|SCL_Pin, GPIO_PIN_SET); |
| | | |
| | | /*Configure GPIO pin Output Level */ |
| | | HAL_GPIO_WritePin(GPIOB, GPIO_PIN_10|LED1_G_Pin|LED1_R_Pin|RADIO_nRESET_Pin |
| | | |RADIO_NSS_Pin|GPIO_PIN_7, GPIO_PIN_RESET); |
| | | HAL_GPIO_WritePin(GPIOB, GPIO_PIN_10|LED1_G_Pin|LED1_R_Pin|GPIO_PIN_14 |
| | | |RADIO_nRESET_Pin|RADIO_NSS_Pin|GPIO_PIN_7, GPIO_PIN_RESET); |
| | | |
| | | /*Configure GPIO pin Output Level */ |
| | | HAL_GPIO_WritePin(GPIOA, GPIO_PIN_8|DW_CTRL_Pin|LED2_G_Pin, GPIO_PIN_RESET); |
| | |
| | | GPIO_InitStruct.Pull = GPIO_NOPULL; |
| | | HAL_GPIO_Init(RADIO_BUSY_GPIO_Port, &GPIO_InitStruct); |
| | | |
| | | /*Configure GPIO pins : PB10 LED1_G_Pin LED1_R_Pin RADIO_nRESET_Pin |
| | | RADIO_NSS_Pin PB7 */ |
| | | GPIO_InitStruct.Pin = GPIO_PIN_10|LED1_G_Pin|LED1_R_Pin|RADIO_nRESET_Pin |
| | | |RADIO_NSS_Pin|GPIO_PIN_7; |
| | | /*Configure GPIO pins : PB10 LED1_G_Pin LED1_R_Pin PB14 |
| | | RADIO_nRESET_Pin RADIO_NSS_Pin PB7 */ |
| | | GPIO_InitStruct.Pin = GPIO_PIN_10|LED1_G_Pin|LED1_R_Pin|GPIO_PIN_14 |
| | | |RADIO_nRESET_Pin|RADIO_NSS_Pin|GPIO_PIN_7; |
| | | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; |
| | | GPIO_InitStruct.Pull = GPIO_NOPULL; |
| | | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |