├── README.txt ├── User ├── main.c ├── Bsp │ ├── key │ │ ├── key.c │ │ ├── key.h │ │ ├── bsp_key.c │ │ └── bsp_key.h │ ├── EC20 │ │ ├── ec20.c │ │ └── ec20.h │ ├── IWDG │ │ ├── iwdg.c │ │ └── iwdg.h │ ├── gpio │ │ ├── gpio.h │ │ └── gpio.c │ ├── timer │ │ ├── timer.c │ │ └── timer.h │ ├── usart │ │ ├── usart.c │ │ ├── usart.h │ │ ├── bsp_usart.c │ │ └── bsp_usart.h │ ├── USART2 │ │ ├── usart2.c │ │ └── usart2.h │ ├── gps │ │ ├── gps_config.c │ │ └── gps_config.h │ └── internal_flash │ │ ├── bsp_internal_flash.c │ │ └── bsp_internal_flash.h ├── delay │ ├── delay.c │ └── delay.h ├── nema_decode_test.c ├── nmea_decode │ ├── src │ │ ├── time.c │ │ ├── parser.c │ │ ├── info.c │ │ ├── context.c │ │ ├── sentence.c │ │ ├── nmea.vcxproj │ │ ├── tok.c │ │ └── generate.c │ └── include │ │ └── nmea │ │ ├── info.h │ │ ├── sentence.h │ │ ├── nmea.h │ │ ├── tok.h │ │ ├── units.h │ │ ├── context.h │ │ ├── time.h │ │ ├── config.h │ │ ├── parser.h │ │ ├── generate.h │ │ ├── generator.h │ │ ├── parse.h │ │ └── gmath.h ├── jt808 │ ├── src │ │ ├── jt808_parser.c │ │ ├── client_manager.c │ │ ├── bcd.c │ │ ├── terminal_register.c │ │ ├── location_report.c │ │ ├── util.c │ │ └── gbk_utf8.c │ └── include │ │ ├── jt808_parser.h │ │ ├── jt808_packager.h │ │ ├── gbk_utf8.h │ │ ├── terminal_control.h │ │ ├── util.h │ │ ├── bcd.h │ │ ├── set_terminal_parameter.h │ │ ├── terminal_register.h │ │ ├── client_manager.h │ │ └── protocol_parameter.h ├── FATFS │ ├── drivers │ │ ├── fatfs_sd_sdio.c │ │ ├── fatfs_sd_sdio.h │ │ ├── fatfs_flash_spi.c │ │ └── fatfs_flash_spi.h │ ├── option │ │ ├── unicode.c │ │ └── syscall.c │ ├── integer.h │ ├── 00readme.txt │ ├── diskio.h │ ├── diskio.c │ └── 00history.txt ├── internal_flash │ ├── bsp_internal_flash.c │ └── bsp_internal_flash.h ├── stm32f10x_it.h ├── stm32f10x_conf.h └── stm32f10x_it.c ├── system ├── sys │ ├── sys.c │ └── sys.h └── delay │ ├── delay.c │ └── delay.h ├── .gitattributes ├── Libraries ├── CMSIS │ ├── stm32f10x.h │ └── system_stm32f10x.h └── FWlib │ ├── src │ ├── stm32f10x_i2c.c │ ├── stm32f10x_flash.c │ ├── stm32f10x_usart.c │ ├── stm32f10x_crc.c │ ├── stm32f10x_iwdg.c │ ├── stm32f10x_dbgmcu.c │ ├── stm32f10x_wwdg.c │ ├── misc.c │ └── stm32f10x_exti.c │ └── inc │ ├── stm32f10x_crc.h │ ├── stm32f10x_wwdg.h │ ├── stm32f10x_dbgmcu.h │ ├── stm32f10x_iwdg.h │ ├── stm32f10x_rtc.h │ ├── stm32f10x_pwr.h │ ├── stm32f10x_cec.h │ ├── stm32f10x_exti.h │ └── stm32f10x_bkp.h └── Project └── RVMDK(uv5) ├── BH-F103_GPS.dep ├── bin_file └── Template.bin ├── RTE ├── RTE_Components.h └── _GPS │ └── RTE_Components.h ├── JLinkSettings.ini └── DebugConfig └── GPS_STM32F103RC_1.0.0.dbgconf /README.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/myqpy/Jt808/HEAD/README.txt -------------------------------------------------------------------------------- /User/main.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/myqpy/Jt808/HEAD/User/main.c -------------------------------------------------------------------------------- /User/Bsp/key/key.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/myqpy/Jt808/HEAD/User/Bsp/key/key.c -------------------------------------------------------------------------------- /User/Bsp/key/key.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/myqpy/Jt808/HEAD/User/Bsp/key/key.h -------------------------------------------------------------------------------- /User/delay/delay.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/myqpy/Jt808/HEAD/User/delay/delay.c -------------------------------------------------------------------------------- /system/sys/sys.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/myqpy/Jt808/HEAD/system/sys/sys.c -------------------------------------------------------------------------------- /system/sys/sys.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/myqpy/Jt808/HEAD/system/sys/sys.h -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /User/Bsp/EC20/ec20.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/myqpy/Jt808/HEAD/User/Bsp/EC20/ec20.c -------------------------------------------------------------------------------- /User/Bsp/EC20/ec20.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/myqpy/Jt808/HEAD/User/Bsp/EC20/ec20.h -------------------------------------------------------------------------------- /User/Bsp/IWDG/iwdg.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/myqpy/Jt808/HEAD/User/Bsp/IWDG/iwdg.c -------------------------------------------------------------------------------- /User/Bsp/IWDG/iwdg.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/myqpy/Jt808/HEAD/User/Bsp/IWDG/iwdg.h -------------------------------------------------------------------------------- /User/Bsp/gpio/gpio.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/myqpy/Jt808/HEAD/User/Bsp/gpio/gpio.h -------------------------------------------------------------------------------- /system/delay/delay.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/myqpy/Jt808/HEAD/system/delay/delay.c -------------------------------------------------------------------------------- /User/Bsp/key/bsp_key.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/myqpy/Jt808/HEAD/User/Bsp/key/bsp_key.c -------------------------------------------------------------------------------- /User/Bsp/key/bsp_key.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/myqpy/Jt808/HEAD/User/Bsp/key/bsp_key.h -------------------------------------------------------------------------------- /User/Bsp/timer/timer.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/myqpy/Jt808/HEAD/User/Bsp/timer/timer.c -------------------------------------------------------------------------------- /User/Bsp/usart/usart.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/myqpy/Jt808/HEAD/User/Bsp/usart/usart.c -------------------------------------------------------------------------------- /User/Bsp/usart/usart.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/myqpy/Jt808/HEAD/User/Bsp/usart/usart.h -------------------------------------------------------------------------------- /User/nema_decode_test.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/myqpy/Jt808/HEAD/User/nema_decode_test.c -------------------------------------------------------------------------------- /User/Bsp/USART2/usart2.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/myqpy/Jt808/HEAD/User/Bsp/USART2/usart2.c -------------------------------------------------------------------------------- /User/Bsp/USART2/usart2.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/myqpy/Jt808/HEAD/User/Bsp/USART2/usart2.h -------------------------------------------------------------------------------- /User/Bsp/gps/gps_config.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/myqpy/Jt808/HEAD/User/Bsp/gps/gps_config.c -------------------------------------------------------------------------------- /User/Bsp/gps/gps_config.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/myqpy/Jt808/HEAD/User/Bsp/gps/gps_config.h -------------------------------------------------------------------------------- /Libraries/CMSIS/stm32f10x.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/myqpy/Jt808/HEAD/Libraries/CMSIS/stm32f10x.h -------------------------------------------------------------------------------- /User/Bsp/usart/bsp_usart.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/myqpy/Jt808/HEAD/User/Bsp/usart/bsp_usart.c -------------------------------------------------------------------------------- /User/Bsp/usart/bsp_usart.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/myqpy/Jt808/HEAD/User/Bsp/usart/bsp_usart.h -------------------------------------------------------------------------------- /User/nmea_decode/src/time.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/myqpy/Jt808/HEAD/User/nmea_decode/src/time.c -------------------------------------------------------------------------------- /User/jt808/src/jt808_parser.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/myqpy/Jt808/HEAD/User/jt808/src/jt808_parser.c -------------------------------------------------------------------------------- /User/nmea_decode/src/parser.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/myqpy/Jt808/HEAD/User/nmea_decode/src/parser.c -------------------------------------------------------------------------------- /User/jt808/src/client_manager.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/myqpy/Jt808/HEAD/User/jt808/src/client_manager.c -------------------------------------------------------------------------------- /Libraries/FWlib/src/stm32f10x_i2c.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/myqpy/Jt808/HEAD/Libraries/FWlib/src/stm32f10x_i2c.c -------------------------------------------------------------------------------- /Project/RVMDK(uv5)/BH-F103_GPS.dep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/myqpy/Jt808/HEAD/Project/RVMDK(uv5)/BH-F103_GPS.dep -------------------------------------------------------------------------------- /User/FATFS/drivers/fatfs_sd_sdio.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/myqpy/Jt808/HEAD/User/FATFS/drivers/fatfs_sd_sdio.c -------------------------------------------------------------------------------- /User/FATFS/drivers/fatfs_sd_sdio.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/myqpy/Jt808/HEAD/User/FATFS/drivers/fatfs_sd_sdio.h -------------------------------------------------------------------------------- /Libraries/FWlib/src/stm32f10x_flash.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/myqpy/Jt808/HEAD/Libraries/FWlib/src/stm32f10x_flash.c -------------------------------------------------------------------------------- /Libraries/FWlib/src/stm32f10x_usart.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/myqpy/Jt808/HEAD/Libraries/FWlib/src/stm32f10x_usart.c -------------------------------------------------------------------------------- /User/FATFS/drivers/fatfs_flash_spi.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/myqpy/Jt808/HEAD/User/FATFS/drivers/fatfs_flash_spi.c -------------------------------------------------------------------------------- /User/FATFS/drivers/fatfs_flash_spi.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/myqpy/Jt808/HEAD/User/FATFS/drivers/fatfs_flash_spi.h -------------------------------------------------------------------------------- /User/nmea_decode/include/nmea/info.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/myqpy/Jt808/HEAD/User/nmea_decode/include/nmea/info.h -------------------------------------------------------------------------------- /Project/RVMDK(uv5)/bin_file/Template.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/myqpy/Jt808/HEAD/Project/RVMDK(uv5)/bin_file/Template.bin -------------------------------------------------------------------------------- /User/internal_flash/bsp_internal_flash.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/myqpy/Jt808/HEAD/User/internal_flash/bsp_internal_flash.c -------------------------------------------------------------------------------- /User/internal_flash/bsp_internal_flash.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/myqpy/Jt808/HEAD/User/internal_flash/bsp_internal_flash.h -------------------------------------------------------------------------------- /User/nmea_decode/include/nmea/sentence.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/myqpy/Jt808/HEAD/User/nmea_decode/include/nmea/sentence.h -------------------------------------------------------------------------------- /User/Bsp/internal_flash/bsp_internal_flash.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/myqpy/Jt808/HEAD/User/Bsp/internal_flash/bsp_internal_flash.c -------------------------------------------------------------------------------- /User/Bsp/internal_flash/bsp_internal_flash.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/myqpy/Jt808/HEAD/User/Bsp/internal_flash/bsp_internal_flash.h -------------------------------------------------------------------------------- /User/Bsp/timer/timer.h: -------------------------------------------------------------------------------- 1 | 2 | #include "./sys/sys.h" 3 | 4 | void Tim3_Int_Init(u16 arr,u16 psc); 5 | //void TIM3_IRQHandler(int time_1s); 6 | void TIM4_Set(u8 sta); 7 | void TIM4_SetARR(u16 period); 8 | void TIM4_Init(u16 arr,u16 psc); 9 | -------------------------------------------------------------------------------- /system/delay/delay.h: -------------------------------------------------------------------------------- 1 | #ifndef __DELAY_H 2 | #define __DELAY_H 3 | #include "./sys/sys.h" 4 | 5 | void delay_init(void); 6 | void delay_ms(u16 nms); 7 | void delay_us(u32 nus); 8 | 9 | #endif 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /User/delay/delay.h: -------------------------------------------------------------------------------- 1 | #ifndef __DELAY_H 2 | #define __DELAY_H 3 | //#include "sys.h" 4 | #include "stm32f10x.h" 5 | 6 | void delay_init(void); 7 | void delay_ms(u16 nms); 8 | void delay_us(u32 nus); 9 | 10 | #endif 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /Project/RVMDK(uv5)/RTE/RTE_Components.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Auto generated Run-Time-Environment Component Configuration File 4 | * *** Do not modify ! *** 5 | * 6 | * Project: 'BH-F103' 7 | * Target: 'GPS' 8 | */ 9 | 10 | #ifndef RTE_COMPONENTS_H 11 | #define RTE_COMPONENTS_H 12 | 13 | 14 | /* 15 | * Define the Device Header File: 16 | */ 17 | #define CMSIS_device_header "stm32f10x.h" 18 | 19 | 20 | #endif /* RTE_COMPONENTS_H */ 21 | -------------------------------------------------------------------------------- /Project/RVMDK(uv5)/RTE/_GPS/RTE_Components.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Auto generated Run-Time-Environment Configuration File 4 | * *** Do not modify ! *** 5 | * 6 | * Project: 'BH-F103 ' 7 | * Target: 'GPS' 8 | */ 9 | 10 | #ifndef RTE_COMPONENTS_H 11 | #define RTE_COMPONENTS_H 12 | 13 | 14 | /* 15 | * Define the Device Header File: 16 | */ 17 | #define CMSIS_device_header "stm32f10x.h" 18 | 19 | 20 | 21 | #endif /* RTE_COMPONENTS_H */ 22 | -------------------------------------------------------------------------------- /User/FATFS/option/unicode.c: -------------------------------------------------------------------------------- 1 | #include "../ff.h" 2 | 3 | #if _USE_LFN != 0 4 | 5 | #if _CODE_PAGE == 932 /* Japanese Shift_JIS */ 6 | #include "cc932.c" 7 | #elif _CODE_PAGE == 936 /* Simplified Chinese GBK */ 8 | #include "cc936.c" 9 | #elif _CODE_PAGE == 949 /* Korean */ 10 | #include "cc949.c" 11 | #elif _CODE_PAGE == 950 /* Traditional Chinese Big5 */ 12 | #include "cc950.c" 13 | #else /* Single Byte Character-Set */ 14 | #include "ccsbcs.c" 15 | #endif 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /User/nmea_decode/src/info.c: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * NMEA library 4 | * URL: http://nmea.sourceforge.net 5 | * Author: Tim (xtimor@gmail.com) 6 | * Licence: http://www.gnu.org/licenses/lgpl.html 7 | * $Id: info.c 17 2008-03-11 11:56:11Z xtimor $ 8 | * 9 | */ 10 | 11 | #include 12 | 13 | #include "nmea/info.h" 14 | 15 | void nmea_zero_INFO(nmeaINFO *info) 16 | { 17 | memset(info, 0, sizeof(nmeaINFO)); 18 | nmea_time_now(&info->utc); 19 | info->sig = NMEA_SIG_BAD; 20 | info->fix = NMEA_FIX_BAD; 21 | } 22 | -------------------------------------------------------------------------------- /User/jt808/include/jt808_parser.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | #ifndef JT808_PARSER_H_ 4 | #define JT808_PARSER_H_ 5 | 6 | //#include 7 | //#include 8 | //#include 9 | //#include 10 | //#include "protocol_parameter.h" 11 | //#include "ff.h" 12 | 13 | #define PARSER_NUM 9 14 | #define BUFFER_SIZE_RECEIVE 10240 // buffer size 发送缓存大小 15 | 16 | extern unsigned short kTerminalParserCMD[PARSER_NUM]; 17 | extern struct ProtocolParameter parameter_; 18 | int jt808FrameParse(const unsigned char *in, unsigned int in_len, struct ProtocolParameter *para); 19 | 20 | #endif // JT808_PARSER_H_ 21 | -------------------------------------------------------------------------------- /User/jt808/include/jt808_packager.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #define PACKAGER_NUM 9 //终端打包器命令相应消息ID数量 7 | #define BUFFER_SIZE_SEND 1024 // buffer size 发送缓存大小 8 | 9 | #include "protocol_parameter.h" 10 | #include "terminal_register.h" 11 | #include "bcd.h" 12 | #include "ff.h" 13 | 14 | 15 | 16 | extern unsigned short kTerminalPackagerCMD[PACKAGER_NUM]; 17 | extern unsigned char BufferSend[BUFFER_SIZE_SEND]; //发送缓存 18 | extern unsigned int RealBufferSendSize; 19 | 20 | int jt808FramePackage(struct ProtocolParameter *para); 21 | 22 | -------------------------------------------------------------------------------- /User/nmea_decode/include/nmea/nmea.h: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * NMEA library 4 | * URL: http://nmea.sourceforge.net 5 | * Author: Tim (xtimor@gmail.com) 6 | * Licence: http://www.gnu.org/licenses/lgpl.html 7 | * $Id: nmea.h 17 2008-03-11 11:56:11Z xtimor $ 8 | * 9 | */ 10 | 11 | #ifndef __NMEA_H__ 12 | #define __NMEA_H__ 13 | 14 | #include "./config.h" 15 | #include "./units.h" 16 | #include "./gmath.h" 17 | #include "./info.h" 18 | #include "./sentence.h" 19 | #include "./generate.h" 20 | #include "./generator.h" 21 | #include "./parse.h" 22 | #include "./parser.h" 23 | #include "./context.h" 24 | 25 | #endif /* __NMEA_H__ */ 26 | -------------------------------------------------------------------------------- /Project/RVMDK(uv5)/JLinkSettings.ini: -------------------------------------------------------------------------------- 1 | [BREAKPOINTS] 2 | ShowInfoWin = 1 3 | EnableFlashBP = 2 4 | BPDuringExecution = 0 5 | [CFI] 6 | CFISize = 0x00 7 | CFIAddr = 0x00 8 | [CPU] 9 | OverrideMemMap = 0 10 | AllowSimulation = 1 11 | ScriptFile="" 12 | [FLASH] 13 | MinNumBytesFlashDL = 0 14 | SkipProgOnCRCMatch = 1 15 | VerifyDownload = 1 16 | AllowCaching = 1 17 | EnableFlashDL = 2 18 | Override = 0 19 | Device="AD7160" 20 | [GENERAL] 21 | WorkRAMSize = 0x00 22 | WorkRAMAddr = 0x00 23 | [SWO] 24 | SWOLogFile="" 25 | [MEM] 26 | RdOverrideOrMask = 0x00 27 | RdOverrideAndMask = 0xFFFFFFFF 28 | RdOverrideAddr = 0xFFFFFFFF 29 | WrOverrideOrMask = 0x00 30 | WrOverrideAndMask = 0xFFFFFFFF 31 | WrOverrideAddr = 0xFFFFFFFF 32 | -------------------------------------------------------------------------------- /User/jt808/include/gbk_utf8.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | #ifndef JT808_GBK_UTF8_H_ 4 | #define JT808_GBK_UTF8_H_ 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | /* 11 | namespace libjt808 12 | { 13 | #ifdef _WIN32 14 | std::string GbkToUtf8(const char *src_str); 15 | std::string Utf8ToGbk(const char *src_str); 16 | #else 17 | int GbkToUtf8(char *str_str, size_t src_len, char *dst_str, size_t dst_len); 18 | int Utf8ToGbk(char *src_str, size_t src_len, char *dst_str, size_t dst_len); 19 | #endif 20 | 21 | std::string gbk_to_utf8_str(const std::vector &gbk_src); 22 | std::string gbk_to_utf8_str(const std::string &str_gbk_src); 23 | } 24 | s 25 | 26 | 27 | */ 28 | #endif // JT808_GBK_UTF8_H_ 29 | 30 | -------------------------------------------------------------------------------- /User/FATFS/integer.h: -------------------------------------------------------------------------------- 1 | /*-------------------------------------------*/ 2 | /* Integer type definitions for FatFs module */ 3 | /*-------------------------------------------*/ 4 | 5 | #ifndef _FF_INTEGER 6 | #define _FF_INTEGER 7 | 8 | #ifdef _WIN32 /* Development platform */ 9 | 10 | #include 11 | #include 12 | 13 | #else /* Embedded platform */ 14 | 15 | /* This type MUST be 8-bit */ 16 | typedef unsigned char BYTE; 17 | 18 | /* These types MUST be 16-bit */ 19 | typedef short SHORT; 20 | typedef unsigned short WORD; 21 | typedef unsigned short WCHAR; 22 | 23 | /* These types MUST be 16-bit or 32-bit */ 24 | typedef int INT; 25 | typedef unsigned int UINT; 26 | 27 | /* These types MUST be 32-bit */ 28 | typedef long LONG; 29 | typedef unsigned long DWORD; 30 | 31 | #endif 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /User/nmea_decode/include/nmea/tok.h: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * NMEA library 4 | * URL: http://nmea.sourceforge.net 5 | * Author: Tim (xtimor@gmail.com) 6 | * Licence: http://www.gnu.org/licenses/lgpl.html 7 | * $Id: tok.h 4 2007-08-27 13:11:03Z xtimor $ 8 | * 9 | */ 10 | 11 | #ifndef __NMEA_TOK_H__ 12 | #define __NMEA_TOK_H__ 13 | 14 | #include "config.h" 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | int nmea_calc_crc(const char *buff, int buff_sz); 21 | int nmea_atoi(const char *str, int str_sz, int radix); 22 | double nmea_atof(const char *str, int str_sz); 23 | int nmea_printf(char *buff, int buff_sz, const char *format, ...); 24 | int nmea_scanf(const char *buff, int buff_sz, const char *format, ...); 25 | 26 | #ifdef __cplusplus 27 | } 28 | #endif 29 | 30 | #endif /* __NMEA_TOK_H__ */ 31 | -------------------------------------------------------------------------------- /User/FATFS/00readme.txt: -------------------------------------------------------------------------------- 1 | FatFs Module Source Files R0.11 2 | 3 | 4 | FILES 5 | 6 | 00readme.txt This file. 7 | history.txt Revision history. 8 | ffconf.h Configuration file for FatFs module. 9 | ff.h Common include file for FatFs and application module. 10 | ff.c FatFs module. 11 | diskio.h Common include file for FatFs and disk I/O module. 12 | diskio.c An example of glue function to attach existing disk I/O module to FatFs. 13 | integer.h Integer type definitions for FatFs. 14 | option Optional external functions. 15 | 16 | 17 | Low level disk I/O module is not included in this archive because the FatFs 18 | module is only a generic file system layer and not depend on any specific 19 | storage device. You have to provide a low level disk I/O module that written 20 | to control the target storage device. 21 | 22 | -------------------------------------------------------------------------------- /User/nmea_decode/include/nmea/units.h: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * NMEA library 4 | * URL: http://nmea.sourceforge.net 5 | * Author: Tim (xtimor@gmail.com) 6 | * Licence: http://www.gnu.org/licenses/lgpl.html 7 | * $Id: units.h 4 2007-08-27 13:11:03Z xtimor $ 8 | * 9 | */ 10 | 11 | #ifndef __NMEA_UNITS_H__ 12 | #define __NMEA_UNITS_H__ 13 | 14 | #include "config.h" 15 | 16 | /* 17 | * Distance units 18 | */ 19 | 20 | #define NMEA_TUD_YARDS (1.0936) /**< Yeards, meter * NMEA_TUD_YARDS = yard */ 21 | #define NMEA_TUD_KNOTS (1.852) /**< Knots, kilometer / NMEA_TUD_KNOTS = knot */ 22 | #define NMEA_TUD_MILES (1.609) /**< Miles, kilometer / NMEA_TUD_MILES = mile */ 23 | 24 | /* 25 | * Speed units 26 | */ 27 | 28 | #define NMEA_TUS_MS (3.6) /**< Meters per seconds, (k/h) / NMEA_TUS_MS= (m/s) */ 29 | 30 | #endif /* __NMEA_UNITS_H__ */ 31 | -------------------------------------------------------------------------------- /User/jt808/include/terminal_control.h: -------------------------------------------------------------------------------- 1 | #ifndef JT808_TERMINAL_CONTROL_H_ 2 | #define JT808_TERMINAL_CONTROL_H_ 3 | 4 | #include 5 | #include 6 | //#include 7 | #include 8 | #include "util.h" 9 | 10 | // 0x8105终端控制命令字. 11 | union TerminalCtrlCmdByte 12 | { 13 | struct 14 | { 15 | unsigned char u8val_0 : 1; // 16 | unsigned char u8val_1 : 1; // 无线升级 17 | unsigned char u8val_2 : 1; // 控制终端连接指定服务器 18 | unsigned char u8val_3 : 1; // 终端关机 19 | unsigned char u8val_4 : 1; // 终端复位 20 | unsigned char u8val_5 : 1; // 终端恢复出厂设置 21 | unsigned char u8val_6 : 1; // 关闭数据通信 22 | unsigned char u8val_7 : 1; // 关闭所有无线通信 23 | } bit; 24 | unsigned char u8val; 25 | }; 26 | 27 | // 0x8105终端控制. 28 | struct TerminalControl 29 | { 30 | // TerminalCtrlCmdByte cmdByte; // 命令字 31 | unsigned char cmdByte; // 命令字 1:无线升级;2:控制终端连接指定服务器;3:终端关机;4:终端复位;5:终端恢复出厂设置;6:关闭数据通信;7:关闭所有无线通信 32 | const char *cmdParameter; // 命令参数 33 | }; 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /User/nmea_decode/include/nmea/context.h: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * NMEA library 4 | * URL: http://nmea.sourceforge.net 5 | * Author: Tim (xtimor@gmail.com) 6 | * Licence: http://www.gnu.org/licenses/lgpl.html 7 | * $Id: context.h 4 2007-08-27 13:11:03Z xtimor $ 8 | * 9 | */ 10 | 11 | #ifndef __NMEA_CONTEXT_H__ 12 | #define __NMEA_CONTEXT_H__ 13 | 14 | #include "config.h" 15 | 16 | #define NMEA_DEF_PARSEBUFF (1024) 17 | #define NMEA_MIN_PARSEBUFF (256) 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | typedef void (*nmeaTraceFunc)(const char *str, int str_size); 24 | typedef void (*nmeaErrorFunc)(const char *str, int str_size); 25 | 26 | typedef struct _nmeaPROPERTY 27 | { 28 | nmeaTraceFunc trace_func; 29 | nmeaErrorFunc error_func; 30 | nmeaErrorFunc info_func; 31 | int parse_buff_size; 32 | 33 | } nmeaPROPERTY; 34 | 35 | nmeaPROPERTY * nmea_property(void); 36 | 37 | void nmea_trace(const char *str, ...); 38 | void nmea_trace_buff(const char *buff, int buff_size); 39 | void nmea_error(const char *str, ...); 40 | void nmea_info(const char *str, ...); 41 | 42 | #ifdef __cplusplus 43 | } 44 | #endif 45 | 46 | #endif /* __NMEA_CONTEXT_H__ */ 47 | -------------------------------------------------------------------------------- /User/jt808/include/util.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef JT808_UTIL_H_ 3 | #define JT808_UTIL_H_ 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | // #include 11 | 12 | // namespace libjt808 13 | // { 14 | 15 | // 无符号64位整型转无符号字节数组. 16 | union U64ToU8Array 17 | { 18 | unsigned long u64val; 19 | unsigned char u8array[8]; 20 | }; 21 | 22 | // 无符号32位整型转无符号字节数组. 23 | union U32ToU8Array 24 | { 25 | unsigned int u32val; 26 | unsigned char u8array[4]; 27 | }; 28 | 29 | // 无符号16位整型转无符号字节数组. 30 | union U16ToU8Array 31 | { 32 | unsigned short u16val; 33 | unsigned char u8array[2]; 34 | }; 35 | 36 | // 大小端互换. 37 | unsigned short EndianSwap16(unsigned short u16val); 38 | 39 | // 大小端互换. 40 | unsigned int EndianSwap32(unsigned int u32val); 41 | 42 | 43 | // 转义函数. 44 | int Escape_C(unsigned char *in, unsigned int inlen, unsigned char *out, unsigned int *outlen); 45 | int ReverseEscape_C(unsigned char *in, unsigned int inlen, unsigned char *out, unsigned int *outlen); 46 | 47 | // 异或校验. 48 | unsigned char BccCheckSum(const unsigned char *src, unsigned long len); 49 | 50 | // } // namespace libjt808 51 | 52 | #endif // JT808_UTIL_H_ 53 | -------------------------------------------------------------------------------- /User/nmea_decode/include/nmea/time.h: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * NMEA library 4 | * URL: http://nmea.sourceforge.net 5 | * Author: Tim (xtimor@gmail.com) 6 | * Licence: http://www.gnu.org/licenses/lgpl.html 7 | * $Id: time.h 4 2007-08-27 13:11:03Z xtimor $ 8 | * 9 | */ 10 | 11 | /*! \file */ 12 | 13 | #ifndef __NMEA_TIME_H__ 14 | #define __NMEA_TIME_H__ 15 | 16 | #include "config.h" 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | 22 | /** 23 | * Date and time data 24 | * @see nmea_time_now 25 | */ 26 | typedef struct _nmeaTIME 27 | { 28 | int year; /**< Years since 1900 */ 29 | int mon; /**< Months since January - [1,12] */ 30 | int day; /**< Day of the month - [1,31] */ 31 | int hour; /**< Hours since midnight - [0,23] */ 32 | int min; /**< Minutes after the hour - [0,59] */ 33 | int sec; /**< Seconds after the minute - [0,59] */ 34 | int hsec; /**< Hundredth part of second - [0,99] */ 35 | 36 | } nmeaTIME; 37 | 38 | /** 39 | * \brief Get time now to nmeaTIME structure 40 | */ 41 | void nmea_time_now(nmeaTIME *t); 42 | 43 | #ifdef __cplusplus 44 | } 45 | #endif 46 | 47 | #endif /* __NMEA_TIME_H__ */ 48 | -------------------------------------------------------------------------------- /User/jt808/include/bcd.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | #ifndef JT808_BCD_H_ 4 | #define JT808_BCD_H_ 5 | 6 | #include 7 | #include 8 | 9 | #include 10 | 11 | 12 | 13 | unsigned char HexToBcd(unsigned char src); 14 | unsigned char BcdToHex(unsigned char src); 15 | unsigned char *jt808StringToBcdCompress(const unsigned char *src, unsigned char *dst, int srclen); 16 | unsigned char *jt808BcdToStringCompress(const unsigned char *src, unsigned char *dst, int srclen); 17 | unsigned char *jt808BcdToStringCompressFillingZero(const unsigned char *src, unsigned char *dst, int srclen); 18 | 19 | // uint8_t HexToBcd(uint8_t const &src); 20 | // uint8_t BcdToHex(uint8_t const &src); 21 | // uint8_t *StringToBcdCompress(const uint8_t *src, uint8_t *dst, const int & srclen); 22 | // uint8_t *BcdToStringCompress(const uint8_t *src, uint8_t *dst, const int & srclen); 23 | // uint8_t *BcdToStringCompressFillingZero(const uint8_t *src, uint8_t *dst, const int &srclen); 24 | // int StringToBcd(std::string const &in, std::vector *out); 25 | // int BcdToString(std::vector const &in, std::string *out); 26 | // int BcdToStringFillZero(std::vector const &in, std::string *out); 27 | 28 | 29 | #endif // JT808_BCD_H_ 30 | -------------------------------------------------------------------------------- /User/nmea_decode/include/nmea/config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * NMEA library 4 | * URL: http://nmea.sourceforge.net 5 | * Author: Tim (xtimor@gmail.com) 6 | * Licence: http://www.gnu.org/licenses/lgpl.html 7 | * $Id: config.h 17 2008-03-11 11:56:11Z xtimor $ 8 | * 9 | */ 10 | 11 | #ifndef __NMEA_CONFIG_H__ 12 | #define __NMEA_CONFIG_H__ 13 | 14 | #define NMEA_VERSION ("0.5.3") 15 | #define NMEA_VERSION_MAJOR (0) 16 | #define NMEA_VERSION_MINOR (5) 17 | #define NMEA_VERSION_PATCH (3) 18 | 19 | #define NMEA_CONVSTR_BUF (256) 20 | #define NMEA_TIMEPARSE_BUF (256) 21 | #define NMEA_TXTPARSE_BUF (256) 22 | 23 | #if defined(WINCE) || defined(UNDER_CE) 24 | # define NMEA_CE 25 | #endif 26 | 27 | #if defined(WIN32) || defined(NMEA_CE) 28 | # define NMEA_WIN 29 | #else 30 | # define NMEA_UNI 31 | #endif 32 | 33 | #if defined(NMEA_WIN) && (_MSC_VER >= 1400) 34 | # pragma warning(disable: 4996) /* declared deprecated */ 35 | #endif 36 | 37 | #if defined(_MSC_VER) 38 | # define NMEA_POSIX(x) _##x 39 | # define NMEA_INLINE __inline 40 | #else 41 | # define NMEA_POSIX(x) x 42 | # define NMEA_INLINE inline 43 | #endif 44 | 45 | #if !defined(NDEBUG) && !defined(NMEA_CE) 46 | # include 47 | # define NMEA_ASSERT(x) //assert(x) //modify by WJSHM 48 | #else 49 | # define NMEA_ASSERT(x) 50 | #endif 51 | 52 | #endif /* __NMEA_CONFIG_H__ */ 53 | -------------------------------------------------------------------------------- /User/nmea_decode/include/nmea/parser.h: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * NMEA library 4 | * URL: http://nmea.sourceforge.net 5 | * Author: Tim (xtimor@gmail.com) 6 | * Licence: http://www.gnu.org/licenses/lgpl.html 7 | * $Id: parser.h 4 2007-08-27 13:11:03Z xtimor $ 8 | * 9 | */ 10 | 11 | #ifndef __NMEA_PARSER_H__ 12 | #define __NMEA_PARSER_H__ 13 | 14 | #include "info.h" 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | /* 21 | * high level 22 | */ 23 | 24 | typedef struct _nmeaPARSER 25 | { 26 | void *top_node; 27 | void *end_node; 28 | unsigned char buffer[1024]; 29 | int buff_size; 30 | int buff_use; 31 | 32 | } nmeaPARSER; 33 | 34 | int nmea_parser_init(nmeaPARSER *parser); 35 | void nmea_parser_destroy(nmeaPARSER *parser); 36 | 37 | int nmea_parse( 38 | nmeaPARSER *parser, 39 | const char *buff, int buff_sz, 40 | nmeaINFO *info 41 | ); 42 | 43 | /* 44 | * low level 45 | */ 46 | 47 | int nmea_parser_push(nmeaPARSER *parser, const char *buff, int buff_sz); 48 | int nmea_parser_top(nmeaPARSER *parser); 49 | int nmea_parser_pop(nmeaPARSER *parser, void **pack_ptr); 50 | int nmea_parser_peek(nmeaPARSER *parser, void **pack_ptr); 51 | int nmea_parser_drop(nmeaPARSER *parser); 52 | int nmea_parser_buff_clear(nmeaPARSER *parser); 53 | int nmea_parser_queue_clear(nmeaPARSER *parser); 54 | 55 | #ifdef __cplusplus 56 | } 57 | #endif 58 | 59 | #endif /* __NMEA_PARSER_H__ */ 60 | -------------------------------------------------------------------------------- /User/jt808/include/set_terminal_parameter.h: -------------------------------------------------------------------------------- 1 | #include "protocol_parameter.h" 2 | #include "bcd.h" 3 | #include "ff.h" 4 | #include "util.h" 5 | #include "./internal_flash/bsp_internal_flash.h" 6 | #define PARA_SETTING_LIMIT 10 //终端打包器命令相应消息ID数量 7 | 8 | // 所有终端数据打包命令. 9 | extern unsigned short kParameterSettingCMD[PARA_SETTING_LIMIT]; 10 | 11 | void jt808ParameterSettingParse(unsigned int id,unsigned char *buf,unsigned char buf_len, struct ProtocolParameter *para); 12 | void handle_HeartBeatInterval(unsigned char *buf,unsigned char buf_len,struct ProtocolParameter *para); 13 | void handle_MainServerAddress(unsigned char *buf,unsigned char buf_len,struct ProtocolParameter *para); 14 | void handle_ServerPort(unsigned char *buf,unsigned char buf_len,struct ProtocolParameter *para); 15 | void handle_DefaultTimeReportTimeInterval(unsigned char *buf,unsigned char buf_len,struct ProtocolParameter *para); 16 | void handle_CornerPointRetransmissionAngle(unsigned char *buf,unsigned char buf_len,struct ProtocolParameter *para); 17 | void handle_MaxSpeed(unsigned char *buf,unsigned char buf_len,struct ProtocolParameter *para); 18 | void handle_ProvinceID(unsigned char *buf,unsigned char buf_len,struct ProtocolParameter *para); 19 | void handle_CityID(unsigned char *buf,unsigned char buf_len,struct ProtocolParameter *para); 20 | void handle_CarPlateNum(unsigned char *buf,unsigned char buf_len,struct ProtocolParameter *para); 21 | void handle_CarPlateColor(unsigned char *buf,unsigned char buf_len,struct ProtocolParameter *para); 22 | -------------------------------------------------------------------------------- /User/nmea_decode/include/nmea/generate.h: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * NMEA library 4 | * URL: http://nmea.sourceforge.net 5 | * Author: Tim (xtimor@gmail.com) 6 | * Licence: http://www.gnu.org/licenses/lgpl.html 7 | * $Id: generate.h 4 2007-08-27 13:11:03Z xtimor $ 8 | * 9 | */ 10 | 11 | #ifndef __NMEA_GENERATE_H__ 12 | #define __NMEA_GENERATE_H__ 13 | 14 | #include "sentence.h" 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | int nmea_generate( 21 | char *buff, int buff_sz, /* buffer */ 22 | const nmeaINFO *info, /* source info */ 23 | int generate_mask /* mask of sentence`s (e.g. GPGGA | GPGSA) */ 24 | ); 25 | 26 | int nmea_gen_GPGGA(char *buff, int buff_sz, nmeaGPGGA *pack); 27 | int nmea_gen_GPGSA(char *buff, int buff_sz, nmeaGPGSA *pack); 28 | int nmea_gen_GPGSV(char *buff, int buff_sz, nmeaGPGSV *pack); 29 | int nmea_gen_GPRMC(char *buff, int buff_sz, nmeaGPRMC *pack); 30 | int nmea_gen_GPVTG(char *buff, int buff_sz, nmeaGPVTG *pack); 31 | 32 | void nmea_info2GPGGA(const nmeaINFO *info, nmeaGPGGA *pack); 33 | void nmea_info2GPGSA(const nmeaINFO *info, nmeaGPGSA *pack); 34 | void nmea_info2GPRMC(const nmeaINFO *info, nmeaGPRMC *pack); 35 | void nmea_info2GPVTG(const nmeaINFO *info, nmeaGPVTG *pack); 36 | 37 | int nmea_gsv_npack(int sat_count); 38 | void nmea_info2GPGSV(const nmeaINFO *info, nmeaGPGSV *pack, int pack_idx); 39 | 40 | #ifdef __cplusplus 41 | } 42 | #endif 43 | 44 | #endif /* __NMEA_GENERATE_H__ */ 45 | -------------------------------------------------------------------------------- /User/Bsp/gpio/gpio.c: -------------------------------------------------------------------------------- 1 | #include "./gpio/gpio.h" 2 | #include "./delay/delay.h" 3 | 4 | void LED_GPIO_Config(GPIO_InitTypeDef *GPIO_InitStructure) 5 | { 6 | 7 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA|RCC_APB2Periph_GPIOD, ENABLE); //??PA,PD???? 8 | 9 | //PA-8 init 10 | GPIO_InitStructure->GPIO_Pin = GPIO_Pin_8; 11 | GPIO_InitStructure->GPIO_Mode = GPIO_Mode_Out_PP; 12 | GPIO_InitStructure->GPIO_Speed = GPIO_Speed_50MHz; 13 | GPIO_Init(GPIOA, GPIO_InitStructure); 14 | 15 | //PC-1 init 16 | GPIO_InitStructure->GPIO_Pin = GPIO_Pin_1; 17 | GPIO_InitStructure->GPIO_Mode = GPIO_Mode_Out_PP; 18 | GPIO_InitStructure->GPIO_Speed = GPIO_Speed_50MHz; 19 | GPIO_Init(GPIOC, GPIO_InitStructure); 20 | GPIO_SetBits(GPIOC, GPIO_Pin_1); 21 | 22 | //PD-2 init 23 | // GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2; 24 | // GPIO_Init(GPIOD, &GPIO_InitStructure); 25 | // GPIO_SetBits(GPIOD,GPIO_Pin_2); 26 | } 27 | 28 | void PC_Config(GPIO_InitTypeDef *GPIO_InitStructure) 29 | { 30 | 31 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE); 32 | //PC-1 init 33 | GPIO_InitStructure->GPIO_Pin = GPIO_Pin_1|GPIO_Pin_5; 34 | GPIO_InitStructure->GPIO_Mode = GPIO_Mode_Out_PP; 35 | GPIO_InitStructure->GPIO_Speed = GPIO_Speed_50MHz; 36 | GPIO_Init(GPIOC, GPIO_InitStructure); 37 | GPIO_SetBits(GPIOC, GPIO_Pin_1); 38 | delay_ms(1000); 39 | 40 | GPIO_SetBits(GPIOC, GPIO_Pin_5); 41 | delay_ms(500); 42 | GPIO_ResetBits(GPIOC, GPIO_Pin_5); 43 | } 44 | 45 | /*********************************************END OF FILE**********************/ 46 | -------------------------------------------------------------------------------- /User/jt808/src/bcd.c: -------------------------------------------------------------------------------- 1 | #include "bcd.h" 2 | 3 | unsigned char HexToBcd(unsigned char src) 4 | { 5 | unsigned char temp; 6 | temp = ((src / 10) << 4) + (src % 10); 7 | return temp; 8 | } 9 | 10 | unsigned char BcdToHex(unsigned char src) 11 | { 12 | unsigned char temp; 13 | temp = (src >> 4) * 10 + (src & 0x0f); 14 | return temp; 15 | } 16 | 17 | unsigned char *jt808StringToBcdCompress(const unsigned char *src, unsigned char *dst, int srclen) 18 | { 19 | unsigned char *ptr = dst; 20 | unsigned char temp; 21 | if (srclen % 2 != 0) 22 | { 23 | *ptr++ = HexToBcd(*src++ - '0'); 24 | } 25 | while (*src) 26 | { 27 | temp = *src++ - '0'; 28 | temp *= 10; 29 | temp += *src++ - '0'; 30 | *ptr++ = HexToBcd(temp); 31 | } 32 | *ptr = 0; 33 | return dst; 34 | } 35 | 36 | unsigned char *jt808BcdToStringCompress(const unsigned char *src, unsigned char *dst, int srclen) 37 | { 38 | unsigned char *ptr = dst; 39 | unsigned char temp; 40 | int cnt = srclen; 41 | while (cnt--) 42 | { 43 | temp = BcdToHex(*src); 44 | *ptr++ = temp / 10 + '0'; 45 | if (dst[0] == '0') 46 | { 47 | ptr = dst; 48 | } 49 | *ptr++ = temp % 10 + '0'; 50 | ++src; 51 | } 52 | return dst; 53 | } 54 | 55 | 56 | unsigned char *jt808BcdToStringCompressFillingZero(const unsigned char *src, unsigned char *dst, int srclen) 57 | { 58 | unsigned char *ptr = dst; 59 | unsigned char temp; 60 | int cnt = srclen; 61 | while (cnt--) 62 | { 63 | temp = BcdToHex(*src); 64 | *ptr++ = temp / 10 + '0'; 65 | *ptr++ = temp % 10 + '0'; 66 | ++src; 67 | } 68 | return dst; 69 | } 70 | -------------------------------------------------------------------------------- /User/jt808/include/terminal_register.h: -------------------------------------------------------------------------------- 1 | #ifndef JT808_TERMINAL_REGISTER_H_ 2 | #define JT808_TERMINAL_REGISTER_H_ 3 | 4 | 5 | #include 6 | #include 7 | //#include 8 | #include 9 | #include "protocol_parameter.h" 10 | 11 | #include "./internal_flash/bsp_internal_flash.h" 12 | /// @brief 设置注册省域ID 13 | /// @param provinceId 14 | void setRegisterProvinceId(unsigned short provinceId); 15 | 16 | /// @brief 获取省域ID 17 | /// @return 18 | unsigned short getRegisterProvinceId(void); 19 | 20 | /// @brief 设置市县域ID 21 | /// @param cityId 22 | void setRegisterCityId(unsigned short cityId); 23 | 24 | /// @brief 获取市县域ID 25 | /// @return 26 | unsigned short getRegisterCityId(void); 27 | 28 | // 制造商ID, 固定5个字节. 29 | void setRegister_manufacturer_id(const char *manufacturerId, unsigned int manufacturer_id_size); 30 | 31 | const char *getRegister_manufacturer_id(void); 32 | 33 | // 终端型号, 固定20个字节, 位数不足后补0x00. 34 | void setRegister_terminal_model(const char *terminalModel, unsigned int terminalModel_size); 35 | 36 | /// @brief 获取终端型号 37 | /// @return 38 | const char *getRegister_terminal_model(void); 39 | 40 | // 终端ID, 固定7个字节, 位数不足后补0x00. 41 | void setRegister_terminal_id(const char *terminal_id, unsigned int terminal_id_size); 42 | 43 | /// @brief 获取终端型号 44 | /// @return 45 | const char *getRegister_terminal_id(void); 46 | 47 | // 车牌颜色, 0表示未上牌. 48 | void setRegister_car_plate_color(unsigned char car_plate_color); 49 | 50 | /// @brief 获取市县域ID 51 | /// @return 52 | unsigned char getRegister_car_plate_color(void); 53 | 54 | // 车辆标识, 仅在上牌时使用. 55 | void setRegister_car_plate_num(const char *car_plate_num, unsigned int car_plate_num_size); 56 | 57 | /// @brief 获取终端型号 58 | /// @return 59 | //const char *getRegister_car_plate_num(void); 60 | 61 | void initRegisterInfo(struct ProtocolParameter *para); 62 | 63 | #endif //JT808_TERMINAL_REGISTER_H_ 64 | 65 | -------------------------------------------------------------------------------- /User/nmea_decode/src/context.c: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * NMEA library 4 | * URL: http://nmea.sourceforge.net 5 | * Author: Tim (xtimor@gmail.com) 6 | * Licence: http://www.gnu.org/licenses/lgpl.html 7 | * $Id: context.c 17 2008-03-11 11:56:11Z xtimor $ 8 | * 9 | */ 10 | 11 | #include "nmea/context.h" 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | nmeaPROPERTY * nmea_property(void) 18 | { 19 | static nmeaPROPERTY prop = { 20 | 0, 0, 0, NMEA_DEF_PARSEBUFF 21 | }; 22 | 23 | return ∝ 24 | } 25 | 26 | void nmea_trace(const char *str, ...) 27 | { 28 | int size; 29 | va_list arg_list; 30 | char buff[NMEA_DEF_PARSEBUFF]; 31 | nmeaTraceFunc func = nmea_property()->trace_func; 32 | 33 | if(func) 34 | { 35 | va_start(arg_list, str); 36 | size = NMEA_POSIX(vsnprintf)(&buff[0], NMEA_DEF_PARSEBUFF - 1, str, arg_list); 37 | va_end(arg_list); 38 | 39 | if(size > 0) 40 | (*func)(&buff[0], size); 41 | } 42 | } 43 | 44 | void nmea_trace_buff(const char *buff, int buff_size) 45 | { 46 | nmeaTraceFunc func = nmea_property()->trace_func; 47 | if(func && buff_size) 48 | (*func)(buff, buff_size); 49 | } 50 | 51 | void nmea_error(const char *str, ...) 52 | { 53 | int size; 54 | va_list arg_list; 55 | char buff[NMEA_DEF_PARSEBUFF]; 56 | nmeaErrorFunc func = nmea_property()->error_func; 57 | 58 | if(func) 59 | { 60 | va_start(arg_list, str); 61 | size = NMEA_POSIX(vsnprintf)(&buff[0], NMEA_DEF_PARSEBUFF - 1, str, arg_list); 62 | va_end(arg_list); 63 | 64 | if(size > 0) 65 | (*func)(&buff[0], size); 66 | } 67 | } 68 | 69 | 70 | void nmea_info(const char *str, ...) 71 | { 72 | int size; 73 | va_list arg_list; 74 | char buff[NMEA_DEF_PARSEBUFF]; 75 | nmeaErrorFunc func = nmea_property()->info_func; 76 | 77 | if(func) 78 | { 79 | va_start(arg_list, str); 80 | size = NMEA_POSIX(vsnprintf)(&buff[0], NMEA_DEF_PARSEBUFF - 1, str, arg_list); 81 | va_end(arg_list); 82 | 83 | if(size > 0) 84 | (*func)(&buff[0], size); 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /User/stm32f10x_it.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file Project/STM32F10x_StdPeriph_Template/stm32f10x_it.h 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 08-April-2011 7 | * @brief This file contains the headers of the interrupt handlers. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2011 STMicroelectronics

19 | ****************************************************************************** 20 | */ 21 | 22 | /* Define to prevent recursive inclusion -------------------------------------*/ 23 | #ifndef __STM32F10x_IT_H 24 | #define __STM32F10x_IT_H 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | /* Includes ------------------------------------------------------------------*/ 31 | #include "stm32f10x.h" 32 | 33 | /* Exported types ------------------------------------------------------------*/ 34 | /* Exported constants --------------------------------------------------------*/ 35 | /* Exported macro ------------------------------------------------------------*/ 36 | /* Exported functions ------------------------------------------------------- */ 37 | 38 | void NMI_Handler(void); 39 | void HardFault_Handler(void); 40 | void MemManage_Handler(void); 41 | void BusFault_Handler(void); 42 | void UsageFault_Handler(void); 43 | void SVC_Handler(void); 44 | void DebugMon_Handler(void); 45 | void PendSV_Handler(void); 46 | void SysTick_Handler(void); 47 | 48 | #ifdef __cplusplus 49 | } 50 | #endif 51 | 52 | #endif /* __STM32F10x_IT_H */ 53 | 54 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 55 | -------------------------------------------------------------------------------- /User/nmea_decode/include/nmea/generator.h: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * NMEA library 4 | * URL: http://nmea.sourceforge.net 5 | * Author: Tim (xtimor@gmail.com) 6 | * Licence: http://www.gnu.org/licenses/lgpl.html 7 | * $Id: generator.h 4 2007-08-27 13:11:03Z xtimor $ 8 | * 9 | */ 10 | 11 | #ifndef __NMEA_GENERATOR_H__ 12 | #define __NMEA_GENERATOR_H__ 13 | 14 | #include "info.h" 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | /* 21 | * high level 22 | */ 23 | 24 | struct _nmeaGENERATOR; 25 | 26 | enum nmeaGENTYPE 27 | { 28 | NMEA_GEN_NOISE = 0, 29 | NMEA_GEN_STATIC, 30 | NMEA_GEN_ROTATE, 31 | 32 | NMEA_GEN_SAT_STATIC, 33 | NMEA_GEN_SAT_ROTATE, 34 | NMEA_GEN_POS_RANDMOVE, 35 | 36 | NMEA_GEN_LAST 37 | }; 38 | 39 | struct _nmeaGENERATOR * nmea_create_generator(int type, nmeaINFO *info); 40 | void nmea_destroy_generator(struct _nmeaGENERATOR *gen); 41 | 42 | int nmea_generate_from( 43 | char *buff, int buff_sz, /* buffer */ 44 | nmeaINFO *info, /* source info */ 45 | struct _nmeaGENERATOR *gen, /* generator */ 46 | int generate_mask /* mask of sentence`s (e.g. GPGGA | GPGSA) */ 47 | ); 48 | 49 | /* 50 | * low level 51 | */ 52 | 53 | typedef int (*nmeaNMEA_GEN_INIT)(struct _nmeaGENERATOR *gen, nmeaINFO *info); 54 | typedef int (*nmeaNMEA_GEN_LOOP)(struct _nmeaGENERATOR *gen, nmeaINFO *info); 55 | typedef int (*nmeaNMEA_GEN_RESET)(struct _nmeaGENERATOR *gen, nmeaINFO *info); 56 | typedef int (*nmeaNMEA_GEN_DESTROY)(struct _nmeaGENERATOR *gen); 57 | 58 | typedef struct _nmeaGENERATOR 59 | { 60 | void *gen_data; 61 | nmeaNMEA_GEN_INIT init_call; 62 | nmeaNMEA_GEN_LOOP loop_call; 63 | nmeaNMEA_GEN_RESET reset_call; 64 | nmeaNMEA_GEN_DESTROY destroy_call; 65 | struct _nmeaGENERATOR *next; 66 | 67 | } nmeaGENERATOR; 68 | 69 | int nmea_gen_init(nmeaGENERATOR *gen, nmeaINFO *info); 70 | int nmea_gen_loop(nmeaGENERATOR *gen, nmeaINFO *info); 71 | int nmea_gen_reset(nmeaGENERATOR *gen, nmeaINFO *info); 72 | void nmea_gen_destroy(nmeaGENERATOR *gen); 73 | void nmea_gen_add(nmeaGENERATOR *to, nmeaGENERATOR *gen); 74 | 75 | #ifdef __cplusplus 76 | } 77 | #endif 78 | 79 | #endif /* __NMEA_GENERATOR_H__ */ 80 | -------------------------------------------------------------------------------- /User/jt808/src/terminal_register.c: -------------------------------------------------------------------------------- 1 | #include "terminal_register.h" 2 | #include "ff.h" 3 | #include "string.h" 4 | //#include "protocol_parameter.h" 5 | 6 | struct RegisterInfo registerInfo_; 7 | 8 | void initRegisterInfo(struct ProtocolParameter *para) 9 | { 10 | int lenManufacturer, lenTModel; 11 | printf("\r\n[ initRegisterInfo ] OK !\r\n"); 12 | //省域ID 13 | para->register_info.province_id = para->parse.terminal_parameters.ProvinceID; 14 | printf("para->register_info.province_id = %d\r\n", para->register_info.province_id); 15 | 16 | //市域ID 17 | para->register_info.city_id = para->parse.terminal_parameters.CityID; 18 | printf("para->register_info.city_id = %04d\r\n", para->register_info.city_id); 19 | 20 | //制造商ID 21 | lenManufacturer=sizeof("XINDA"); 22 | lenManufacturer=(lenManufacturer>5)?5:lenManufacturer; 23 | 24 | memset(para->register_info.manufacturer_id, 0, lenManufacturer); 25 | memcpy(para->register_info.manufacturer_id, "XINDA", lenManufacturer); 26 | printf("para->register_info.manufacturer_id = %s\r\n", para->register_info.manufacturer_id); 27 | 28 | //终端型号 29 | lenTModel=sizeof("ZXIAT-CZ01"); 30 | lenTModel=(lenTModel>20)?20:lenTModel; 31 | 32 | memset(para->register_info.terminal_model, 0, lenTModel); 33 | memcpy(para->register_info.terminal_model, "ZXIAT-CZ01", lenTModel); 34 | printf("para->register_info.terminal_model = %s\r\n", para->register_info.terminal_model); 35 | 36 | // //终端ID 37 | // lenTerminalId = sizeof("1000000"); 38 | // lenTerminalId=(lenTerminalId>20)?20:lenTerminalId; 39 | 40 | // memset(para->register_info.terminal_id, 0, lenTerminalId); 41 | // memcpy(para->register_info.terminal_id, "1000000", lenTerminalId); 42 | // printf("para->register_info.terminal_id = %s\r\n", para->register_info.terminal_id); 43 | 44 | //车牌颜色 45 | para->register_info.car_plate_color = para->parse.terminal_parameters.CarPlateColor; 46 | printf("para->register_info.car_plate_color = 0x%02x\r\n", para->register_info.car_plate_color); 47 | 48 | //车牌号 49 | if (para->register_info.car_plate_color != 0x00) 50 | { 51 | memcpy(para->register_info.car_plate_num, para->parse.terminal_parameters.CarPlateNum, 12); 52 | printf("para->register_info.car_plate_num = %s\r\n", para->register_info.car_plate_num); 53 | } 54 | printf("\r\n"); 55 | printf("注册信息更新完成\r\n"); 56 | printf("\r\n"); 57 | 58 | 59 | } 60 | -------------------------------------------------------------------------------- /User/nmea_decode/include/nmea/parse.h: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * NMEA library 4 | * URL: http://nmea.sourceforge.net 5 | * Author: Tim (xtimor@gmail.com) 6 | * Licence: http://www.gnu.org/licenses/lgpl.html 7 | * $Id: parse.h 4 2007-08-27 13:11:03Z xtimor $ 8 | * 9 | */ 10 | 11 | #ifndef __NMEA_PARSE_H__ 12 | #define __NMEA_PARSE_H__ 13 | 14 | #include "sentence.h" 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | int nmea_pack_type(const char *buff, int buff_sz); 21 | int nmea_find_tail(const char *buff, int buff_sz, int *res_crc); 22 | 23 | int nmea_parse_GPGGA(const char *buff, int buff_sz, nmeaGPGGA *pack); 24 | int nmea_parse_GPGSA(const char *buff, int buff_sz, nmeaGPGSA *pack); 25 | int nmea_parse_GPGSV(const char *buff, int buff_sz, nmeaGPGSV *pack); 26 | int nmea_parse_GPRMC(const char *buff, int buff_sz, nmeaGPRMC *pack); 27 | int nmea_parse_GPVTG(const char *buff, int buff_sz, nmeaGPVTG *pack); 28 | 29 | int nmea_parse_GNGGA(const char *buff, int buff_sz, nmeaGNGGA *pack); 30 | int nmea_parse_GNRMC(const char *buff, int buff_sz, nmeaGNRMC *pack); 31 | int nmea_parse_GNVTG(const char *buff, int buff_sz, nmeaGNVTG *pack); 32 | int nmea_parse_GNZDA(const char *buff, int buff_sz, nmeaGNZDA *pack); 33 | int nmea_parse_GNGLL(const char *buff, int buff_sz, nmeaGNGLL *pack); 34 | 35 | int nmea_parse_BDGSV(const char *buff, int buff_sz, nmeaBDGSV *pack); 36 | int nmea_parse_BDGSA(const char *buff, int buff_sz, nmeaBDGSA *pack); 37 | int nmea_parse_GPTXT(const char *buff, int buff_sz, nmeaGPTXT *pack); 38 | 39 | void nmea_GPGGA2info(nmeaGPGGA *pack, nmeaINFO *info); 40 | void nmea_GPGSA2info(nmeaGPGSA *pack, nmeaINFO *info); 41 | void nmea_GPGSV2info(nmeaGPGSV *pack, nmeaINFO *info); 42 | void nmea_GPRMC2info(nmeaGPRMC *pack, nmeaINFO *info); 43 | void nmea_GPVTG2info(nmeaGPVTG *pack, nmeaINFO *info); 44 | 45 | void nmea_GNGGA2info(nmeaGNGGA *pack, nmeaINFO *info); 46 | void nmea_GNRMC2info(nmeaGNRMC *pack, nmeaINFO *info); 47 | void nmea_GNVTG2info(nmeaGNVTG *pack, nmeaINFO *info); 48 | void nmea_GNZDA2info(nmeaGNZDA *pack, nmeaINFO *info); 49 | void nmea_GNGLL2info(nmeaGNGLL *pack, nmeaINFO *info); 50 | 51 | void nmea_BDGSV2info(nmeaBDGSV *pack, nmeaINFO *info); 52 | void nmea_BDGSA2info(nmeaBDGSA *pack, nmeaINFO *info); 53 | void nmea_GPTXT2info(nmeaGPTXT *pack, nmeaINFO *info); 54 | 55 | #ifdef __cplusplus 56 | } 57 | #endif 58 | 59 | #endif /* __NMEA_PARSE_H__ */ 60 | -------------------------------------------------------------------------------- /Libraries/CMSIS/system_stm32f10x.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file system_stm32f10x.h 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 11-March-2011 7 | * @brief CMSIS Cortex-M3 Device Peripheral Access Layer System Header File. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2011 STMicroelectronics

19 | ****************************************************************************** 20 | */ 21 | 22 | /** @addtogroup CMSIS 23 | * @{ 24 | */ 25 | 26 | /** @addtogroup stm32f10x_system 27 | * @{ 28 | */ 29 | 30 | /** 31 | * @brief Define to prevent recursive inclusion 32 | */ 33 | #ifndef __SYSTEM_STM32F10X_H 34 | #define __SYSTEM_STM32F10X_H 35 | 36 | #ifdef __cplusplus 37 | extern "C" { 38 | #endif 39 | 40 | /** @addtogroup STM32F10x_System_Includes 41 | * @{ 42 | */ 43 | 44 | /** 45 | * @} 46 | */ 47 | 48 | 49 | /** @addtogroup STM32F10x_System_Exported_types 50 | * @{ 51 | */ 52 | 53 | extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ 54 | 55 | /** 56 | * @} 57 | */ 58 | 59 | /** @addtogroup STM32F10x_System_Exported_Constants 60 | * @{ 61 | */ 62 | 63 | /** 64 | * @} 65 | */ 66 | 67 | /** @addtogroup STM32F10x_System_Exported_Macros 68 | * @{ 69 | */ 70 | 71 | /** 72 | * @} 73 | */ 74 | 75 | /** @addtogroup STM32F10x_System_Exported_Functions 76 | * @{ 77 | */ 78 | 79 | extern void SystemInit(void); 80 | extern void SystemCoreClockUpdate(void); 81 | /** 82 | * @} 83 | */ 84 | 85 | #ifdef __cplusplus 86 | } 87 | #endif 88 | 89 | #endif /*__SYSTEM_STM32F10X_H */ 90 | 91 | /** 92 | * @} 93 | */ 94 | 95 | /** 96 | * @} 97 | */ 98 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 99 | -------------------------------------------------------------------------------- /Libraries/FWlib/inc/stm32f10x_crc.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f10x_crc.h 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 11-March-2011 7 | * @brief This file contains all the functions prototypes for the CRC firmware 8 | * library. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 13 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 14 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 15 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 16 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 17 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 18 | * 19 | *

© COPYRIGHT 2011 STMicroelectronics

20 | ****************************************************************************** 21 | */ 22 | 23 | /* Define to prevent recursive inclusion -------------------------------------*/ 24 | #ifndef __STM32F10x_CRC_H 25 | #define __STM32F10x_CRC_H 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | /* Includes ------------------------------------------------------------------*/ 32 | #include "stm32f10x.h" 33 | 34 | /** @addtogroup STM32F10x_StdPeriph_Driver 35 | * @{ 36 | */ 37 | 38 | /** @addtogroup CRC 39 | * @{ 40 | */ 41 | 42 | /** @defgroup CRC_Exported_Types 43 | * @{ 44 | */ 45 | 46 | /** 47 | * @} 48 | */ 49 | 50 | /** @defgroup CRC_Exported_Constants 51 | * @{ 52 | */ 53 | 54 | /** 55 | * @} 56 | */ 57 | 58 | /** @defgroup CRC_Exported_Macros 59 | * @{ 60 | */ 61 | 62 | /** 63 | * @} 64 | */ 65 | 66 | /** @defgroup CRC_Exported_Functions 67 | * @{ 68 | */ 69 | 70 | void CRC_ResetDR(void); 71 | uint32_t CRC_CalcCRC(uint32_t Data); 72 | uint32_t CRC_CalcBlockCRC(uint32_t pBuffer[], uint32_t BufferLength); 73 | uint32_t CRC_GetCRC(void); 74 | void CRC_SetIDRegister(uint8_t IDValue); 75 | uint8_t CRC_GetIDRegister(void); 76 | 77 | #ifdef __cplusplus 78 | } 79 | #endif 80 | 81 | #endif /* __STM32F10x_CRC_H */ 82 | /** 83 | * @} 84 | */ 85 | 86 | /** 87 | * @} 88 | */ 89 | 90 | /** 91 | * @} 92 | */ 93 | 94 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 95 | -------------------------------------------------------------------------------- /User/jt808/include/client_manager.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | //#ifndef JT808_CLIENT_MANAGER_H_ 4 | //#define JT808_CLIENT_MANAGER_H_ 5 | 6 | 7 | 8 | //#include 9 | //#include 10 | //#include 11 | //#include "./sys/sys.h" 12 | 13 | 14 | #define __JT808_DEBUG 15 | #define FLASH_ADDR (uint32_t)0x08034000 16 | #define FLASH_BUFFER_SIZE 128 17 | 18 | 19 | 20 | extern struct ProtocolParameter parameter_; 21 | 22 | void setTerminalPhoneNumber(unsigned char *phone_num, unsigned int phoneSize); 23 | 24 | /****************************************************************************** 25 | * @description: 数据打包并发送接口 26 | * @param {unsigned int} msg_id 消息ID 27 | * @return {*} 28 | * @author: ZTL 29 | *******************************************************************************/ 30 | int packagingAndSendMessage(unsigned int msg_id); 31 | 32 | /****************************************************************************** 33 | * @description: 数据打包接口 34 | * @param {unsigned int} msg_id JT808消息ID 35 | * @param { unsigned int} *realBufSize 用于记录实际打包待发送的buffer长度 36 | * @return {0}成功 {-1}失败 37 | * @author: ZTL 38 | *******************************************************************************/ 39 | int packagingMessage(unsigned int msg_id); 40 | 41 | /****************************************************************************** 42 | * @description: 从终端打包器命令数组中查找是否有当前相应的消息ID,以便根据该命令数组中的消息ID调用相应的接口 43 | * @param {unsigned int} msg_id 消息ID 44 | * @return {0}失败 {1}成功 45 | * @author: ZTL 46 | *******************************************************************************/ 47 | int findMsgIDFromTerminalPackagerCMD(unsigned int msg_id); 48 | int findParameterIDFromArray(unsigned int para_id); 49 | int parsingMessage(const unsigned char *in, unsigned int in_len); 50 | int jt808TerminalRegister(int *isRegistered); 51 | int jt808TerminalAuthentication(int *isAuthenticated); 52 | int jt808LocationReport(void); 53 | int jt808TerminalLogOut(void); 54 | int jt808TerminalHeartBeat(void); 55 | int jt808TerminalUpgradeResultReport(void); 56 | int jt808TerminalGeneralResponse(void); 57 | void setTerminalId(unsigned char *TerminalId, unsigned int lenTerminalId); 58 | void setStatusBit(void); 59 | int FlashWrite(void); 60 | void setUUID(void); 61 | int IPFlashWrite(void); 62 | void File_upload(void); 63 | void system_reboot(void); 64 | void initSystemParameters(int i); 65 | void initLocationInfo(unsigned int v_alarm_value, unsigned int v_status_value); 66 | void updateLocation(double const v_latitude, double const v_longitude, float const v_altitude, 67 | float const v_speed, float const v_bearing, unsigned char *v_timestamp); 68 | void boot_loader_flag(void); 69 | 70 | //#endif // JT808_CLIENT_MANAGER_H_ 71 | -------------------------------------------------------------------------------- /User/nmea_decode/src/sentence.c: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * NMEA library 4 | * URL: http://nmea.sourceforge.net 5 | * Author: Tim (xtimor@gmail.com) 6 | * Licence: http://www.gnu.org/licenses/lgpl.html 7 | * $Id: sentence.c 17 2008-03-11 11:56:11Z xtimor $ 8 | * 9 | */ 10 | 11 | #include "nmea/sentence.h" 12 | 13 | #include 14 | 15 | void nmea_zero_GPGGA(nmeaGPGGA *pack) 16 | { 17 | memset(pack, 0, sizeof(nmeaGPGGA)); 18 | nmea_time_now(&pack->utc); 19 | pack->ns = 'N'; 20 | pack->ew = 'E'; 21 | pack->elv_units = 'M'; 22 | pack->diff_units = 'M'; 23 | } 24 | 25 | void nmea_zero_GPGSA(nmeaGPGSA *pack) 26 | { 27 | memset(pack, 0, sizeof(nmeaGPGSA)); 28 | pack->fix_mode = 'A'; 29 | pack->fix_type = NMEA_FIX_BAD; 30 | } 31 | 32 | void nmea_zero_GPGSV(nmeaGPGSV *pack) 33 | { 34 | memset(pack, 0, sizeof(nmeaGPGSV)); 35 | } 36 | 37 | void nmea_zero_GPRMC(nmeaGPRMC *pack) 38 | { 39 | memset(pack, 0, sizeof(nmeaGPRMC)); 40 | nmea_time_now(&pack->utc); 41 | pack->status = 'V'; 42 | pack->ns = 'N'; 43 | pack->ew = 'E'; 44 | pack->declin_ew = 'E'; 45 | } 46 | 47 | void nmea_zero_GPVTG(nmeaGPVTG *pack) 48 | { 49 | memset(pack, 0, sizeof(nmeaGPVTG)); 50 | pack->dir_t = 'T'; 51 | pack->dec_m = 'M'; 52 | pack->spn_n = 'N'; 53 | pack->spk_k = 'K'; 54 | } 55 | 56 | void nmea_zero_GNGGA(nmeaGNGGA *pack) 57 | { 58 | memset(pack, 0, sizeof(nmeaGNGGA)); 59 | nmea_time_now(&pack->utc); 60 | pack->uLat = 'N'; 61 | pack->uLon = 'E'; 62 | pack->uMsl = 'M'; 63 | pack->uSep = 'M'; 64 | } 65 | 66 | void nmea_zero_GNRMC(nmeaGNRMC *pack) 67 | { 68 | memset(pack, 0, sizeof(nmeaGNRMC)); 69 | nmea_time_now(&pack->utc); 70 | pack->status = 'V'; 71 | pack->uLat = 'N'; 72 | pack->uLon = 'E'; 73 | pack->mvE = 'E'; 74 | } 75 | 76 | void nmea_zero_GNVTG(nmeaGNVTG *pack) 77 | { 78 | memset(pack, 0, sizeof(nmeaGNVTG)); 79 | pack->T = 'T'; 80 | pack->M = 'M'; 81 | pack->N = 'N'; 82 | pack->K = 'K'; 83 | } 84 | 85 | void nmea_zero_GNZDA(nmeaGNZDA *pack) 86 | { 87 | memset(pack, 0, sizeof(nmeaGNZDA)); 88 | nmea_time_now(&pack->utc); 89 | } 90 | 91 | void nmea_zero_GNGLL(nmeaGNGLL *pack) 92 | { 93 | memset(pack, 0, sizeof(nmeaGNGLL)); 94 | nmea_time_now(&pack->utc); 95 | pack->Value = 'V'; 96 | pack->uLat = 'N'; 97 | pack->uLon = 'E'; 98 | } 99 | 100 | void nmea_zero_BDGSA(nmeaBDGSA *pack) 101 | { 102 | memset(pack, 0, sizeof(nmeaBDGSA)); 103 | pack->Smode = 'A'; 104 | pack->FS = NMEA_FIX_BAD; 105 | } 106 | 107 | void nmea_zero_GPTXT(nmeaGPTXT *pack) 108 | { 109 | memset(pack, 0, sizeof(nmeaGPTXT)); 110 | 111 | } 112 | -------------------------------------------------------------------------------- /User/nmea_decode/include/nmea/gmath.h: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * NMEA library 4 | * URL: http://nmea.sourceforge.net 5 | * Author: Tim (xtimor@gmail.com) 6 | * Licence: http://www.gnu.org/licenses/lgpl.html 7 | * $Id: gmath.h 17 2008-03-11 11:56:11Z xtimor $ 8 | * 9 | */ 10 | 11 | #ifndef __NMEA_GMATH_H__ 12 | #define __NMEA_GMATH_H__ 13 | 14 | #include "info.h" 15 | 16 | #define NMEA_PI (3.141592653589793) /**< PI value */ 17 | #define NMEA_PI180 (NMEA_PI / 180) /**< PI division by 180 */ 18 | #define NMEA_EARTHRADIUS_KM (6378) /**< Earth's mean radius in km */ 19 | #define NMEA_EARTHRADIUS_M (NMEA_EARTHRADIUS_KM * 1000) /**< Earth's mean radius in m */ 20 | #define NMEA_EARTH_SEMIMAJORAXIS_M (6378137.0) /**< Earth's semi-major axis in m according WGS84 */ 21 | #define NMEA_EARTH_SEMIMAJORAXIS_KM (NMEA_EARTHMAJORAXIS_KM / 1000) /**< Earth's semi-major axis in km according WGS 84 */ 22 | #define NMEA_EARTH_FLATTENING (1 / 298.257223563) /**< Earth's flattening according WGS 84 */ 23 | #define NMEA_DOP_FACTOR (5) /**< Factor for translating DOP to meters */ 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | /* 30 | * degree VS radian 31 | */ 32 | 33 | double nmea_degree2radian(double val); 34 | double nmea_radian2degree(double val); 35 | 36 | /* 37 | * NDEG (NMEA degree) 38 | */ 39 | 40 | double nmea_ndeg2degree(double val); 41 | double nmea_degree2ndeg(double val); 42 | 43 | double nmea_ndeg2radian(double val); 44 | double nmea_radian2ndeg(double val); 45 | 46 | /* 47 | * DOP 48 | */ 49 | 50 | double nmea_calc_pdop(double hdop, double vdop); 51 | double nmea_dop2meters(double dop); 52 | double nmea_meters2dop(double meters); 53 | 54 | /* 55 | * positions work 56 | */ 57 | 58 | void nmea_info2pos(const nmeaINFO *info, nmeaPOS *pos); 59 | void nmea_pos2info(const nmeaPOS *pos, nmeaINFO *info); 60 | 61 | double nmea_distance( 62 | const nmeaPOS *from_pos, 63 | const nmeaPOS *to_pos 64 | ); 65 | 66 | double nmea_distance_ellipsoid( 67 | const nmeaPOS *from_pos, 68 | const nmeaPOS *to_pos, 69 | double *from_azimuth, 70 | double *to_azimuth 71 | ); 72 | 73 | int nmea_move_horz( 74 | const nmeaPOS *start_pos, 75 | nmeaPOS *end_pos, 76 | double azimuth, 77 | double distance 78 | ); 79 | 80 | int nmea_move_horz_ellipsoid( 81 | const nmeaPOS *start_pos, 82 | nmeaPOS *end_pos, 83 | double azimuth, 84 | double distance, 85 | double *end_azimuth 86 | ); 87 | 88 | #ifdef __cplusplus 89 | } 90 | #endif 91 | 92 | #endif /* __NMEA_GMATH_H__ */ 93 | -------------------------------------------------------------------------------- /User/FATFS/diskio.h: -------------------------------------------------------------------------------- 1 | /*-----------------------------------------------------------------------/ 2 | / Low level disk interface modlue include file (C)ChaN, 2014 / 3 | /-----------------------------------------------------------------------*/ 4 | 5 | #ifndef _DISKIO_DEFINED 6 | #define _DISKIO_DEFINED 7 | 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | 12 | #define _USE_WRITE 1 /* 1: Enable disk_write function */ 13 | #define _USE_IOCTL 1 /* 1: Enable disk_ioctl fucntion */ 14 | 15 | #include "integer.h" 16 | 17 | 18 | /* Status of Disk Functions */ 19 | typedef BYTE DSTATUS; 20 | 21 | /* Results of Disk Functions */ 22 | typedef enum { 23 | RES_OK = 0, /* 0: Successful */ 24 | RES_ERROR, /* 1: R/W Error */ 25 | RES_WRPRT, /* 2: Write Protected */ 26 | RES_NOTRDY, /* 3: Not Ready */ 27 | RES_PARERR /* 4: Invalid Parameter */ 28 | } DRESULT; 29 | 30 | 31 | /*---------------------------------------*/ 32 | /* Prototypes for disk control functions */ 33 | 34 | 35 | DSTATUS disk_initialize (BYTE pdrv); 36 | DSTATUS disk_status (BYTE pdrv); 37 | DRESULT disk_read (BYTE pdrv, BYTE* buff, DWORD sector, UINT count); 38 | DRESULT disk_write (BYTE pdrv, const BYTE* buff, DWORD sector, UINT count); 39 | DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff); 40 | 41 | 42 | /* Disk Status Bits (DSTATUS) */ 43 | 44 | #define STA_NOINIT 0x01 /* Drive not initialized */ 45 | #define STA_NODISK 0x02 /* No medium in the drive */ 46 | #define STA_PROTECT 0x04 /* Write protected */ 47 | 48 | 49 | /* Command code for disk_ioctrl fucntion */ 50 | 51 | /* Generic command (Used by FatFs) */ 52 | #define CTRL_SYNC 0 /* Complete pending write process (needed at _FS_READONLY == 0) */ 53 | #define GET_SECTOR_COUNT 1 /* Get media size (needed at _USE_MKFS == 1) */ 54 | #define GET_SECTOR_SIZE 2 /* Get sector size (needed at _MAX_SS != _MIN_SS) */ 55 | #define GET_BLOCK_SIZE 3 /* Get erase block size (needed at _USE_MKFS == 1) */ 56 | #define CTRL_TRIM 4 /* Inform device that the data on the block of sectors is no longer used (needed at _USE_TRIM == 1) */ 57 | 58 | /* Generic command (Not used by FatFs) */ 59 | #define CTRL_POWER 5 /* Get/Set power status */ 60 | #define CTRL_LOCK 6 /* Lock/Unlock media removal */ 61 | #define CTRL_EJECT 7 /* Eject media */ 62 | #define CTRL_FORMAT 8 /* Create physical format on the media */ 63 | 64 | /* MMC/SDC specific ioctl command */ 65 | #define MMC_GET_TYPE 10 /* Get card type */ 66 | #define MMC_GET_CSD 11 /* Get CSD */ 67 | #define MMC_GET_CID 12 /* Get CID */ 68 | #define MMC_GET_OCR 13 /* Get OCR */ 69 | #define MMC_GET_SDSTAT 14 /* Get SD status */ 70 | 71 | /* ATA/CF specific ioctl command */ 72 | #define ATA_GET_REV 20 /* Get F/W revision */ 73 | #define ATA_GET_MODEL 21 /* Get model name */ 74 | #define ATA_GET_SN 22 /* Get serial number */ 75 | 76 | #ifdef __cplusplus 77 | } 78 | #endif 79 | 80 | #endif 81 | -------------------------------------------------------------------------------- /User/jt808/src/location_report.c: -------------------------------------------------------------------------------- 1 | 2 | #include "location_report.h" 3 | 4 | #include 5 | 6 | #include "util.h" 7 | 8 | // double const v_latitude = 23.123456; 9 | // double const v_longitude = 123.123456; 10 | // float const v_altitude=10; 11 | // float const v_speed=10; 12 | // float const v_bearing=100; 13 | // unsigned char *v_timestamp = "211221213045"; 14 | 15 | // void initGPSInfo(struct ProtocolParameter *para, unsigned int v_alarm_value, 16 | // unsigned int v_status_value, double const v_latitude, 17 | // double const v_longitude, float const v_altitude, 18 | // float const v_speed, float const v_bearing, 19 | // unsigned char *v_timestamp) 20 | // { 21 | // printf("\n\r[initGPSInfo] OK !\n"); 22 | // //报警标志 23 | // para->location_info.alarm.value = v_alarm_value; 24 | // printf("para->alarm.value = %d\n", para->location_info.alarm.value); 25 | // //状态 26 | // para->location_info.status.value = v_status_value; 27 | // printf("para->status.value = %d\n", para->location_info.status.value); 28 | 29 | // // if (speed >= 10) //默认车速大于等于10公里时为正常行驶状态 30 | // // { 31 | // // isCarMoving.store(true); 32 | // // } 33 | // // else 34 | // // { 35 | // // isCarMoving.store(false); 36 | // // } 37 | // para->location_info.latitude = v_latitude * 1e6; 38 | // printf("para->latitude = %d\n", para->location_info.latitude); 39 | 40 | // para->location_info.longitude = v_longitude * 1e6; 41 | // printf("para->longitude = %d\n", para->location_info.longitude); 42 | 43 | // para->location_info.altitude = v_altitude; 44 | // printf("para->altitude = %d\n", para->location_info.altitude); 45 | 46 | // para->location_info.speed = v_speed * 10; 47 | // printf("para->speed = %d\n", para->location_info.speed); 48 | 49 | // para->location_info.bearing = v_bearing; 50 | // printf("para->bearing = %d\n", para->location_info.bearing); 51 | 52 | // para->location_info.time = v_timestamp; 53 | // printf("para->time = %s\n", para->location_info.time); 54 | // } 55 | 56 | // void UpdateLocation(double const latitude, double const longitude, 57 | // float const altitude, float const speed, 58 | // float const bearing, unsigned char *timestamp) 59 | // { 60 | // // if (speed >= 10) //默认车速大于等于10公里时为正常行驶状态 61 | // // { 62 | // // isCarMoving.store(true); 63 | // // } 64 | // // else 65 | // // { 66 | // // isCarMoving.store(false); 67 | // // } 68 | // para->location_info.latitude = static_cast(latitude * 1e6); 69 | // para->location_info.longitude = static_cast(longitude * 1e6); 70 | // para->location_info.altitude = static_cast(altitude); 71 | // para->location_info.speed = static_cast(speed * 10); 72 | // para->location_info.bearing = static_cast(bearing); 73 | // para->location_info.time.assign(timestamp.begin(), timestamp.end()); 74 | 75 | // // spdlog::info("[{}] [{}] 更新上报位置信息 ", libjt808::getCurrentFileName(__FILE__), __LINE__); 76 | // } 77 | -------------------------------------------------------------------------------- /User/jt808/src/util.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | // #include "jt808/util.h" 4 | // #include "jt808/protocol_parameter.h" 5 | 6 | #include "util.h" 7 | #include "protocol_parameter.h" 8 | #include "client_manager.h" 9 | //#include 10 | 11 | union U16ToU8Array u16converter; 12 | union U32ToU8Array u32converter; 13 | 14 | // 双字节大小段互换 15 | unsigned short EndianSwap16(unsigned short u16val) 16 | { 17 | return (((u16val & 0x00FF) << 8) + 18 | ((u16val & 0xFF00) >> 8)); 19 | } 20 | 21 | // 四字节大小端互换. 22 | unsigned int EndianSwap32(unsigned int u32val) 23 | { 24 | return (((u32val & 0x000000FF) << 24) + 25 | ((u32val & 0x0000FF00) << 8) + 26 | ((u32val & 0x00FF0000) >> 8) + 27 | ((u32val & 0xFF000000) >> 24)); 28 | } 29 | 30 | // 转义函数. outlen应大于inlen 建议outlen >= 2*inlen; 31 | int Escape_C(unsigned char *in, unsigned int inlen, unsigned char *out, unsigned int *outlen) 32 | { 33 | unsigned int i; 34 | int offset_num; 35 | if ((out == NULL) || ((*outlen) < 2 * inlen)) 36 | { 37 | printf("[%s] FAILED \r\n",__FUNCTION__); 38 | return -1; 39 | 40 | } 41 | 42 | memset(out, 0, *outlen); 43 | 44 | offset_num = 0; 45 | for (i = 0; i < inlen; ++i) 46 | { 47 | if (in[i] == PROTOCOL_SIGN) 48 | { 49 | out[i + offset_num] = PROTOCOL_ESCAPE; 50 | out[i + 1 + offset_num] = PROTOCOL_ESCAPE_SIGN; 51 | offset_num++; 52 | } 53 | else if (in[i] == PROTOCOL_ESCAPE) 54 | { 55 | out[i + offset_num] = PROTOCOL_ESCAPE; 56 | out[i + 1 + offset_num] = PROTOCOL_ESCAPE_ESCAPE; 57 | offset_num++; 58 | } 59 | else 60 | { 61 | out[i + offset_num] = in[i]; 62 | } 63 | } 64 | *outlen = inlen + offset_num; 65 | 66 | return 0; 67 | } 68 | 69 | // 逆转义函数. outlen >= (inlen/2) 70 | int ReverseEscape_C(unsigned char *in, unsigned int inlen, unsigned char *out, unsigned int *outlen) 71 | { 72 | // if ((out == NULL) || (inlen == 0)) 73 | // return -1; 74 | // memset(out, 0, *outlen); 75 | unsigned int i; 76 | int offset_num; 77 | #ifdef __JT808_DEBUG 78 | printf("[ReverseEscape_C]:"); 79 | #endif 80 | 81 | offset_num = 0; 82 | for (i = 0; i < inlen; ++i) 83 | { 84 | if ((in[i] == PROTOCOL_ESCAPE) && (in[i + 1] == PROTOCOL_ESCAPE_SIGN)) 85 | { 86 | out[i - offset_num] = PROTOCOL_SIGN; 87 | ++i; 88 | offset_num++; 89 | } 90 | else if ((in[i] == PROTOCOL_ESCAPE) && (in[i + 1] == PROTOCOL_ESCAPE_ESCAPE)) 91 | { 92 | out[i - offset_num] = PROTOCOL_ESCAPE; 93 | ++i; 94 | offset_num++; 95 | } 96 | else 97 | { 98 | out[i - offset_num] = in[i]; 99 | #ifdef __JT808_DEBUG 100 | printf("%02x ", out[i - offset_num]); 101 | #endif 102 | } 103 | } 104 | #ifdef __JT808_DEBUG 105 | printf("\r\n"); 106 | #endif 107 | 108 | *outlen = inlen - offset_num; 109 | 110 | return 0; 111 | } 112 | 113 | // 异或校验. 114 | unsigned char BccCheckSum(const unsigned char *src, unsigned long len) 115 | { 116 | unsigned char checksum = 0; 117 | unsigned long i; 118 | for (i = 0; i < len; ++i) 119 | { 120 | checksum = checksum ^ src[i]; 121 | } 122 | #ifdef __JT808_DEBUG 123 | printf("[BccCheckSum] OK !\r\n"); 124 | #endif 125 | return checksum; 126 | 127 | 128 | } 129 | 130 | // } // namespace libjt808 131 | -------------------------------------------------------------------------------- /Libraries/FWlib/inc/stm32f10x_wwdg.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f10x_wwdg.h 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 11-March-2011 7 | * @brief This file contains all the functions prototypes for the WWDG firmware 8 | * library. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 13 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 14 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 15 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 16 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 17 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 18 | * 19 | *

© COPYRIGHT 2011 STMicroelectronics

20 | ****************************************************************************** 21 | */ 22 | 23 | /* Define to prevent recursive inclusion -------------------------------------*/ 24 | #ifndef __STM32F10x_WWDG_H 25 | #define __STM32F10x_WWDG_H 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | /* Includes ------------------------------------------------------------------*/ 32 | #include "stm32f10x.h" 33 | 34 | /** @addtogroup STM32F10x_StdPeriph_Driver 35 | * @{ 36 | */ 37 | 38 | /** @addtogroup WWDG 39 | * @{ 40 | */ 41 | 42 | /** @defgroup WWDG_Exported_Types 43 | * @{ 44 | */ 45 | 46 | /** 47 | * @} 48 | */ 49 | 50 | /** @defgroup WWDG_Exported_Constants 51 | * @{ 52 | */ 53 | 54 | /** @defgroup WWDG_Prescaler 55 | * @{ 56 | */ 57 | 58 | #define WWDG_Prescaler_1 ((uint32_t)0x00000000) 59 | #define WWDG_Prescaler_2 ((uint32_t)0x00000080) 60 | #define WWDG_Prescaler_4 ((uint32_t)0x00000100) 61 | #define WWDG_Prescaler_8 ((uint32_t)0x00000180) 62 | #define IS_WWDG_PRESCALER(PRESCALER) (((PRESCALER) == WWDG_Prescaler_1) || \ 63 | ((PRESCALER) == WWDG_Prescaler_2) || \ 64 | ((PRESCALER) == WWDG_Prescaler_4) || \ 65 | ((PRESCALER) == WWDG_Prescaler_8)) 66 | #define IS_WWDG_WINDOW_VALUE(VALUE) ((VALUE) <= 0x7F) 67 | #define IS_WWDG_COUNTER(COUNTER) (((COUNTER) >= 0x40) && ((COUNTER) <= 0x7F)) 68 | 69 | /** 70 | * @} 71 | */ 72 | 73 | /** 74 | * @} 75 | */ 76 | 77 | /** @defgroup WWDG_Exported_Macros 78 | * @{ 79 | */ 80 | /** 81 | * @} 82 | */ 83 | 84 | /** @defgroup WWDG_Exported_Functions 85 | * @{ 86 | */ 87 | 88 | void WWDG_DeInit(void); 89 | void WWDG_SetPrescaler(uint32_t WWDG_Prescaler); 90 | void WWDG_SetWindowValue(uint8_t WindowValue); 91 | void WWDG_EnableIT(void); 92 | void WWDG_SetCounter(uint8_t Counter); 93 | void WWDG_Enable(uint8_t Counter); 94 | FlagStatus WWDG_GetFlagStatus(void); 95 | void WWDG_ClearFlag(void); 96 | 97 | #ifdef __cplusplus 98 | } 99 | #endif 100 | 101 | #endif /* __STM32F10x_WWDG_H */ 102 | 103 | /** 104 | * @} 105 | */ 106 | 107 | /** 108 | * @} 109 | */ 110 | 111 | /** 112 | * @} 113 | */ 114 | 115 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 116 | -------------------------------------------------------------------------------- /User/stm32f10x_conf.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file Project/STM32F10x_StdPeriph_Template/stm32f10x_conf.h 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 08-April-2011 7 | * @brief Library configuration file. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2011 STMicroelectronics

19 | ****************************************************************************** 20 | */ 21 | 22 | /* Define to prevent recursive inclusion -------------------------------------*/ 23 | #ifndef __STM32F10x_CONF_H 24 | #define __STM32F10x_CONF_H 25 | 26 | /* Includes ------------------------------------------------------------------*/ 27 | /* Uncomment/Comment the line below to enable/disable peripheral header file inclusion */ 28 | #include "stm32f10x_adc.h" 29 | #include "stm32f10x_bkp.h" 30 | #include "stm32f10x_can.h" 31 | #include "stm32f10x_cec.h" 32 | #include "stm32f10x_crc.h" 33 | #include "stm32f10x_dac.h" 34 | #include "stm32f10x_dbgmcu.h" 35 | #include "stm32f10x_dma.h" 36 | #include "stm32f10x_exti.h" 37 | #include "stm32f10x_flash.h" 38 | #include "stm32f10x_fsmc.h" 39 | #include "stm32f10x_gpio.h" 40 | #include "stm32f10x_i2c.h" 41 | #include "stm32f10x_iwdg.h" 42 | #include "stm32f10x_pwr.h" 43 | #include "stm32f10x_rcc.h" 44 | #include "stm32f10x_rtc.h" 45 | #include "stm32f10x_sdio.h" 46 | #include "stm32f10x_spi.h" 47 | #include "stm32f10x_tim.h" 48 | #include "stm32f10x_usart.h" 49 | #include "stm32f10x_wwdg.h" 50 | #include "misc.h" /* High level functions for NVIC and SysTick (add-on to CMSIS functions) */ 51 | /* Exported types ------------------------------------------------------------*/ 52 | /* Exported constants --------------------------------------------------------*/ 53 | /* Uncomment the line below to expanse the "assert_param" macro in the 54 | Standard Peripheral Library drivers code */ 55 | /* #define USE_FULL_ASSERT 1 */ 56 | 57 | /* Exported macro ------------------------------------------------------------*/ 58 | #ifdef USE_FULL_ASSERT 59 | 60 | /** 61 | * @brief The assert_param macro is used for function's parameters check. 62 | * @param expr: If expr is false, it calls assert_failed function which reports 63 | * the name of the source file and the source line number of the call 64 | * that failed. If expr is true, it returns no value. 65 | * @retval None 66 | */ 67 | #define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__)) 68 | /* Exported functions ------------------------------------------------------- */ 69 | void assert_failed(uint8_t* file, uint32_t line); 70 | #else 71 | #define assert_param(expr) ((void)0) 72 | #endif /* USE_FULL_ASSERT */ 73 | 74 | #endif /* __STM32F10x_CONF_H */ 75 | 76 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 77 | -------------------------------------------------------------------------------- /Libraries/FWlib/src/stm32f10x_crc.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f10x_crc.c 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 11-March-2011 7 | * @brief This file provides all the CRC firmware functions. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2011 STMicroelectronics

19 | ****************************************************************************** 20 | */ 21 | 22 | /* Includes ------------------------------------------------------------------*/ 23 | #include "stm32f10x_crc.h" 24 | 25 | /** @addtogroup STM32F10x_StdPeriph_Driver 26 | * @{ 27 | */ 28 | 29 | /** @defgroup CRC 30 | * @brief CRC driver modules 31 | * @{ 32 | */ 33 | 34 | /** @defgroup CRC_Private_TypesDefinitions 35 | * @{ 36 | */ 37 | 38 | /** 39 | * @} 40 | */ 41 | 42 | /** @defgroup CRC_Private_Defines 43 | * @{ 44 | */ 45 | 46 | /** 47 | * @} 48 | */ 49 | 50 | /** @defgroup CRC_Private_Macros 51 | * @{ 52 | */ 53 | 54 | /** 55 | * @} 56 | */ 57 | 58 | /** @defgroup CRC_Private_Variables 59 | * @{ 60 | */ 61 | 62 | /** 63 | * @} 64 | */ 65 | 66 | /** @defgroup CRC_Private_FunctionPrototypes 67 | * @{ 68 | */ 69 | 70 | /** 71 | * @} 72 | */ 73 | 74 | /** @defgroup CRC_Private_Functions 75 | * @{ 76 | */ 77 | 78 | /** 79 | * @brief Resets the CRC Data register (DR). 80 | * @param None 81 | * @retval None 82 | */ 83 | void CRC_ResetDR(void) 84 | { 85 | /* Reset CRC generator */ 86 | CRC->CR = CRC_CR_RESET; 87 | } 88 | 89 | /** 90 | * @brief Computes the 32-bit CRC of a given data word(32-bit). 91 | * @param Data: data word(32-bit) to compute its CRC 92 | * @retval 32-bit CRC 93 | */ 94 | uint32_t CRC_CalcCRC(uint32_t Data) 95 | { 96 | CRC->DR = Data; 97 | 98 | return (CRC->DR); 99 | } 100 | 101 | /** 102 | * @brief Computes the 32-bit CRC of a given buffer of data word(32-bit). 103 | * @param pBuffer: pointer to the buffer containing the data to be computed 104 | * @param BufferLength: length of the buffer to be computed 105 | * @retval 32-bit CRC 106 | */ 107 | uint32_t CRC_CalcBlockCRC(uint32_t pBuffer[], uint32_t BufferLength) 108 | { 109 | uint32_t index = 0; 110 | 111 | for(index = 0; index < BufferLength; index++) 112 | { 113 | CRC->DR = pBuffer[index]; 114 | } 115 | return (CRC->DR); 116 | } 117 | 118 | /** 119 | * @brief Returns the current CRC value. 120 | * @param None 121 | * @retval 32-bit CRC 122 | */ 123 | uint32_t CRC_GetCRC(void) 124 | { 125 | return (CRC->DR); 126 | } 127 | 128 | /** 129 | * @brief Stores a 8-bit data in the Independent Data(ID) register. 130 | * @param IDValue: 8-bit value to be stored in the ID register 131 | * @retval None 132 | */ 133 | void CRC_SetIDRegister(uint8_t IDValue) 134 | { 135 | CRC->IDR = IDValue; 136 | } 137 | 138 | /** 139 | * @brief Returns the 8-bit data stored in the Independent Data(ID) register 140 | * @param None 141 | * @retval 8-bit value of the ID register 142 | */ 143 | uint8_t CRC_GetIDRegister(void) 144 | { 145 | return (CRC->IDR); 146 | } 147 | 148 | /** 149 | * @} 150 | */ 151 | 152 | /** 153 | * @} 154 | */ 155 | 156 | /** 157 | * @} 158 | */ 159 | 160 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 161 | -------------------------------------------------------------------------------- /Libraries/FWlib/inc/stm32f10x_dbgmcu.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f10x_dbgmcu.h 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 11-March-2011 7 | * @brief This file contains all the functions prototypes for the DBGMCU 8 | * firmware library. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 13 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 14 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 15 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 16 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 17 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 18 | * 19 | *

© COPYRIGHT 2011 STMicroelectronics

20 | ****************************************************************************** 21 | */ 22 | 23 | /* Define to prevent recursive inclusion -------------------------------------*/ 24 | #ifndef __STM32F10x_DBGMCU_H 25 | #define __STM32F10x_DBGMCU_H 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | /* Includes ------------------------------------------------------------------*/ 32 | #include "stm32f10x.h" 33 | 34 | /** @addtogroup STM32F10x_StdPeriph_Driver 35 | * @{ 36 | */ 37 | 38 | /** @addtogroup DBGMCU 39 | * @{ 40 | */ 41 | 42 | /** @defgroup DBGMCU_Exported_Types 43 | * @{ 44 | */ 45 | 46 | /** 47 | * @} 48 | */ 49 | 50 | /** @defgroup DBGMCU_Exported_Constants 51 | * @{ 52 | */ 53 | 54 | #define DBGMCU_SLEEP ((uint32_t)0x00000001) 55 | #define DBGMCU_STOP ((uint32_t)0x00000002) 56 | #define DBGMCU_STANDBY ((uint32_t)0x00000004) 57 | #define DBGMCU_IWDG_STOP ((uint32_t)0x00000100) 58 | #define DBGMCU_WWDG_STOP ((uint32_t)0x00000200) 59 | #define DBGMCU_TIM1_STOP ((uint32_t)0x00000400) 60 | #define DBGMCU_TIM2_STOP ((uint32_t)0x00000800) 61 | #define DBGMCU_TIM3_STOP ((uint32_t)0x00001000) 62 | #define DBGMCU_TIM4_STOP ((uint32_t)0x00002000) 63 | #define DBGMCU_CAN1_STOP ((uint32_t)0x00004000) 64 | #define DBGMCU_I2C1_SMBUS_TIMEOUT ((uint32_t)0x00008000) 65 | #define DBGMCU_I2C2_SMBUS_TIMEOUT ((uint32_t)0x00010000) 66 | #define DBGMCU_TIM8_STOP ((uint32_t)0x00020000) 67 | #define DBGMCU_TIM5_STOP ((uint32_t)0x00040000) 68 | #define DBGMCU_TIM6_STOP ((uint32_t)0x00080000) 69 | #define DBGMCU_TIM7_STOP ((uint32_t)0x00100000) 70 | #define DBGMCU_CAN2_STOP ((uint32_t)0x00200000) 71 | #define DBGMCU_TIM15_STOP ((uint32_t)0x00400000) 72 | #define DBGMCU_TIM16_STOP ((uint32_t)0x00800000) 73 | #define DBGMCU_TIM17_STOP ((uint32_t)0x01000000) 74 | #define DBGMCU_TIM12_STOP ((uint32_t)0x02000000) 75 | #define DBGMCU_TIM13_STOP ((uint32_t)0x04000000) 76 | #define DBGMCU_TIM14_STOP ((uint32_t)0x08000000) 77 | #define DBGMCU_TIM9_STOP ((uint32_t)0x10000000) 78 | #define DBGMCU_TIM10_STOP ((uint32_t)0x20000000) 79 | #define DBGMCU_TIM11_STOP ((uint32_t)0x40000000) 80 | 81 | #define IS_DBGMCU_PERIPH(PERIPH) ((((PERIPH) & 0x800000F8) == 0x00) && ((PERIPH) != 0x00)) 82 | /** 83 | * @} 84 | */ 85 | 86 | /** @defgroup DBGMCU_Exported_Macros 87 | * @{ 88 | */ 89 | 90 | /** 91 | * @} 92 | */ 93 | 94 | /** @defgroup DBGMCU_Exported_Functions 95 | * @{ 96 | */ 97 | 98 | uint32_t DBGMCU_GetREVID(void); 99 | uint32_t DBGMCU_GetDEVID(void); 100 | void DBGMCU_Config(uint32_t DBGMCU_Periph, FunctionalState NewState); 101 | 102 | #ifdef __cplusplus 103 | } 104 | #endif 105 | 106 | #endif /* __STM32F10x_DBGMCU_H */ 107 | /** 108 | * @} 109 | */ 110 | 111 | /** 112 | * @} 113 | */ 114 | 115 | /** 116 | * @} 117 | */ 118 | 119 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 120 | -------------------------------------------------------------------------------- /Libraries/FWlib/inc/stm32f10x_iwdg.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f10x_iwdg.h 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 11-March-2011 7 | * @brief This file contains all the functions prototypes for the IWDG 8 | * firmware library. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 13 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 14 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 15 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 16 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 17 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 18 | * 19 | *

© COPYRIGHT 2011 STMicroelectronics

20 | ****************************************************************************** 21 | */ 22 | 23 | /* Define to prevent recursive inclusion -------------------------------------*/ 24 | #ifndef __STM32F10x_IWDG_H 25 | #define __STM32F10x_IWDG_H 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | /* Includes ------------------------------------------------------------------*/ 32 | #include "stm32f10x.h" 33 | 34 | /** @addtogroup STM32F10x_StdPeriph_Driver 35 | * @{ 36 | */ 37 | 38 | /** @addtogroup IWDG 39 | * @{ 40 | */ 41 | 42 | /** @defgroup IWDG_Exported_Types 43 | * @{ 44 | */ 45 | 46 | /** 47 | * @} 48 | */ 49 | 50 | /** @defgroup IWDG_Exported_Constants 51 | * @{ 52 | */ 53 | 54 | /** @defgroup IWDG_WriteAccess 55 | * @{ 56 | */ 57 | 58 | #define IWDG_WriteAccess_Enable ((uint16_t)0x5555) 59 | #define IWDG_WriteAccess_Disable ((uint16_t)0x0000) 60 | #define IS_IWDG_WRITE_ACCESS(ACCESS) (((ACCESS) == IWDG_WriteAccess_Enable) || \ 61 | ((ACCESS) == IWDG_WriteAccess_Disable)) 62 | /** 63 | * @} 64 | */ 65 | 66 | /** @defgroup IWDG_prescaler 67 | * @{ 68 | */ 69 | 70 | #define IWDG_Prescaler_4 ((uint8_t)0x00) 71 | #define IWDG_Prescaler_8 ((uint8_t)0x01) 72 | #define IWDG_Prescaler_16 ((uint8_t)0x02) 73 | #define IWDG_Prescaler_32 ((uint8_t)0x03) 74 | #define IWDG_Prescaler_64 ((uint8_t)0x04) 75 | #define IWDG_Prescaler_128 ((uint8_t)0x05) 76 | #define IWDG_Prescaler_256 ((uint8_t)0x06) 77 | #define IS_IWDG_PRESCALER(PRESCALER) (((PRESCALER) == IWDG_Prescaler_4) || \ 78 | ((PRESCALER) == IWDG_Prescaler_8) || \ 79 | ((PRESCALER) == IWDG_Prescaler_16) || \ 80 | ((PRESCALER) == IWDG_Prescaler_32) || \ 81 | ((PRESCALER) == IWDG_Prescaler_64) || \ 82 | ((PRESCALER) == IWDG_Prescaler_128)|| \ 83 | ((PRESCALER) == IWDG_Prescaler_256)) 84 | /** 85 | * @} 86 | */ 87 | 88 | /** @defgroup IWDG_Flag 89 | * @{ 90 | */ 91 | 92 | #define IWDG_FLAG_PVU ((uint16_t)0x0001) 93 | #define IWDG_FLAG_RVU ((uint16_t)0x0002) 94 | #define IS_IWDG_FLAG(FLAG) (((FLAG) == IWDG_FLAG_PVU) || ((FLAG) == IWDG_FLAG_RVU)) 95 | #define IS_IWDG_RELOAD(RELOAD) ((RELOAD) <= 0xFFF) 96 | /** 97 | * @} 98 | */ 99 | 100 | /** 101 | * @} 102 | */ 103 | 104 | /** @defgroup IWDG_Exported_Macros 105 | * @{ 106 | */ 107 | 108 | /** 109 | * @} 110 | */ 111 | 112 | /** @defgroup IWDG_Exported_Functions 113 | * @{ 114 | */ 115 | 116 | void IWDG_WriteAccessCmd(uint16_t IWDG_WriteAccess); 117 | void IWDG_SetPrescaler(uint8_t IWDG_Prescaler); 118 | void IWDG_SetReload(uint16_t Reload); 119 | void IWDG_ReloadCounter(void); 120 | void IWDG_Enable(void); 121 | FlagStatus IWDG_GetFlagStatus(uint16_t IWDG_FLAG); 122 | 123 | #ifdef __cplusplus 124 | } 125 | #endif 126 | 127 | #endif /* __STM32F10x_IWDG_H */ 128 | /** 129 | * @} 130 | */ 131 | 132 | /** 133 | * @} 134 | */ 135 | 136 | /** 137 | * @} 138 | */ 139 | 140 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 141 | -------------------------------------------------------------------------------- /Libraries/FWlib/inc/stm32f10x_rtc.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f10x_rtc.h 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 11-March-2011 7 | * @brief This file contains all the functions prototypes for the RTC firmware 8 | * library. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 13 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 14 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 15 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 16 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 17 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 18 | * 19 | *

© COPYRIGHT 2011 STMicroelectronics

20 | ****************************************************************************** 21 | */ 22 | 23 | /* Define to prevent recursive inclusion -------------------------------------*/ 24 | #ifndef __STM32F10x_RTC_H 25 | #define __STM32F10x_RTC_H 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | /* Includes ------------------------------------------------------------------*/ 32 | #include "stm32f10x.h" 33 | 34 | /** @addtogroup STM32F10x_StdPeriph_Driver 35 | * @{ 36 | */ 37 | 38 | /** @addtogroup RTC 39 | * @{ 40 | */ 41 | 42 | /** @defgroup RTC_Exported_Types 43 | * @{ 44 | */ 45 | 46 | /** 47 | * @} 48 | */ 49 | 50 | /** @defgroup RTC_Exported_Constants 51 | * @{ 52 | */ 53 | 54 | /** @defgroup RTC_interrupts_define 55 | * @{ 56 | */ 57 | 58 | #define RTC_IT_OW ((uint16_t)0x0004) /*!< Overflow interrupt */ 59 | #define RTC_IT_ALR ((uint16_t)0x0002) /*!< Alarm interrupt */ 60 | #define RTC_IT_SEC ((uint16_t)0x0001) /*!< Second interrupt */ 61 | #define IS_RTC_IT(IT) ((((IT) & (uint16_t)0xFFF8) == 0x00) && ((IT) != 0x00)) 62 | #define IS_RTC_GET_IT(IT) (((IT) == RTC_IT_OW) || ((IT) == RTC_IT_ALR) || \ 63 | ((IT) == RTC_IT_SEC)) 64 | /** 65 | * @} 66 | */ 67 | 68 | /** @defgroup RTC_interrupts_flags 69 | * @{ 70 | */ 71 | 72 | #define RTC_FLAG_RTOFF ((uint16_t)0x0020) /*!< RTC Operation OFF flag */ 73 | #define RTC_FLAG_RSF ((uint16_t)0x0008) /*!< Registers Synchronized flag */ 74 | #define RTC_FLAG_OW ((uint16_t)0x0004) /*!< Overflow flag */ 75 | #define RTC_FLAG_ALR ((uint16_t)0x0002) /*!< Alarm flag */ 76 | #define RTC_FLAG_SEC ((uint16_t)0x0001) /*!< Second flag */ 77 | #define IS_RTC_CLEAR_FLAG(FLAG) ((((FLAG) & (uint16_t)0xFFF0) == 0x00) && ((FLAG) != 0x00)) 78 | #define IS_RTC_GET_FLAG(FLAG) (((FLAG) == RTC_FLAG_RTOFF) || ((FLAG) == RTC_FLAG_RSF) || \ 79 | ((FLAG) == RTC_FLAG_OW) || ((FLAG) == RTC_FLAG_ALR) || \ 80 | ((FLAG) == RTC_FLAG_SEC)) 81 | #define IS_RTC_PRESCALER(PRESCALER) ((PRESCALER) <= 0xFFFFF) 82 | 83 | /** 84 | * @} 85 | */ 86 | 87 | /** 88 | * @} 89 | */ 90 | 91 | /** @defgroup RTC_Exported_Macros 92 | * @{ 93 | */ 94 | 95 | /** 96 | * @} 97 | */ 98 | 99 | /** @defgroup RTC_Exported_Functions 100 | * @{ 101 | */ 102 | 103 | void RTC_ITConfig(uint16_t RTC_IT, FunctionalState NewState); 104 | void RTC_EnterConfigMode(void); 105 | void RTC_ExitConfigMode(void); 106 | uint32_t RTC_GetCounter(void); 107 | void RTC_SetCounter(uint32_t CounterValue); 108 | void RTC_SetPrescaler(uint32_t PrescalerValue); 109 | void RTC_SetAlarm(uint32_t AlarmValue); 110 | uint32_t RTC_GetDivider(void); 111 | void RTC_WaitForLastTask(void); 112 | void RTC_WaitForSynchro(void); 113 | FlagStatus RTC_GetFlagStatus(uint16_t RTC_FLAG); 114 | void RTC_ClearFlag(uint16_t RTC_FLAG); 115 | ITStatus RTC_GetITStatus(uint16_t RTC_IT); 116 | void RTC_ClearITPendingBit(uint16_t RTC_IT); 117 | 118 | #ifdef __cplusplus 119 | } 120 | #endif 121 | 122 | #endif /* __STM32F10x_RTC_H */ 123 | /** 124 | * @} 125 | */ 126 | 127 | /** 128 | * @} 129 | */ 130 | 131 | /** 132 | * @} 133 | */ 134 | 135 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 136 | -------------------------------------------------------------------------------- /User/jt808/src/gbk_utf8.c: -------------------------------------------------------------------------------- 1 | #include "gbk_utf8.h" 2 | 3 | /* 4 | namespace libjt808 5 | { 6 | #ifdef _WIN32 7 | 8 | std::string GbkToUtf8(const char *src_str) 9 | { 10 | int len = MultiByteToWideChar(CP_ACP, 0, src_str, -1, NULL, 0); 11 | wchar_t *wstr = new wchar_t[len + 1]; 12 | memset(wstr, 0, len + 1); 13 | MultiByteToWideChar(CP_ACP, 0, src_str, -1, wstr, len); 14 | len = WideCharToMultiByte(CP_UTF8, 0, wstr, -1, NULL, 0, NULL, NULL); 15 | char *str = new char[len + 1]; 16 | memset(str, 0, len + 1); 17 | WideCharToMultiByte(CP_UTF8, 0, wstr, -1, str, len, NULL, NULL); 18 | std::string strTemp = str; 19 | if (wstr) 20 | delete[] wstr; 21 | if (str) 22 | delete[] str; 23 | return strTemp; 24 | } 25 | 26 | std::string Utf8ToGbk(const char *src_str) 27 | { 28 | int len = MultiByteToWideChar(CP_UTF8, 0, src_str, -1, NULL, 0); 29 | wchar_t *wszGBK = new wchar_t[len + 1]; 30 | memset(wszGBK, 0, len * 2 + 2); 31 | MultiByteToWideChar(CP_UTF8, 0, src_str, -1, wszGBK, len); 32 | len = WideCharToMultiByte(CP_ACP, 0, wszGBK, -1, NULL, 0, NULL, NULL); 33 | char *szGBK = new char[len + 1]; 34 | memset(szGBK, 0, len + 1); 35 | WideCharToMultiByte(CP_ACP, 0, wszGBK, -1, szGBK, len, NULL, NULL); 36 | std::string strTemp(szGBK); 37 | if (wszGBK) 38 | delete[] wszGBK; 39 | if (szGBK) 40 | delete[] szGBK; 41 | return strTemp; 42 | } 43 | #else 44 | 45 | int GbkToUtf8(char *str_str, size_t src_len, char *dst_str, size_t dst_len) 46 | { 47 | iconv_t cd; 48 | char **pin = &str_str; 49 | char **pout = &dst_str; 50 | 51 | cd = iconv_open("utf-8", "gbk"); 52 | if (cd == (iconv_t)-1) 53 | { 54 | printf("GbkToUtf8 iconv_open error\n"); 55 | return -1; 56 | } 57 | 58 | memset(dst_str, 0, dst_len); 59 | if (iconv(cd, pin, &src_len, pout, &dst_len) != 0) 60 | { 61 | printf("GbkToUtf8 iconv error\n"); 62 | return -1; 63 | } 64 | 65 | iconv_close(cd); 66 | *pout = nullptr; 67 | 68 | return 0; 69 | } 70 | 71 | int Utf8ToGbk(char *src_str, size_t src_len, char *dst_str, size_t dst_len) 72 | { 73 | iconv_t cd; 74 | char **pin = &src_str; 75 | char **pout = &dst_str; 76 | 77 | cd = iconv_open("gbk", "utf-8"); 78 | if (cd == 0) 79 | { 80 | printf("Utf8ToGbk iconv_open error\n"); 81 | return -1; 82 | } 83 | 84 | memset(dst_str, 0, dst_len); 85 | if (iconv(cd, pin, &src_len, pout, &dst_len) != 0) 86 | { 87 | printf("Utf8ToGbk iconv error\n"); 88 | return -1; 89 | } 90 | iconv_close(cd); 91 | *pout = nullptr; 92 | 93 | return 0; 94 | } 95 | 96 | #endif 97 | 98 | std::string gbk_to_utf8_str(const std::vector &gbk_src) 99 | { 100 | 101 | //?GBK??????utf-8?? 102 | size_t lenSRC = gbk_src.size(); 103 | size_t lenDst = lenSRC * 2; 104 | char *dst_str = new char[lenDst]; 105 | // Utf8ToGbk((char *)(txt8300_2013.data()), len, dst_str, 1024); 106 | if (GbkToUtf8((char *)(gbk_src.data()), lenSRC, dst_str, lenDst) != 0) 107 | return ""; 108 | std::string str_GbkToUtf8(dst_str); 109 | std::this_thread::sleep_for(std::chrono::milliseconds(100)); 110 | delete[] dst_str; 111 | 112 | return str_GbkToUtf8; 113 | } 114 | 115 | std::string gbk_to_utf8_str(const std::string &str_gbk_src) 116 | { 117 | 118 | //?GBK??????utf-8?? 119 | size_t lenSRC = str_gbk_src.size(); 120 | size_t lenDst = lenSRC * 2; 121 | char *dst_str = new char[lenDst]; 122 | // Utf8ToGbk((char *)(txt8300_2013.data()), len, dst_str, 1024); 123 | if (GbkToUtf8((char *)(str_gbk_src.data()), lenSRC, dst_str, lenDst) != 0) 124 | return ""; 125 | std::string str_GbkToUtf8(dst_str); 126 | std::this_thread::sleep_for(std::chrono::milliseconds(100)); 127 | delete[] dst_str; 128 | 129 | return str_GbkToUtf8; 130 | } 131 | } 132 | */ 133 | -------------------------------------------------------------------------------- /User/stm32f10x_it.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file Project/STM32F10x_StdPeriph_Template/stm32f10x_it.c 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 08-April-2011 7 | * @brief Main Interrupt Service Routines. 8 | * This file provides template for all exceptions handler and 9 | * peripherals interrupt service routine. 10 | ****************************************************************************** 11 | * @attention 12 | * 13 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 14 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 15 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 16 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 17 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 18 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 19 | * 20 | *

© COPYRIGHT 2011 STMicroelectronics

21 | ****************************************************************************** 22 | */ 23 | 24 | /* Includes ------------------------------------------------------------------*/ 25 | #include "stm32f10x_it.h" 26 | #include "./gps/gps_config.h" 27 | 28 | /** @addtogroup STM32F10x_StdPeriph_Template 29 | * @{ 30 | */ 31 | 32 | /* Private typedef -----------------------------------------------------------*/ 33 | /* Private define ------------------------------------------------------------*/ 34 | /* Private macro -------------------------------------------------------------*/ 35 | /* Private variables ---------------------------------------------------------*/ 36 | /* Private function prototypes -----------------------------------------------*/ 37 | /* Private functions ---------------------------------------------------------*/ 38 | 39 | /******************************************************************************/ 40 | /* Cortex-M3 Processor Exceptions Handlers */ 41 | /******************************************************************************/ 42 | 43 | /** 44 | * @brief This function handles NMI exception. 45 | * @param None 46 | * @retval None 47 | */ 48 | void NMI_Handler(void) 49 | { 50 | } 51 | 52 | /** 53 | * @brief This function handles Hard Fault exception. 54 | * @param None 55 | * @retval None 56 | */ 57 | void HardFault_Handler(void) 58 | { 59 | /* Go to infinite loop when Hard Fault exception occurs */ 60 | while (1) 61 | { 62 | } 63 | } 64 | 65 | /** 66 | * @brief This function handles Memory Manage exception. 67 | * @param None 68 | * @retval None 69 | */ 70 | void MemManage_Handler(void) 71 | { 72 | /* Go to infinite loop when Memory Manage exception occurs */ 73 | while (1) 74 | { 75 | } 76 | } 77 | 78 | /** 79 | * @brief This function handles Bus Fault exception. 80 | * @param None 81 | * @retval None 82 | */ 83 | void BusFault_Handler(void) 84 | { 85 | /* Go to infinite loop when Bus Fault exception occurs */ 86 | while (1) 87 | { 88 | } 89 | } 90 | 91 | /** 92 | * @brief This function handles Usage Fault exception. 93 | * @param None 94 | * @retval None 95 | */ 96 | void UsageFault_Handler(void) 97 | { 98 | /* Go to infinite loop when Usage Fault exception occurs */ 99 | while (1) 100 | { 101 | } 102 | } 103 | 104 | /** 105 | * @brief This function handles SVCall exception. 106 | * @param None 107 | * @retval None 108 | */ 109 | void SVC_Handler(void) 110 | { 111 | } 112 | 113 | /** 114 | * @brief This function handles Debug Monitor exception. 115 | * @param None 116 | * @retval None 117 | */ 118 | void DebugMon_Handler(void) 119 | { 120 | } 121 | 122 | /** 123 | * @brief This function handles PendSVC exception. 124 | * @param None 125 | * @retval None 126 | */ 127 | void PendSV_Handler(void) 128 | { 129 | } 130 | 131 | 132 | 133 | /******************************************************************************/ 134 | /* STM32F10x Peripherals Interrupt Handlers */ 135 | /* Add here the Interrupt Handler for the used peripheral(s) (PPP), for the */ 136 | /* available peripheral interrupt handler's name please refer to the startup */ 137 | /* file (startup_stm32f10x_xx.s). */ 138 | /******************************************************************************/ 139 | 140 | /** 141 | * @brief This function handles PPP interrupt request. 142 | * @param None 143 | * @retval None 144 | */ 145 | /*void PPP_IRQHandler(void) 146 | { 147 | }*/ 148 | 149 | void GPS_DMA_IRQHANDLER(void) 150 | { 151 | 152 | GPS_ProcessDMAIRQ(); 153 | 154 | } 155 | 156 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 157 | -------------------------------------------------------------------------------- /Libraries/FWlib/inc/stm32f10x_pwr.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f10x_pwr.h 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 11-March-2011 7 | * @brief This file contains all the functions prototypes for the PWR firmware 8 | * library. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 13 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 14 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 15 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 16 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 17 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 18 | * 19 | *

© COPYRIGHT 2011 STMicroelectronics

20 | ****************************************************************************** 21 | */ 22 | 23 | /* Define to prevent recursive inclusion -------------------------------------*/ 24 | #ifndef __STM32F10x_PWR_H 25 | #define __STM32F10x_PWR_H 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | /* Includes ------------------------------------------------------------------*/ 32 | #include "stm32f10x.h" 33 | 34 | /** @addtogroup STM32F10x_StdPeriph_Driver 35 | * @{ 36 | */ 37 | 38 | /** @addtogroup PWR 39 | * @{ 40 | */ 41 | 42 | /** @defgroup PWR_Exported_Types 43 | * @{ 44 | */ 45 | 46 | /** 47 | * @} 48 | */ 49 | 50 | /** @defgroup PWR_Exported_Constants 51 | * @{ 52 | */ 53 | 54 | /** @defgroup PVD_detection_level 55 | * @{ 56 | */ 57 | 58 | #define PWR_PVDLevel_2V2 ((uint32_t)0x00000000) 59 | #define PWR_PVDLevel_2V3 ((uint32_t)0x00000020) 60 | #define PWR_PVDLevel_2V4 ((uint32_t)0x00000040) 61 | #define PWR_PVDLevel_2V5 ((uint32_t)0x00000060) 62 | #define PWR_PVDLevel_2V6 ((uint32_t)0x00000080) 63 | #define PWR_PVDLevel_2V7 ((uint32_t)0x000000A0) 64 | #define PWR_PVDLevel_2V8 ((uint32_t)0x000000C0) 65 | #define PWR_PVDLevel_2V9 ((uint32_t)0x000000E0) 66 | #define IS_PWR_PVD_LEVEL(LEVEL) (((LEVEL) == PWR_PVDLevel_2V2) || ((LEVEL) == PWR_PVDLevel_2V3)|| \ 67 | ((LEVEL) == PWR_PVDLevel_2V4) || ((LEVEL) == PWR_PVDLevel_2V5)|| \ 68 | ((LEVEL) == PWR_PVDLevel_2V6) || ((LEVEL) == PWR_PVDLevel_2V7)|| \ 69 | ((LEVEL) == PWR_PVDLevel_2V8) || ((LEVEL) == PWR_PVDLevel_2V9)) 70 | /** 71 | * @} 72 | */ 73 | 74 | /** @defgroup Regulator_state_is_STOP_mode 75 | * @{ 76 | */ 77 | 78 | #define PWR_Regulator_ON ((uint32_t)0x00000000) 79 | #define PWR_Regulator_LowPower ((uint32_t)0x00000001) 80 | #define IS_PWR_REGULATOR(REGULATOR) (((REGULATOR) == PWR_Regulator_ON) || \ 81 | ((REGULATOR) == PWR_Regulator_LowPower)) 82 | /** 83 | * @} 84 | */ 85 | 86 | /** @defgroup STOP_mode_entry 87 | * @{ 88 | */ 89 | 90 | #define PWR_STOPEntry_WFI ((uint8_t)0x01) 91 | #define PWR_STOPEntry_WFE ((uint8_t)0x02) 92 | #define IS_PWR_STOP_ENTRY(ENTRY) (((ENTRY) == PWR_STOPEntry_WFI) || ((ENTRY) == PWR_STOPEntry_WFE)) 93 | 94 | /** 95 | * @} 96 | */ 97 | 98 | /** @defgroup PWR_Flag 99 | * @{ 100 | */ 101 | 102 | #define PWR_FLAG_WU ((uint32_t)0x00000001) 103 | #define PWR_FLAG_SB ((uint32_t)0x00000002) 104 | #define PWR_FLAG_PVDO ((uint32_t)0x00000004) 105 | #define IS_PWR_GET_FLAG(FLAG) (((FLAG) == PWR_FLAG_WU) || ((FLAG) == PWR_FLAG_SB) || \ 106 | ((FLAG) == PWR_FLAG_PVDO)) 107 | 108 | #define IS_PWR_CLEAR_FLAG(FLAG) (((FLAG) == PWR_FLAG_WU) || ((FLAG) == PWR_FLAG_SB)) 109 | /** 110 | * @} 111 | */ 112 | 113 | /** 114 | * @} 115 | */ 116 | 117 | /** @defgroup PWR_Exported_Macros 118 | * @{ 119 | */ 120 | 121 | /** 122 | * @} 123 | */ 124 | 125 | /** @defgroup PWR_Exported_Functions 126 | * @{ 127 | */ 128 | 129 | void PWR_DeInit(void); 130 | void PWR_BackupAccessCmd(FunctionalState NewState); 131 | void PWR_PVDCmd(FunctionalState NewState); 132 | void PWR_PVDLevelConfig(uint32_t PWR_PVDLevel); 133 | void PWR_WakeUpPinCmd(FunctionalState NewState); 134 | void PWR_EnterSTOPMode(uint32_t PWR_Regulator, uint8_t PWR_STOPEntry); 135 | void PWR_EnterSTANDBYMode(void); 136 | FlagStatus PWR_GetFlagStatus(uint32_t PWR_FLAG); 137 | void PWR_ClearFlag(uint32_t PWR_FLAG); 138 | 139 | #ifdef __cplusplus 140 | } 141 | #endif 142 | 143 | #endif /* __STM32F10x_PWR_H */ 144 | /** 145 | * @} 146 | */ 147 | 148 | /** 149 | * @} 150 | */ 151 | 152 | /** 153 | * @} 154 | */ 155 | 156 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 157 | -------------------------------------------------------------------------------- /User/FATFS/option/syscall.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------*/ 2 | /* Sample code of OS dependent controls for FatFs */ 3 | /* (C)ChaN, 2014 */ 4 | /*------------------------------------------------------------------------*/ 5 | 6 | 7 | #include "../ff.h" 8 | 9 | 10 | #if _FS_REENTRANT 11 | /*------------------------------------------------------------------------*/ 12 | /* Create a Synchronization Object 13 | /*------------------------------------------------------------------------*/ 14 | /* This function is called in f_mount() function to create a new 15 | / synchronization object, such as semaphore and mutex. When a 0 is returned, 16 | / the f_mount() function fails with FR_INT_ERR. 17 | */ 18 | 19 | int ff_cre_syncobj ( /* !=0:Function succeeded, ==0:Could not create due to any error */ 20 | BYTE vol, /* Corresponding logical drive being processed */ 21 | _SYNC_t *sobj /* Pointer to return the created sync object */ 22 | ) 23 | { 24 | int ret; 25 | 26 | 27 | *sobj = CreateMutex(NULL, FALSE, NULL); /* Win32 */ 28 | ret = (int)(*sobj != INVALID_HANDLE_VALUE); 29 | 30 | // *sobj = SyncObjects[vol]; /* uITRON (give a static created sync object) */ 31 | // ret = 1; /* The initial value of the semaphore must be 1. */ 32 | 33 | // *sobj = OSMutexCreate(0, &err); /* uC/OS-II */ 34 | // ret = (int)(err == OS_NO_ERR); 35 | 36 | // *sobj = xSemaphoreCreateMutex(); /* FreeRTOS */ 37 | // ret = (int)(*sobj != NULL); 38 | 39 | return ret; 40 | } 41 | 42 | 43 | 44 | /*------------------------------------------------------------------------*/ 45 | /* Delete a Synchronization Object */ 46 | /*------------------------------------------------------------------------*/ 47 | /* This function is called in f_mount() function to delete a synchronization 48 | / object that created with ff_cre_syncobj function. When a 0 is returned, 49 | / the f_mount() function fails with FR_INT_ERR. 50 | */ 51 | 52 | int ff_del_syncobj ( /* !=0:Function succeeded, ==0:Could not delete due to any error */ 53 | _SYNC_t sobj /* Sync object tied to the logical drive to be deleted */ 54 | ) 55 | { 56 | int ret; 57 | 58 | 59 | ret = CloseHandle(sobj); /* Win32 */ 60 | 61 | // ret = 1; /* uITRON (nothing to do) */ 62 | 63 | // OSMutexDel(sobj, OS_DEL_ALWAYS, &err); /* uC/OS-II */ 64 | // ret = (int)(err == OS_NO_ERR); 65 | 66 | // vSemaphoreDelete(sobj); /* FreeRTOS */ 67 | // ret = 1; 68 | 69 | return ret; 70 | } 71 | 72 | 73 | 74 | /*------------------------------------------------------------------------*/ 75 | /* Request Grant to Access the Volume */ 76 | /*------------------------------------------------------------------------*/ 77 | /* This function is called on entering file functions to lock the volume. 78 | / When a 0 is returned, the file function fails with FR_TIMEOUT. 79 | */ 80 | 81 | int ff_req_grant ( /* 1:Got a grant to access the volume, 0:Could not get a grant */ 82 | _SYNC_t sobj /* Sync object to wait */ 83 | ) 84 | { 85 | int ret; 86 | 87 | ret = (int)(WaitForSingleObject(sobj, _FS_TIMEOUT) == WAIT_OBJECT_0); /* Win32 */ 88 | 89 | // ret = (int)(wai_sem(sobj) == E_OK); /* uITRON */ 90 | 91 | // OSMutexPend(sobj, _FS_TIMEOUT, &err)); /* uC/OS-II */ 92 | // ret = (int)(err == OS_NO_ERR); 93 | 94 | // ret = (int)(xSemaphoreTake(sobj, _FS_TIMEOUT) == pdTRUE); /* FreeRTOS */ 95 | 96 | return ret; 97 | } 98 | 99 | 100 | 101 | /*------------------------------------------------------------------------*/ 102 | /* Release Grant to Access the Volume */ 103 | /*------------------------------------------------------------------------*/ 104 | /* This function is called on leaving file functions to unlock the volume. 105 | */ 106 | 107 | void ff_rel_grant ( 108 | _SYNC_t sobj /* Sync object to be signaled */ 109 | ) 110 | { 111 | ReleaseMutex(sobj); /* Win32 */ 112 | 113 | // sig_sem(sobj); /* uITRON */ 114 | 115 | // OSMutexPost(sobj); /* uC/OS-II */ 116 | 117 | // xSemaphoreGive(sobj); /* FreeRTOS */ 118 | } 119 | 120 | #endif 121 | 122 | 123 | 124 | 125 | #if _USE_LFN == 3 /* LFN with a working buffer on the heap */ 126 | /*------------------------------------------------------------------------*/ 127 | /* Allocate a memory block */ 128 | /*------------------------------------------------------------------------*/ 129 | /* If a NULL is returned, the file function fails with FR_NOT_ENOUGH_CORE. 130 | */ 131 | 132 | void* ff_memalloc ( /* Returns pointer to the allocated memory block */ 133 | UINT msize /* Number of bytes to allocate */ 134 | ) 135 | { 136 | return malloc(msize); /* Allocate a new memory block with POSIX API */ 137 | } 138 | 139 | 140 | /*------------------------------------------------------------------------*/ 141 | /* Free a memory block */ 142 | /*------------------------------------------------------------------------*/ 143 | 144 | void ff_memfree ( 145 | void* mblock /* Pointer to the memory block to free */ 146 | ) 147 | { 148 | free(mblock); /* Discard the memory block with POSIX API */ 149 | } 150 | 151 | #endif 152 | -------------------------------------------------------------------------------- /Libraries/FWlib/src/stm32f10x_iwdg.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f10x_iwdg.c 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 11-March-2011 7 | * @brief This file provides all the IWDG firmware functions. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2011 STMicroelectronics

19 | ****************************************************************************** 20 | */ 21 | 22 | /* Includes ------------------------------------------------------------------*/ 23 | #include "stm32f10x_iwdg.h" 24 | /** @addtogroup STM32F10x_StdPeriph_Driver 25 | * @{ 26 | */ 27 | 28 | /** @defgroup IWDG 29 | * @brief IWDG driver modules 30 | * @{ 31 | */ 32 | 33 | /** @defgroup IWDG_Private_TypesDefinitions 34 | * @{ 35 | */ 36 | 37 | /** 38 | * @} 39 | */ 40 | 41 | /** @defgroup IWDG_Private_Defines 42 | * @{ 43 | */ 44 | 45 | /* ---------------------- IWDG registers bit mask ----------------------------*/ 46 | 47 | /* KR register bit mask */ 48 | #define KR_KEY_Reload ((uint16_t)0xAAAA) 49 | #define KR_KEY_Enable ((uint16_t)0xCCCC) 50 | 51 | /** 52 | * @} 53 | */ 54 | 55 | /** @defgroup IWDG_Private_Macros 56 | * @{ 57 | */ 58 | 59 | /** 60 | * @} 61 | */ 62 | 63 | /** @defgroup IWDG_Private_Variables 64 | * @{ 65 | */ 66 | 67 | /** 68 | * @} 69 | */ 70 | 71 | /** @defgroup IWDG_Private_FunctionPrototypes 72 | * @{ 73 | */ 74 | 75 | /** 76 | * @} 77 | */ 78 | 79 | /** @defgroup IWDG_Private_Functions 80 | * @{ 81 | */ 82 | 83 | /** 84 | * @brief Enables or disables write access to IWDG_PR and IWDG_RLR registers. 85 | * @param IWDG_WriteAccess: new state of write access to IWDG_PR and IWDG_RLR registers. 86 | * This parameter can be one of the following values: 87 | * @arg IWDG_WriteAccess_Enable: Enable write access to IWDG_PR and IWDG_RLR registers 88 | * @arg IWDG_WriteAccess_Disable: Disable write access to IWDG_PR and IWDG_RLR registers 89 | * @retval None 90 | */ 91 | void IWDG_WriteAccessCmd(uint16_t IWDG_WriteAccess) 92 | { 93 | /* Check the parameters */ 94 | assert_param(IS_IWDG_WRITE_ACCESS(IWDG_WriteAccess)); 95 | IWDG->KR = IWDG_WriteAccess; 96 | } 97 | 98 | /** 99 | * @brief Sets IWDG Prescaler value. 100 | * @param IWDG_Prescaler: specifies the IWDG Prescaler value. 101 | * This parameter can be one of the following values: 102 | * @arg IWDG_Prescaler_4: IWDG prescaler set to 4 103 | * @arg IWDG_Prescaler_8: IWDG prescaler set to 8 104 | * @arg IWDG_Prescaler_16: IWDG prescaler set to 16 105 | * @arg IWDG_Prescaler_32: IWDG prescaler set to 32 106 | * @arg IWDG_Prescaler_64: IWDG prescaler set to 64 107 | * @arg IWDG_Prescaler_128: IWDG prescaler set to 128 108 | * @arg IWDG_Prescaler_256: IWDG prescaler set to 256 109 | * @retval None 110 | */ 111 | void IWDG_SetPrescaler(uint8_t IWDG_Prescaler) 112 | { 113 | /* Check the parameters */ 114 | assert_param(IS_IWDG_PRESCALER(IWDG_Prescaler)); 115 | IWDG->PR = IWDG_Prescaler; 116 | } 117 | 118 | /** 119 | * @brief Sets IWDG Reload value. 120 | * @param Reload: specifies the IWDG Reload value. 121 | * This parameter must be a number between 0 and 0x0FFF. 122 | * @retval None 123 | */ 124 | void IWDG_SetReload(uint16_t Reload) 125 | { 126 | /* Check the parameters */ 127 | assert_param(IS_IWDG_RELOAD(Reload)); 128 | IWDG->RLR = Reload; 129 | } 130 | 131 | /** 132 | * @brief Reloads IWDG counter with value defined in the reload register 133 | * (write access to IWDG_PR and IWDG_RLR registers disabled). 134 | * @param None 135 | * @retval None 136 | */ 137 | void IWDG_ReloadCounter(void) 138 | { 139 | IWDG->KR = KR_KEY_Reload; 140 | } 141 | 142 | /** 143 | * @brief Enables IWDG (write access to IWDG_PR and IWDG_RLR registers disabled). 144 | * @param None 145 | * @retval None 146 | */ 147 | void IWDG_Enable(void) 148 | { 149 | IWDG->KR = KR_KEY_Enable; 150 | } 151 | 152 | /** 153 | * @brief Checks whether the specified IWDG flag is set or not. 154 | * @param IWDG_FLAG: specifies the flag to check. 155 | * This parameter can be one of the following values: 156 | * @arg IWDG_FLAG_PVU: Prescaler Value Update on going 157 | * @arg IWDG_FLAG_RVU: Reload Value Update on going 158 | * @retval The new state of IWDG_FLAG (SET or RESET). 159 | */ 160 | FlagStatus IWDG_GetFlagStatus(uint16_t IWDG_FLAG) 161 | { 162 | FlagStatus bitstatus = RESET; 163 | /* Check the parameters */ 164 | assert_param(IS_IWDG_FLAG(IWDG_FLAG)); 165 | if ((IWDG->SR & IWDG_FLAG) != (uint32_t)RESET) 166 | { 167 | bitstatus = SET; 168 | } 169 | else 170 | { 171 | bitstatus = RESET; 172 | } 173 | /* Return the flag status */ 174 | return bitstatus; 175 | } 176 | 177 | /** 178 | * @} 179 | */ 180 | 181 | /** 182 | * @} 183 | */ 184 | 185 | /** 186 | * @} 187 | */ 188 | 189 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 190 | -------------------------------------------------------------------------------- /Libraries/FWlib/src/stm32f10x_dbgmcu.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f10x_dbgmcu.c 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 11-March-2011 7 | * @brief This file provides all the DBGMCU firmware functions. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2011 STMicroelectronics

19 | ****************************************************************************** 20 | */ 21 | 22 | /* Includes ------------------------------------------------------------------*/ 23 | #include "stm32f10x_dbgmcu.h" 24 | 25 | /** @addtogroup STM32F10x_StdPeriph_Driver 26 | * @{ 27 | */ 28 | 29 | /** @defgroup DBGMCU 30 | * @brief DBGMCU driver modules 31 | * @{ 32 | */ 33 | 34 | /** @defgroup DBGMCU_Private_TypesDefinitions 35 | * @{ 36 | */ 37 | 38 | /** 39 | * @} 40 | */ 41 | 42 | /** @defgroup DBGMCU_Private_Defines 43 | * @{ 44 | */ 45 | 46 | #define IDCODE_DEVID_MASK ((uint32_t)0x00000FFF) 47 | /** 48 | * @} 49 | */ 50 | 51 | /** @defgroup DBGMCU_Private_Macros 52 | * @{ 53 | */ 54 | 55 | /** 56 | * @} 57 | */ 58 | 59 | /** @defgroup DBGMCU_Private_Variables 60 | * @{ 61 | */ 62 | 63 | /** 64 | * @} 65 | */ 66 | 67 | /** @defgroup DBGMCU_Private_FunctionPrototypes 68 | * @{ 69 | */ 70 | 71 | /** 72 | * @} 73 | */ 74 | 75 | /** @defgroup DBGMCU_Private_Functions 76 | * @{ 77 | */ 78 | 79 | /** 80 | * @brief Returns the device revision identifier. 81 | * @param None 82 | * @retval Device revision identifier 83 | */ 84 | uint32_t DBGMCU_GetREVID(void) 85 | { 86 | return(DBGMCU->IDCODE >> 16); 87 | } 88 | 89 | /** 90 | * @brief Returns the device identifier. 91 | * @param None 92 | * @retval Device identifier 93 | */ 94 | uint32_t DBGMCU_GetDEVID(void) 95 | { 96 | return(DBGMCU->IDCODE & IDCODE_DEVID_MASK); 97 | } 98 | 99 | /** 100 | * @brief Configures the specified peripheral and low power mode behavior 101 | * when the MCU under Debug mode. 102 | * @param DBGMCU_Periph: specifies the peripheral and low power mode. 103 | * This parameter can be any combination of the following values: 104 | * @arg DBGMCU_SLEEP: Keep debugger connection during SLEEP mode 105 | * @arg DBGMCU_STOP: Keep debugger connection during STOP mode 106 | * @arg DBGMCU_STANDBY: Keep debugger connection during STANDBY mode 107 | * @arg DBGMCU_IWDG_STOP: Debug IWDG stopped when Core is halted 108 | * @arg DBGMCU_WWDG_STOP: Debug WWDG stopped when Core is halted 109 | * @arg DBGMCU_TIM1_STOP: TIM1 counter stopped when Core is halted 110 | * @arg DBGMCU_TIM2_STOP: TIM2 counter stopped when Core is halted 111 | * @arg DBGMCU_TIM3_STOP: TIM3 counter stopped when Core is halted 112 | * @arg DBGMCU_TIM4_STOP: TIM4 counter stopped when Core is halted 113 | * @arg DBGMCU_CAN1_STOP: Debug CAN2 stopped when Core is halted 114 | * @arg DBGMCU_I2C1_SMBUS_TIMEOUT: I2C1 SMBUS timeout mode stopped when Core is halted 115 | * @arg DBGMCU_I2C2_SMBUS_TIMEOUT: I2C2 SMBUS timeout mode stopped when Core is halted 116 | * @arg DBGMCU_TIM5_STOP: TIM5 counter stopped when Core is halted 117 | * @arg DBGMCU_TIM6_STOP: TIM6 counter stopped when Core is halted 118 | * @arg DBGMCU_TIM7_STOP: TIM7 counter stopped when Core is halted 119 | * @arg DBGMCU_TIM8_STOP: TIM8 counter stopped when Core is halted 120 | * @arg DBGMCU_CAN2_STOP: Debug CAN2 stopped when Core is halted 121 | * @arg DBGMCU_TIM15_STOP: TIM15 counter stopped when Core is halted 122 | * @arg DBGMCU_TIM16_STOP: TIM16 counter stopped when Core is halted 123 | * @arg DBGMCU_TIM17_STOP: TIM17 counter stopped when Core is halted 124 | * @arg DBGMCU_TIM9_STOP: TIM9 counter stopped when Core is halted 125 | * @arg DBGMCU_TIM10_STOP: TIM10 counter stopped when Core is halted 126 | * @arg DBGMCU_TIM11_STOP: TIM11 counter stopped when Core is halted 127 | * @arg DBGMCU_TIM12_STOP: TIM12 counter stopped when Core is halted 128 | * @arg DBGMCU_TIM13_STOP: TIM13 counter stopped when Core is halted 129 | * @arg DBGMCU_TIM14_STOP: TIM14 counter stopped when Core is halted 130 | * @param NewState: new state of the specified peripheral in Debug mode. 131 | * This parameter can be: ENABLE or DISABLE. 132 | * @retval None 133 | */ 134 | void DBGMCU_Config(uint32_t DBGMCU_Periph, FunctionalState NewState) 135 | { 136 | /* Check the parameters */ 137 | assert_param(IS_DBGMCU_PERIPH(DBGMCU_Periph)); 138 | assert_param(IS_FUNCTIONAL_STATE(NewState)); 139 | 140 | if (NewState != DISABLE) 141 | { 142 | DBGMCU->CR |= DBGMCU_Periph; 143 | } 144 | else 145 | { 146 | DBGMCU->CR &= ~DBGMCU_Periph; 147 | } 148 | } 149 | 150 | /** 151 | * @} 152 | */ 153 | 154 | /** 155 | * @} 156 | */ 157 | 158 | /** 159 | * @} 160 | */ 161 | 162 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 163 | -------------------------------------------------------------------------------- /User/nmea_decode/src/nmea.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {462522F4-3517-4507-A9C9-1D51DEBC4824} 15 | nmea 16 | Win32Proj 17 | 18 | 19 | 20 | StaticLibrary 21 | v120 22 | MultiByte 23 | true 24 | 25 | 26 | StaticLibrary 27 | v120 28 | MultiByte 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | <_ProjectFileVersion>12.0.21005.1 42 | 43 | 44 | ../build/$(Platform)/$(Configuration)/$(ProjectName)\ 45 | ../build/$(Platform)/$(Configuration)/$(ProjectName)\ 46 | 47 | 48 | ../build/$(Platform)/$(Configuration)/$(ProjectName)\ 49 | ../build/$(Platform)/$(Configuration)/$(ProjectName)\ 50 | 51 | 52 | 53 | Disabled 54 | ../include;%(AdditionalIncludeDirectories) 55 | WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) 56 | true 57 | 58 | EnableFastChecks 59 | MultiThreadedDebugDLL 60 | 61 | Level4 62 | ProgramDatabase 63 | CompileAsC 64 | 65 | 66 | ../lib/$(ProjectName)_d.lib 67 | 68 | 69 | 70 | 71 | ../include;%(AdditionalIncludeDirectories) 72 | WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) 73 | 74 | MultiThreaded 75 | 76 | Level4 77 | ProgramDatabase 78 | CompileAsC 79 | 80 | 81 | ../lib/$(ProjectName).lib 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | -------------------------------------------------------------------------------- /User/FATFS/diskio.c: -------------------------------------------------------------------------------- 1 | /*-----------------------------------------------------------------------*/ 2 | /* Low level disk I/O module skeleton for FatFs (C)ChaN, 2013 */ 3 | /*-----------------------------------------------------------------------*/ 4 | /* If a working storage control module is available, it should be */ 5 | /* attached to the FatFs via a glue function rather than modifying it. */ 6 | /* This is an example of glue functions to attach various exsisting */ 7 | /* storage control module to the FatFs module with a defined API. */ 8 | /*-----------------------------------------------------------------------*/ 9 | 10 | #include "diskio.h" /* FatFs lower layer API */ 11 | #include "ff.h" 12 | 13 | #ifndef FATFS_FLASH_SPI 14 | #define FATFS_FLASH_SPI 1 15 | #endif 16 | 17 | #ifndef FATFS_USE_SDIO 18 | #define FATFS_USE_SDIO 1 19 | #endif 20 | 21 | /* Set in defines.h file if you want it */ 22 | #ifndef TM_FATFS_CUSTOM_FATTIME 23 | #define TM_FATFS_CUSTOM_FATTIME 0 24 | #endif 25 | 26 | 27 | /* Include SD card files if is enabled */ 28 | #if FATFS_USE_SDIO == 1 29 | #include "./fatfs/drivers/fatfs_sd_sdio.h" 30 | #endif 31 | 32 | #if FATFS_FLASH_SPI == 1 33 | #include "./fatfs/drivers/fatfs_flash_spi.h" 34 | #endif 35 | 36 | 37 | /* Definitions of physical drive number for each media */ 38 | #define ATA 0 39 | #define SPI_FLASH 1 40 | 41 | /*-----------------------------------------------------------------------*/ 42 | /* Inidialize a Drive */ 43 | /*-----------------------------------------------------------------------*/ 44 | 45 | DSTATUS disk_initialize ( 46 | BYTE pdrv /* Physical drive nmuber (0..) */ 47 | ) 48 | { 49 | 50 | DSTATUS status = STA_NOINIT; 51 | switch (pdrv) { 52 | case ATA: /* SD CARD */ 53 | #if FATFS_USE_SDIO == 1 54 | status = TM_FATFS_SD_SDIO_disk_initialize(); /* SDIO communication */ 55 | #endif 56 | break; 57 | case SPI_FLASH: 58 | #if FATFS_FLASH_SPI ==1 59 | status = TM_FATFS_FLASH_SPI_disk_initialize(); /* SDIO communication */ 60 | #endif 61 | break; 62 | 63 | default: 64 | status = STA_NOINIT; 65 | } 66 | return status; 67 | } 68 | 69 | 70 | 71 | /*-----------------------------------------------------------------------*/ 72 | /* Get Disk Status */ 73 | /*-----------------------------------------------------------------------*/ 74 | 75 | DSTATUS disk_status ( 76 | BYTE pdrv /* Physical drive nmuber (0..) */ 77 | ) 78 | { 79 | 80 | DSTATUS status = STA_NOINIT; 81 | 82 | switch (pdrv) { 83 | case ATA: /* SD CARD */ 84 | #if FATFS_USE_SDIO == 1 85 | status = TM_FATFS_SD_SDIO_disk_status(); /* SDIO communication */ 86 | #endif 87 | break; 88 | case SPI_FLASH: 89 | #if FATFS_FLASH_SPI ==1 90 | status = TM_FATFS_FLASH_SPI_disk_status(); /* SDIO communication */ 91 | #endif 92 | break; 93 | 94 | default: 95 | status = STA_NOINIT; 96 | } 97 | return status; 98 | } 99 | 100 | 101 | 102 | /*-----------------------------------------------------------------------*/ 103 | /* Read Sector(s) */ 104 | /*-----------------------------------------------------------------------*/ 105 | 106 | DRESULT disk_read ( 107 | BYTE pdrv, /* Physical drive nmuber (0..) */ 108 | BYTE *buff, /* Data buffer to store read data */ 109 | DWORD sector, /* Sector address (LBA) */ 110 | UINT count /* Number of sectors to read (1..128) */ 111 | ) 112 | { 113 | DRESULT status = RES_PARERR; 114 | switch (pdrv) { 115 | case ATA: /* SD CARD */ 116 | #if FATFS_USE_SDIO == 1 117 | status = TM_FATFS_SD_SDIO_disk_read(buff, sector, count); /* SDIO communication */ 118 | #endif 119 | break; 120 | case SPI_FLASH: 121 | #if FATFS_FLASH_SPI ==1 122 | status = TM_FATFS_FLASH_SPI_disk_read(buff, sector, count); /* SDIO communication */ 123 | #endif 124 | break; 125 | default: 126 | status = RES_PARERR; 127 | } 128 | return status; 129 | } 130 | 131 | 132 | 133 | /*-----------------------------------------------------------------------*/ 134 | /* Write Sector(s) */ 135 | /*-----------------------------------------------------------------------*/ 136 | 137 | #if _USE_WRITE 138 | DRESULT disk_write ( 139 | BYTE pdrv, /* Physical drive nmuber (0..) */ 140 | const BYTE *buff, /* Data to be written */ 141 | DWORD sector, /* Sector address (LBA) */ 142 | UINT count /* Number of sectors to write (1..128) */ 143 | ) 144 | { 145 | DRESULT status = RES_PARERR; 146 | if (!count) { 147 | return RES_PARERR; /* Check parameter */ 148 | } 149 | 150 | switch (pdrv) { 151 | case ATA: /* SD CARD */ 152 | #if FATFS_USE_SDIO == 1 153 | status = TM_FATFS_SD_SDIO_disk_write((BYTE *)buff, sector, count); /* SDIO communication */ 154 | #endif 155 | break; 156 | 157 | case SPI_FLASH: 158 | #if FATFS_FLASH_SPI ==1 159 | status = TM_FATFS_FLASH_SPI_disk_write((BYTE *)buff, sector, count); /* SDIO communication */ 160 | #endif 161 | break; 162 | default: 163 | status = RES_PARERR; 164 | } 165 | return status; 166 | } 167 | #endif 168 | 169 | 170 | /*-----------------------------------------------------------------------*/ 171 | /* Miscellaneous Functions */ 172 | /*-----------------------------------------------------------------------*/ 173 | 174 | #if _USE_IOCTL 175 | DRESULT disk_ioctl ( 176 | BYTE pdrv, /* Physical drive nmuber (0..) */ 177 | BYTE cmd, /* Control code */ 178 | void *buff /* Buffer to send/receive control data */ 179 | ) 180 | { 181 | DRESULT status = RES_PARERR; 182 | switch (pdrv) { 183 | case ATA: /* SD CARD */ 184 | #if FATFS_USE_SDIO == 1 185 | status = TM_FATFS_SD_SDIO_disk_ioctl(cmd, buff); /* SDIO communication */ 186 | #endif 187 | break; 188 | case SPI_FLASH: 189 | #if FATFS_FLASH_SPI ==1 190 | status = TM_FATFS_FLASH_SPI_disk_ioctl(cmd, buff); /* SDIO communication */ 191 | #endif 192 | break; 193 | default: 194 | status = RES_PARERR; 195 | } 196 | return status; 197 | } 198 | #endif 199 | 200 | __weak DWORD get_fattime(void) { 201 | /* Returns current time packed into a DWORD variable */ 202 | return ((DWORD)(2013 - 1980) << 25) /* Year 2013 */ 203 | | ((DWORD)7 << 21) /* Month 7 */ 204 | | ((DWORD)28 << 16) /* Mday 28 */ 205 | | ((DWORD)0 << 11) /* Hour 0 */ 206 | | ((DWORD)0 << 5) /* Min 0 */ 207 | | ((DWORD)0 >> 1); /* Sec 0 */ 208 | } 209 | 210 | 211 | -------------------------------------------------------------------------------- /Libraries/FWlib/src/stm32f10x_wwdg.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f10x_wwdg.c 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 11-March-2011 7 | * @brief This file provides all the WWDG firmware functions. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2011 STMicroelectronics

19 | ****************************************************************************** 20 | */ 21 | 22 | /* Includes ------------------------------------------------------------------*/ 23 | #include "stm32f10x_wwdg.h" 24 | #include "stm32f10x_rcc.h" 25 | 26 | /** @addtogroup STM32F10x_StdPeriph_Driver 27 | * @{ 28 | */ 29 | 30 | /** @defgroup WWDG 31 | * @brief WWDG driver modules 32 | * @{ 33 | */ 34 | 35 | /** @defgroup WWDG_Private_TypesDefinitions 36 | * @{ 37 | */ 38 | 39 | /** 40 | * @} 41 | */ 42 | 43 | /** @defgroup WWDG_Private_Defines 44 | * @{ 45 | */ 46 | 47 | /* ----------- WWDG registers bit address in the alias region ----------- */ 48 | #define WWDG_OFFSET (WWDG_BASE - PERIPH_BASE) 49 | 50 | /* Alias word address of EWI bit */ 51 | #define CFR_OFFSET (WWDG_OFFSET + 0x04) 52 | #define EWI_BitNumber 0x09 53 | #define CFR_EWI_BB (PERIPH_BB_BASE + (CFR_OFFSET * 32) + (EWI_BitNumber * 4)) 54 | 55 | /* --------------------- WWDG registers bit mask ------------------------ */ 56 | 57 | /* CR register bit mask */ 58 | #define CR_WDGA_Set ((uint32_t)0x00000080) 59 | 60 | /* CFR register bit mask */ 61 | #define CFR_WDGTB_Mask ((uint32_t)0xFFFFFE7F) 62 | #define CFR_W_Mask ((uint32_t)0xFFFFFF80) 63 | #define BIT_Mask ((uint8_t)0x7F) 64 | 65 | /** 66 | * @} 67 | */ 68 | 69 | /** @defgroup WWDG_Private_Macros 70 | * @{ 71 | */ 72 | 73 | /** 74 | * @} 75 | */ 76 | 77 | /** @defgroup WWDG_Private_Variables 78 | * @{ 79 | */ 80 | 81 | /** 82 | * @} 83 | */ 84 | 85 | /** @defgroup WWDG_Private_FunctionPrototypes 86 | * @{ 87 | */ 88 | 89 | /** 90 | * @} 91 | */ 92 | 93 | /** @defgroup WWDG_Private_Functions 94 | * @{ 95 | */ 96 | 97 | /** 98 | * @brief Deinitializes the WWDG peripheral registers to their default reset values. 99 | * @param None 100 | * @retval None 101 | */ 102 | void WWDG_DeInit(void) 103 | { 104 | RCC_APB1PeriphResetCmd(RCC_APB1Periph_WWDG, ENABLE); 105 | RCC_APB1PeriphResetCmd(RCC_APB1Periph_WWDG, DISABLE); 106 | } 107 | 108 | /** 109 | * @brief Sets the WWDG Prescaler. 110 | * @param WWDG_Prescaler: specifies the WWDG Prescaler. 111 | * This parameter can be one of the following values: 112 | * @arg WWDG_Prescaler_1: WWDG counter clock = (PCLK1/4096)/1 113 | * @arg WWDG_Prescaler_2: WWDG counter clock = (PCLK1/4096)/2 114 | * @arg WWDG_Prescaler_4: WWDG counter clock = (PCLK1/4096)/4 115 | * @arg WWDG_Prescaler_8: WWDG counter clock = (PCLK1/4096)/8 116 | * @retval None 117 | */ 118 | void WWDG_SetPrescaler(uint32_t WWDG_Prescaler) 119 | { 120 | uint32_t tmpreg = 0; 121 | /* Check the parameters */ 122 | assert_param(IS_WWDG_PRESCALER(WWDG_Prescaler)); 123 | /* Clear WDGTB[1:0] bits */ 124 | tmpreg = WWDG->CFR & CFR_WDGTB_Mask; 125 | /* Set WDGTB[1:0] bits according to WWDG_Prescaler value */ 126 | tmpreg |= WWDG_Prescaler; 127 | /* Store the new value */ 128 | WWDG->CFR = tmpreg; 129 | } 130 | 131 | /** 132 | * @brief Sets the WWDG window value. 133 | * @param WindowValue: specifies the window value to be compared to the downcounter. 134 | * This parameter value must be lower than 0x80. 135 | * @retval None 136 | */ 137 | void WWDG_SetWindowValue(uint8_t WindowValue) 138 | { 139 | __IO uint32_t tmpreg = 0; 140 | 141 | /* Check the parameters */ 142 | assert_param(IS_WWDG_WINDOW_VALUE(WindowValue)); 143 | /* Clear W[6:0] bits */ 144 | 145 | tmpreg = WWDG->CFR & CFR_W_Mask; 146 | 147 | /* Set W[6:0] bits according to WindowValue value */ 148 | tmpreg |= WindowValue & (uint32_t) BIT_Mask; 149 | 150 | /* Store the new value */ 151 | WWDG->CFR = tmpreg; 152 | } 153 | 154 | /** 155 | * @brief Enables the WWDG Early Wakeup interrupt(EWI). 156 | * @param None 157 | * @retval None 158 | */ 159 | void WWDG_EnableIT(void) 160 | { 161 | *(__IO uint32_t *) CFR_EWI_BB = (uint32_t)ENABLE; 162 | } 163 | 164 | /** 165 | * @brief Sets the WWDG counter value. 166 | * @param Counter: specifies the watchdog counter value. 167 | * This parameter must be a number between 0x40 and 0x7F. 168 | * @retval None 169 | */ 170 | void WWDG_SetCounter(uint8_t Counter) 171 | { 172 | /* Check the parameters */ 173 | assert_param(IS_WWDG_COUNTER(Counter)); 174 | /* Write to T[6:0] bits to configure the counter value, no need to do 175 | a read-modify-write; writing a 0 to WDGA bit does nothing */ 176 | WWDG->CR = Counter & BIT_Mask; 177 | } 178 | 179 | /** 180 | * @brief Enables WWDG and load the counter value. 181 | * @param Counter: specifies the watchdog counter value. 182 | * This parameter must be a number between 0x40 and 0x7F. 183 | * @retval None 184 | */ 185 | void WWDG_Enable(uint8_t Counter) 186 | { 187 | /* Check the parameters */ 188 | assert_param(IS_WWDG_COUNTER(Counter)); 189 | WWDG->CR = CR_WDGA_Set | Counter; 190 | } 191 | 192 | /** 193 | * @brief Checks whether the Early Wakeup interrupt flag is set or not. 194 | * @param None 195 | * @retval The new state of the Early Wakeup interrupt flag (SET or RESET) 196 | */ 197 | FlagStatus WWDG_GetFlagStatus(void) 198 | { 199 | return (FlagStatus)(WWDG->SR); 200 | } 201 | 202 | /** 203 | * @brief Clears Early Wakeup interrupt flag. 204 | * @param None 205 | * @retval None 206 | */ 207 | void WWDG_ClearFlag(void) 208 | { 209 | WWDG->SR = (uint32_t)RESET; 210 | } 211 | 212 | /** 213 | * @} 214 | */ 215 | 216 | /** 217 | * @} 218 | */ 219 | 220 | /** 221 | * @} 222 | */ 223 | 224 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 225 | -------------------------------------------------------------------------------- /Project/RVMDK(uv5)/DebugConfig/GPS_STM32F103RC_1.0.0.dbgconf: -------------------------------------------------------------------------------- 1 | // <<< Use Configuration Wizard in Context Menu >>> 2 | // Debug MCU Configuration 3 | // DBG_SLEEP 4 | // Debug Sleep Mode 5 | // 0: (FCLK=On, HCLK=Off) FCLK is clocked by the system clock as previously configured by the software while HCLK is disabled 6 | // 1: (FCLK=On, HCLK=On) HCLK is fed by the same clock that is provided to FCLK 7 | // DBG_STOP 8 | // Debug Stop Mode 9 | // 0: (FCLK=Off, HCLK=Off) Clock controller disables all clocks 10 | // 1: (FCLK=On, HCLK=On) FCLK and HCLK are provided by the internal RC oscillator which remains active 11 | // DBG_STANDBY 12 | // Debug Standby Mode 13 | // 0: (FCLK=Off, HCLK=Off) The whole digital part is unpowered. 14 | // 1: (FCLK=On, HCLK=On) Digital part is powered and FCLK and HCLK are provided by the internal RC oscillator which remains active 15 | // DBG_IWDG_STOP 16 | // Debug independent watchdog stopped when core is halted 17 | // 0: The watchdog counter clock continues even if the core is halted 18 | // 1: The watchdog counter clock is stopped when the core is halted 19 | // DBG_WWDG_STOP 20 | // Debug window watchdog stopped when core is halted 21 | // 0: The window watchdog counter clock continues even if the core is halted 22 | // 1: The window watchdog counter clock is stopped when the core is halted 23 | // DBG_TIM1_STOP 24 | // Timer 1 counter stopped when core is halted 25 | // 0: The clock of the involved Timer Counter is fed even if the core is halted 26 | // 1: The clock of the involved Timer counter is stopped when the core is halted 27 | // DBG_TIM2_STOP 28 | // Timer 2 counter stopped when core is halted 29 | // 0: The clock of the involved Timer Counter is fed even if the core is halted 30 | // 1: The clock of the involved Timer counter is stopped when the core is halted 31 | // DBG_TIM3_STOP 32 | // Timer 3 counter stopped when core is halted 33 | // 0: The clock of the involved Timer Counter is fed even if the core is halted 34 | // 1: The clock of the involved Timer counter is stopped when the core is halted 35 | // DBG_TIM4_STOP 36 | // Timer 4 counter stopped when core is halted 37 | // 0: The clock of the involved Timer Counter is fed even if the core is halted 38 | // 1: The clock of the involved Timer counter is stopped when the core is halted 39 | // DBG_CAN1_STOP 40 | // Debug CAN1 stopped when Core is halted 41 | // 0: Same behavior as in normal mode 42 | // 1: CAN1 receive registers are frozen 43 | // DBG_I2C1_SMBUS_TIMEOUT 44 | // I2C1 SMBUS timeout mode stopped when Core is halted 45 | // 0: Same behavior as in normal mode 46 | // 1: The SMBUS timeout is frozen 47 | // DBG_I2C2_SMBUS_TIMEOUT 48 | // I2C2 SMBUS timeout mode stopped when Core is halted 49 | // 0: Same behavior as in normal mode 50 | // 1: The SMBUS timeout is frozen 51 | // DBG_TIM8_STOP 52 | // Timer 8 counter stopped when core is halted 53 | // 0: The clock of the involved timer counter is fed even if the core is halted, and the outputs behave normally. 54 | // 1: The clock of the involved timer counter is stopped when the core is halted, and the outputs are disabled (as if there were an emergency stop in response to a break event). 55 | // DBG_TIM5_STOP 56 | // Timer 5 counter stopped when core is halted 57 | // 0: The clock of the involved timer counter is fed even if the core is halted, and the outputs behave normally. 58 | // 1: The clock of the involved timer counter is stopped when the core is halted, and the outputs are disabled (as if there were an emergency stop in response to a break event). 59 | // DBG_TIM6_STOP 60 | // Timer 6 counter stopped when core is halted 61 | // 0: The clock of the involved timer counter is fed even if the core is halted, and the outputs behave normally. 62 | // 1: The clock of the involved timer counter is stopped when the core is halted, and the outputs are disabled (as if there were an emergency stop in response to a break event). 63 | // DBG_TIM7_STOP 64 | // Timer 7 counter stopped when core is halted 65 | // 0: The clock of the involved timer counter is fed even if the core is halted, and the outputs behave normally. 66 | // 1: The clock of the involved timer counter is stopped when the core is halted, and the outputs are disabled (as if there were an emergency stop in response to a break event). 67 | // DBG_CAN2_STOP 68 | // Debug CAN2 stopped when Core is halted 69 | // 0: Same behavior as in normal mode 70 | // 1: CAN2 receive registers are frozen 71 | // DBG_TIM12_STOP 72 | // Timer 12 counter stopped when core is halted 73 | // 0: The clock of the involved timer counter is fed even if the core is halted, and the outputs behave normally. 74 | // 1: The clock of the involved timer counter is stopped when the core is halted, and the outputs are disabled (as if there were an emergency stop in response to a break event). 75 | // DBG_TIM13_STOP 76 | // Timer 13 counter stopped when core is halted 77 | // 0: The clock of the involved timer counter is fed even if the core is halted, and the outputs behave normally. 78 | // 1: The clock of the involved timer counter is stopped when the core is halted, and the outputs are disabled (as if there were an emergency stop in response to a break event). 79 | // DBG_TIM14_STOP 80 | // Timer 14 counter stopped when core is halted 81 | // 0: The clock of the involved timer counter is fed even if the core is halted, and the outputs behave normally. 82 | // 1: The clock of the involved timer counter is stopped when the core is halted, and the outputs are disabled (as if there were an emergency stop in response to a break event). 83 | // DBG_TIM9_STOP 84 | // Timer 9 counter stopped when core is halted 85 | // 0: The clock of the involved timer counter is fed even if the core is halted, and the outputs behave normally. 86 | // 1: The clock of the involved timer counter is stopped when the core is halted, and the outputs are disabled (as if there were an emergency stop in response to a break event). 87 | // DBG_TIM10_STOP 88 | // Timer 10 counter stopped when core is halted 89 | // 0: The clock of the involved timer counter is fed even if the core is halted, and the outputs behave normally. 90 | // 1: The clock of the involved timer counter is stopped when the core is halted, and the outputs are disabled (as if there were an emergency stop in response to a break event). 91 | // DBG_TIM11_STOP 92 | // Timer 11 counter stopped when core is halted 93 | // 0: The clock of the involved timer counter is fed even if the core is halted, and the outputs behave normally. 94 | // 1: The clock of the involved timer counter is stopped when the core is halted, and the outputs are disabled (as if there were an emergency stop in response to a break event). 95 | // 96 | DbgMCU_CR = 0x00000007; 97 | // <<< end of configuration section >>> -------------------------------------------------------------------------------- /User/nmea_decode/src/tok.c: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * NMEA library 4 | * URL: http://nmea.sourceforge.net 5 | * Author: Tim (xtimor@gmail.com) 6 | * Licence: http://www.gnu.org/licenses/lgpl.html 7 | * $Id: tok.c 17 2008-03-11 11:56:11Z xtimor $ 8 | * 9 | */ 10 | 11 | /*! \file tok.h */ 12 | 13 | #include "nmea/tok.h" 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #define NMEA_TOKS_COMPARE (1) 23 | #define NMEA_TOKS_PERCENT (2) 24 | #define NMEA_TOKS_WIDTH (3) 25 | #define NMEA_TOKS_TYPE (4) 26 | 27 | /** 28 | * \brief Calculate control sum of binary buffer 29 | */ 30 | int nmea_calc_crc(const char *buff, int buff_sz) 31 | { 32 | int chsum = 0, 33 | it; 34 | 35 | for(it = 0; it < buff_sz; ++it) 36 | chsum ^= (int)buff[it]; 37 | 38 | return chsum; 39 | } 40 | 41 | /** 42 | * \brief Convert string to number 43 | */ 44 | int nmea_atoi(const char *str, int str_sz, int radix) 45 | { 46 | char *tmp_ptr; 47 | char buff[NMEA_CONVSTR_BUF]; 48 | int res = 0; 49 | 50 | if(str_sz < NMEA_CONVSTR_BUF) 51 | { 52 | memcpy(&buff[0], str, str_sz); 53 | buff[str_sz] = '\0'; 54 | res = strtol(&buff[0], &tmp_ptr, radix); 55 | } 56 | 57 | return res; 58 | } 59 | 60 | /** 61 | * \brief Convert string to fraction number 62 | */ 63 | double nmea_atof(const char *str, int str_sz) 64 | { 65 | char *tmp_ptr; 66 | char buff[NMEA_CONVSTR_BUF]; 67 | double res = 0; 68 | 69 | if(str_sz < NMEA_CONVSTR_BUF) 70 | { 71 | memcpy(&buff[0], str, str_sz); 72 | buff[str_sz] = '\0'; 73 | res = strtod(&buff[0], &tmp_ptr); 74 | } 75 | 76 | return res; 77 | } 78 | 79 | /** 80 | * \brief Formating string (like standart printf) with CRC tail (*CRC) 81 | */ 82 | int nmea_printf(char *buff, int buff_sz, const char *format, ...) 83 | { 84 | int retval, add = 0; 85 | va_list arg_ptr; 86 | 87 | if(buff_sz <= 0) 88 | return 0; 89 | 90 | va_start(arg_ptr, format); 91 | 92 | retval = NMEA_POSIX(vsnprintf)(buff, buff_sz, format, arg_ptr); 93 | 94 | if(retval > 0) 95 | { 96 | add = NMEA_POSIX(snprintf)( 97 | buff + retval, buff_sz - retval, "*%02x\r\n", 98 | nmea_calc_crc(buff + 1, retval - 1)); 99 | } 100 | 101 | retval += add; 102 | 103 | if(retval < 0 || retval > buff_sz) 104 | { 105 | memset(buff, ' ', buff_sz); 106 | retval = buff_sz; 107 | } 108 | 109 | va_end(arg_ptr); 110 | 111 | return retval; 112 | } 113 | 114 | /** 115 | * \brief Analyse string (specificate for NMEA sentences) 116 | */ 117 | int nmea_scanf(const char *buff, int buff_sz, const char *format, ...) 118 | { 119 | const char *beg_tok; 120 | const char *end_buf = buff + buff_sz; 121 | 122 | va_list arg_ptr; 123 | int tok_type = NMEA_TOKS_COMPARE; 124 | int width = 0; 125 | const char *beg_fmt = 0; 126 | int snum = 0, unum = 0; 127 | 128 | int tok_count = 0; 129 | void *parg_target; 130 | 131 | va_start(arg_ptr, format); 132 | 133 | for(; *format && buff < end_buf; ++format) 134 | { 135 | switch(tok_type) 136 | { 137 | case NMEA_TOKS_COMPARE: 138 | if('%' == *format) 139 | tok_type = NMEA_TOKS_PERCENT; 140 | else if(*buff++ != *format) 141 | goto fail; 142 | break; 143 | case NMEA_TOKS_PERCENT: 144 | width = 0; 145 | beg_fmt = format; 146 | tok_type = NMEA_TOKS_WIDTH; 147 | case NMEA_TOKS_WIDTH: 148 | if(isdigit(*format)) 149 | break; 150 | { 151 | tok_type = NMEA_TOKS_TYPE; 152 | if(format > beg_fmt) 153 | width = nmea_atoi(beg_fmt, (int)(format - beg_fmt), 10); 154 | } 155 | case NMEA_TOKS_TYPE: 156 | beg_tok = buff; 157 | 158 | if(!width && ('c' == *format || 'C' == *format) && *buff != format[1]) 159 | width = 1; 160 | 161 | if(width) 162 | { 163 | if(buff + width <= end_buf) 164 | buff += width; 165 | else 166 | goto fail; 167 | } 168 | else 169 | { 170 | if(!format[1] || (0 == (buff = (char *)memchr(buff, format[1], end_buf - buff)))) 171 | buff = end_buf; 172 | } 173 | 174 | if(buff > end_buf) 175 | goto fail; 176 | 177 | tok_type = NMEA_TOKS_COMPARE; 178 | tok_count++; 179 | 180 | parg_target = 0; width = (int)(buff - beg_tok); 181 | 182 | switch(*format) 183 | { 184 | case 'c': 185 | case 'C': 186 | parg_target = (void *)va_arg(arg_ptr, char *); 187 | if(width && 0 != (parg_target)) 188 | *((char *)parg_target) = *beg_tok; 189 | break; 190 | case 's': 191 | case 'S': 192 | parg_target = (void *)va_arg(arg_ptr, char *); 193 | if(width && 0 != (parg_target)) 194 | { 195 | memcpy(parg_target, beg_tok, width); 196 | ((char *)parg_target)[width] = '\0'; 197 | } 198 | break; 199 | case 'f': 200 | case 'g': 201 | case 'G': 202 | case 'e': 203 | case 'E': 204 | parg_target = (void *)va_arg(arg_ptr, double *); 205 | if(width && 0 != (parg_target)) 206 | *((double *)parg_target) = nmea_atof(beg_tok, width); 207 | break; 208 | }; 209 | 210 | if(parg_target) 211 | break; 212 | if(0 == (parg_target = (void *)va_arg(arg_ptr, int *))) 213 | break; 214 | if(!width) 215 | break; 216 | 217 | switch(*format) 218 | { 219 | case 'd': 220 | case 'i': 221 | snum = nmea_atoi(beg_tok, width, 10); 222 | memcpy(parg_target, &snum, sizeof(int)); 223 | break; 224 | case 'u': 225 | unum = nmea_atoi(beg_tok, width, 10); 226 | memcpy(parg_target, &unum, sizeof(unsigned int)); 227 | break; 228 | case 'x': 229 | case 'X': 230 | unum = nmea_atoi(beg_tok, width, 16); 231 | memcpy(parg_target, &unum, sizeof(unsigned int)); 232 | break; 233 | case 'o': 234 | unum = nmea_atoi(beg_tok, width, 8); 235 | memcpy(parg_target, &unum, sizeof(unsigned int)); 236 | break; 237 | default: 238 | goto fail; 239 | }; 240 | 241 | break; 242 | }; 243 | } 244 | 245 | fail: 246 | 247 | va_end(arg_ptr); 248 | 249 | return tok_count; 250 | } 251 | -------------------------------------------------------------------------------- /Libraries/FWlib/inc/stm32f10x_cec.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f10x_cec.h 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 11-March-2011 7 | * @brief This file contains all the functions prototypes for the CEC firmware 8 | * library. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 13 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 14 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 15 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 16 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 17 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 18 | * 19 | *

© COPYRIGHT 2011 STMicroelectronics

20 | ****************************************************************************** 21 | */ 22 | 23 | /* Define to prevent recursive inclusion -------------------------------------*/ 24 | #ifndef __STM32F10x_CEC_H 25 | #define __STM32F10x_CEC_H 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | /* Includes ------------------------------------------------------------------*/ 32 | #include "stm32f10x.h" 33 | 34 | /** @addtogroup STM32F10x_StdPeriph_Driver 35 | * @{ 36 | */ 37 | 38 | /** @addtogroup CEC 39 | * @{ 40 | */ 41 | 42 | 43 | /** @defgroup CEC_Exported_Types 44 | * @{ 45 | */ 46 | 47 | /** 48 | * @brief CEC Init structure definition 49 | */ 50 | typedef struct 51 | { 52 | uint16_t CEC_BitTimingMode; /*!< Configures the CEC Bit Timing Error Mode. 53 | This parameter can be a value of @ref CEC_BitTiming_Mode */ 54 | uint16_t CEC_BitPeriodMode; /*!< Configures the CEC Bit Period Error Mode. 55 | This parameter can be a value of @ref CEC_BitPeriod_Mode */ 56 | }CEC_InitTypeDef; 57 | 58 | /** 59 | * @} 60 | */ 61 | 62 | /** @defgroup CEC_Exported_Constants 63 | * @{ 64 | */ 65 | 66 | /** @defgroup CEC_BitTiming_Mode 67 | * @{ 68 | */ 69 | #define CEC_BitTimingStdMode ((uint16_t)0x00) /*!< Bit timing error Standard Mode */ 70 | #define CEC_BitTimingErrFreeMode CEC_CFGR_BTEM /*!< Bit timing error Free Mode */ 71 | 72 | #define IS_CEC_BIT_TIMING_ERROR_MODE(MODE) (((MODE) == CEC_BitTimingStdMode) || \ 73 | ((MODE) == CEC_BitTimingErrFreeMode)) 74 | /** 75 | * @} 76 | */ 77 | 78 | /** @defgroup CEC_BitPeriod_Mode 79 | * @{ 80 | */ 81 | #define CEC_BitPeriodStdMode ((uint16_t)0x00) /*!< Bit period error Standard Mode */ 82 | #define CEC_BitPeriodFlexibleMode CEC_CFGR_BPEM /*!< Bit period error Flexible Mode */ 83 | 84 | #define IS_CEC_BIT_PERIOD_ERROR_MODE(MODE) (((MODE) == CEC_BitPeriodStdMode) || \ 85 | ((MODE) == CEC_BitPeriodFlexibleMode)) 86 | /** 87 | * @} 88 | */ 89 | 90 | 91 | /** @defgroup CEC_interrupts_definition 92 | * @{ 93 | */ 94 | #define CEC_IT_TERR CEC_CSR_TERR 95 | #define CEC_IT_TBTRF CEC_CSR_TBTRF 96 | #define CEC_IT_RERR CEC_CSR_RERR 97 | #define CEC_IT_RBTF CEC_CSR_RBTF 98 | #define IS_CEC_GET_IT(IT) (((IT) == CEC_IT_TERR) || ((IT) == CEC_IT_TBTRF) || \ 99 | ((IT) == CEC_IT_RERR) || ((IT) == CEC_IT_RBTF)) 100 | /** 101 | * @} 102 | */ 103 | 104 | 105 | /** @defgroup CEC_Own_Address 106 | * @{ 107 | */ 108 | #define IS_CEC_ADDRESS(ADDRESS) ((ADDRESS) < 0x10) 109 | /** 110 | * @} 111 | */ 112 | 113 | /** @defgroup CEC_Prescaler 114 | * @{ 115 | */ 116 | #define IS_CEC_PRESCALER(PRESCALER) ((PRESCALER) <= 0x3FFF) 117 | 118 | /** 119 | * @} 120 | */ 121 | 122 | /** @defgroup CEC_flags_definition 123 | * @{ 124 | */ 125 | 126 | /** 127 | * @brief ESR register flags 128 | */ 129 | #define CEC_FLAG_BTE ((uint32_t)0x10010000) 130 | #define CEC_FLAG_BPE ((uint32_t)0x10020000) 131 | #define CEC_FLAG_RBTFE ((uint32_t)0x10040000) 132 | #define CEC_FLAG_SBE ((uint32_t)0x10080000) 133 | #define CEC_FLAG_ACKE ((uint32_t)0x10100000) 134 | #define CEC_FLAG_LINE ((uint32_t)0x10200000) 135 | #define CEC_FLAG_TBTFE ((uint32_t)0x10400000) 136 | 137 | /** 138 | * @brief CSR register flags 139 | */ 140 | #define CEC_FLAG_TEOM ((uint32_t)0x00000002) 141 | #define CEC_FLAG_TERR ((uint32_t)0x00000004) 142 | #define CEC_FLAG_TBTRF ((uint32_t)0x00000008) 143 | #define CEC_FLAG_RSOM ((uint32_t)0x00000010) 144 | #define CEC_FLAG_REOM ((uint32_t)0x00000020) 145 | #define CEC_FLAG_RERR ((uint32_t)0x00000040) 146 | #define CEC_FLAG_RBTF ((uint32_t)0x00000080) 147 | 148 | #define IS_CEC_CLEAR_FLAG(FLAG) ((((FLAG) & (uint32_t)0xFFFFFF03) == 0x00) && ((FLAG) != 0x00)) 149 | 150 | #define IS_CEC_GET_FLAG(FLAG) (((FLAG) == CEC_FLAG_BTE) || ((FLAG) == CEC_FLAG_BPE) || \ 151 | ((FLAG) == CEC_FLAG_RBTFE) || ((FLAG)== CEC_FLAG_SBE) || \ 152 | ((FLAG) == CEC_FLAG_ACKE) || ((FLAG) == CEC_FLAG_LINE) || \ 153 | ((FLAG) == CEC_FLAG_TBTFE) || ((FLAG) == CEC_FLAG_TEOM) || \ 154 | ((FLAG) == CEC_FLAG_TERR) || ((FLAG) == CEC_FLAG_TBTRF) || \ 155 | ((FLAG) == CEC_FLAG_RSOM) || ((FLAG) == CEC_FLAG_REOM) || \ 156 | ((FLAG) == CEC_FLAG_RERR) || ((FLAG) == CEC_FLAG_RBTF)) 157 | 158 | /** 159 | * @} 160 | */ 161 | 162 | /** 163 | * @} 164 | */ 165 | 166 | /** @defgroup CEC_Exported_Macros 167 | * @{ 168 | */ 169 | 170 | /** 171 | * @} 172 | */ 173 | 174 | /** @defgroup CEC_Exported_Functions 175 | * @{ 176 | */ 177 | void CEC_DeInit(void); 178 | void CEC_Init(CEC_InitTypeDef* CEC_InitStruct); 179 | void CEC_Cmd(FunctionalState NewState); 180 | void CEC_ITConfig(FunctionalState NewState); 181 | void CEC_OwnAddressConfig(uint8_t CEC_OwnAddress); 182 | void CEC_SetPrescaler(uint16_t CEC_Prescaler); 183 | void CEC_SendDataByte(uint8_t Data); 184 | uint8_t CEC_ReceiveDataByte(void); 185 | void CEC_StartOfMessage(void); 186 | void CEC_EndOfMessageCmd(FunctionalState NewState); 187 | FlagStatus CEC_GetFlagStatus(uint32_t CEC_FLAG); 188 | void CEC_ClearFlag(uint32_t CEC_FLAG); 189 | ITStatus CEC_GetITStatus(uint8_t CEC_IT); 190 | void CEC_ClearITPendingBit(uint16_t CEC_IT); 191 | 192 | #ifdef __cplusplus 193 | } 194 | #endif 195 | 196 | #endif /* __STM32F10x_CEC_H */ 197 | 198 | /** 199 | * @} 200 | */ 201 | 202 | /** 203 | * @} 204 | */ 205 | 206 | /** 207 | * @} 208 | */ 209 | 210 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 211 | -------------------------------------------------------------------------------- /Libraries/FWlib/inc/stm32f10x_exti.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f10x_exti.h 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 11-March-2011 7 | * @brief This file contains all the functions prototypes for the EXTI firmware 8 | * library. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 13 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 14 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 15 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 16 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 17 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 18 | * 19 | *

© COPYRIGHT 2011 STMicroelectronics

20 | ****************************************************************************** 21 | */ 22 | 23 | /* Define to prevent recursive inclusion -------------------------------------*/ 24 | #ifndef __STM32F10x_EXTI_H 25 | #define __STM32F10x_EXTI_H 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | /* Includes ------------------------------------------------------------------*/ 32 | #include "stm32f10x.h" 33 | 34 | /** @addtogroup STM32F10x_StdPeriph_Driver 35 | * @{ 36 | */ 37 | 38 | /** @addtogroup EXTI 39 | * @{ 40 | */ 41 | 42 | /** @defgroup EXTI_Exported_Types 43 | * @{ 44 | */ 45 | 46 | /** 47 | * @brief EXTI mode enumeration 48 | */ 49 | 50 | typedef enum 51 | { 52 | EXTI_Mode_Interrupt = 0x00, 53 | EXTI_Mode_Event = 0x04 54 | }EXTIMode_TypeDef; 55 | 56 | #define IS_EXTI_MODE(MODE) (((MODE) == EXTI_Mode_Interrupt) || ((MODE) == EXTI_Mode_Event)) 57 | 58 | /** 59 | * @brief EXTI Trigger enumeration 60 | */ 61 | 62 | typedef enum 63 | { 64 | EXTI_Trigger_Rising = 0x08, 65 | EXTI_Trigger_Falling = 0x0C, 66 | EXTI_Trigger_Rising_Falling = 0x10 67 | }EXTITrigger_TypeDef; 68 | 69 | #define IS_EXTI_TRIGGER(TRIGGER) (((TRIGGER) == EXTI_Trigger_Rising) || \ 70 | ((TRIGGER) == EXTI_Trigger_Falling) || \ 71 | ((TRIGGER) == EXTI_Trigger_Rising_Falling)) 72 | /** 73 | * @brief EXTI Init Structure definition 74 | */ 75 | 76 | typedef struct 77 | { 78 | uint32_t EXTI_Line; /*!< Specifies the EXTI lines to be enabled or disabled. 79 | This parameter can be any combination of @ref EXTI_Lines */ 80 | 81 | EXTIMode_TypeDef EXTI_Mode; /*!< Specifies the mode for the EXTI lines. 82 | This parameter can be a value of @ref EXTIMode_TypeDef */ 83 | 84 | EXTITrigger_TypeDef EXTI_Trigger; /*!< Specifies the trigger signal active edge for the EXTI lines. 85 | This parameter can be a value of @ref EXTIMode_TypeDef */ 86 | 87 | FunctionalState EXTI_LineCmd; /*!< Specifies the new state of the selected EXTI lines. 88 | This parameter can be set either to ENABLE or DISABLE */ 89 | }EXTI_InitTypeDef; 90 | 91 | /** 92 | * @} 93 | */ 94 | 95 | /** @defgroup EXTI_Exported_Constants 96 | * @{ 97 | */ 98 | 99 | /** @defgroup EXTI_Lines 100 | * @{ 101 | */ 102 | 103 | #define EXTI_Line0 ((uint32_t)0x00001) /*!< External interrupt line 0 */ 104 | #define EXTI_Line1 ((uint32_t)0x00002) /*!< External interrupt line 1 */ 105 | #define EXTI_Line2 ((uint32_t)0x00004) /*!< External interrupt line 2 */ 106 | #define EXTI_Line3 ((uint32_t)0x00008) /*!< External interrupt line 3 */ 107 | #define EXTI_Line4 ((uint32_t)0x00010) /*!< External interrupt line 4 */ 108 | #define EXTI_Line5 ((uint32_t)0x00020) /*!< External interrupt line 5 */ 109 | #define EXTI_Line6 ((uint32_t)0x00040) /*!< External interrupt line 6 */ 110 | #define EXTI_Line7 ((uint32_t)0x00080) /*!< External interrupt line 7 */ 111 | #define EXTI_Line8 ((uint32_t)0x00100) /*!< External interrupt line 8 */ 112 | #define EXTI_Line9 ((uint32_t)0x00200) /*!< External interrupt line 9 */ 113 | #define EXTI_Line10 ((uint32_t)0x00400) /*!< External interrupt line 10 */ 114 | #define EXTI_Line11 ((uint32_t)0x00800) /*!< External interrupt line 11 */ 115 | #define EXTI_Line12 ((uint32_t)0x01000) /*!< External interrupt line 12 */ 116 | #define EXTI_Line13 ((uint32_t)0x02000) /*!< External interrupt line 13 */ 117 | #define EXTI_Line14 ((uint32_t)0x04000) /*!< External interrupt line 14 */ 118 | #define EXTI_Line15 ((uint32_t)0x08000) /*!< External interrupt line 15 */ 119 | #define EXTI_Line16 ((uint32_t)0x10000) /*!< External interrupt line 16 Connected to the PVD Output */ 120 | #define EXTI_Line17 ((uint32_t)0x20000) /*!< External interrupt line 17 Connected to the RTC Alarm event */ 121 | #define EXTI_Line18 ((uint32_t)0x40000) /*!< External interrupt line 18 Connected to the USB Device/USB OTG FS 122 | Wakeup from suspend event */ 123 | #define EXTI_Line19 ((uint32_t)0x80000) /*!< External interrupt line 19 Connected to the Ethernet Wakeup event */ 124 | 125 | #define IS_EXTI_LINE(LINE) ((((LINE) & (uint32_t)0xFFF00000) == 0x00) && ((LINE) != (uint16_t)0x00)) 126 | #define IS_GET_EXTI_LINE(LINE) (((LINE) == EXTI_Line0) || ((LINE) == EXTI_Line1) || \ 127 | ((LINE) == EXTI_Line2) || ((LINE) == EXTI_Line3) || \ 128 | ((LINE) == EXTI_Line4) || ((LINE) == EXTI_Line5) || \ 129 | ((LINE) == EXTI_Line6) || ((LINE) == EXTI_Line7) || \ 130 | ((LINE) == EXTI_Line8) || ((LINE) == EXTI_Line9) || \ 131 | ((LINE) == EXTI_Line10) || ((LINE) == EXTI_Line11) || \ 132 | ((LINE) == EXTI_Line12) || ((LINE) == EXTI_Line13) || \ 133 | ((LINE) == EXTI_Line14) || ((LINE) == EXTI_Line15) || \ 134 | ((LINE) == EXTI_Line16) || ((LINE) == EXTI_Line17) || \ 135 | ((LINE) == EXTI_Line18) || ((LINE) == EXTI_Line19)) 136 | 137 | 138 | /** 139 | * @} 140 | */ 141 | 142 | /** 143 | * @} 144 | */ 145 | 146 | /** @defgroup EXTI_Exported_Macros 147 | * @{ 148 | */ 149 | 150 | /** 151 | * @} 152 | */ 153 | 154 | /** @defgroup EXTI_Exported_Functions 155 | * @{ 156 | */ 157 | 158 | void EXTI_DeInit(void); 159 | void EXTI_Init(EXTI_InitTypeDef* EXTI_InitStruct); 160 | void EXTI_StructInit(EXTI_InitTypeDef* EXTI_InitStruct); 161 | void EXTI_GenerateSWInterrupt(uint32_t EXTI_Line); 162 | FlagStatus EXTI_GetFlagStatus(uint32_t EXTI_Line); 163 | void EXTI_ClearFlag(uint32_t EXTI_Line); 164 | ITStatus EXTI_GetITStatus(uint32_t EXTI_Line); 165 | void EXTI_ClearITPendingBit(uint32_t EXTI_Line); 166 | 167 | #ifdef __cplusplus 168 | } 169 | #endif 170 | 171 | #endif /* __STM32F10x_EXTI_H */ 172 | /** 173 | * @} 174 | */ 175 | 176 | /** 177 | * @} 178 | */ 179 | 180 | /** 181 | * @} 182 | */ 183 | 184 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 185 | -------------------------------------------------------------------------------- /User/FATFS/00history.txt: -------------------------------------------------------------------------------- 1 | ---------------------------------------------------------------------------- 2 | Revision history of FatFs module 3 | ---------------------------------------------------------------------------- 4 | 5 | R0.00 (February 26, 2006) 6 | 7 | Prototype. 8 | 9 | 10 | 11 | R0.01 (April 29, 2006) 12 | 13 | First stable version. 14 | 15 | 16 | 17 | R0.02 (June 01, 2006) 18 | 19 | Added FAT12 support. 20 | Removed unbuffered mode. 21 | Fixed a problem on small (<32M) partition. 22 | 23 | 24 | 25 | R0.02a (June 10, 2006) 26 | 27 | Added a configuration option (_FS_MINIMUM). 28 | 29 | 30 | 31 | R0.03 (September 22, 2006) 32 | 33 | Added f_rename(). 34 | Changed option _FS_MINIMUM to _FS_MINIMIZE. 35 | 36 | 37 | 38 | R0.03a (December 11, 2006) 39 | 40 | Improved cluster scan algorithm to write files fast. 41 | Fixed f_mkdir() creates incorrect directory on FAT32. 42 | 43 | 44 | 45 | R0.04 (February 04, 2007) 46 | 47 | Added f_mkfs(). 48 | Supported multiple drive system. 49 | Changed some interfaces for multiple drive system. 50 | Changed f_mountdrv() to f_mount(). 51 | 52 | 53 | 54 | R0.04a (April 01, 2007) 55 | 56 | Supported multiple partitions on a physical drive. 57 | Added a capability of extending file size to f_lseek(). 58 | Added minimization level 3. 59 | Fixed an endian sensitive code in f_mkfs(). 60 | 61 | 62 | 63 | R0.04b (May 05, 2007) 64 | 65 | Added a configuration option _USE_NTFLAG. 66 | Added FSINFO support. 67 | Fixed DBCS name can result FR_INVALID_NAME. 68 | Fixed short seek (<= csize) collapses the file object. 69 | 70 | 71 | 72 | R0.05 (August 25, 2007) 73 | 74 | Changed arguments of f_read(), f_write() and f_mkfs(). 75 | Fixed f_mkfs() on FAT32 creates incorrect FSINFO. 76 | Fixed f_mkdir() on FAT32 creates incorrect directory. 77 | 78 | 79 | 80 | R0.05a (February 03, 2008) 81 | 82 | Added f_truncate() and f_utime(). 83 | Fixed off by one error at FAT sub-type determination. 84 | Fixed btr in f_read() can be mistruncated. 85 | Fixed cached sector is not flushed when create and close without write. 86 | 87 | 88 | 89 | R0.06 (April 01, 2008) 90 | 91 | Added fputc(), fputs(), fprintf() and fgets(). 92 | Improved performance of f_lseek() on moving to the same or following cluster. 93 | 94 | 95 | 96 | R0.07 (April 01, 2009) 97 | 98 | Merged Tiny-FatFs as a configuration option. (_FS_TINY) 99 | Added long file name feature. (_USE_LFN) 100 | Added multiple code page feature. (_CODE_PAGE) 101 | Added re-entrancy for multitask operation. (_FS_REENTRANT) 102 | Added auto cluster size selection to f_mkfs(). 103 | Added rewind option to f_readdir(). 104 | Changed result code of critical errors. 105 | Renamed string functions to avoid name collision. 106 | 107 | 108 | 109 | R0.07a (April 14, 2009) 110 | 111 | Septemberarated out OS dependent code on reentrant cfg. 112 | Added multiple sector size feature. 113 | 114 | 115 | 116 | R0.07c (June 21, 2009) 117 | 118 | Fixed f_unlink() can return FR_OK on error. 119 | Fixed wrong cache control in f_lseek(). 120 | Added relative path feature. 121 | Added f_chdir() and f_chdrive(). 122 | Added proper case conversion to extended character. 123 | 124 | 125 | 126 | R0.07e (November 03, 2009) 127 | 128 | Septemberarated out configuration options from ff.h to ffconf.h. 129 | Fixed f_unlink() fails to remove a sub-directory on _FS_RPATH. 130 | Fixed name matching error on the 13 character boundary. 131 | Added a configuration option, _LFN_UNICODE. 132 | Changed f_readdir() to return the SFN with always upper case on non-LFN cfg. 133 | 134 | 135 | 136 | R0.08 (May 15, 2010) 137 | 138 | Added a memory configuration option. (_USE_LFN = 3) 139 | Added file lock feature. (_FS_SHARE) 140 | Added fast seek feature. (_USE_FASTSEEK) 141 | Changed some types on the API, XCHAR->TCHAR. 142 | Changed .fname in the FILINFO structure on Unicode cfg. 143 | String functions support UTF-8 encoding files on Unicode cfg. 144 | 145 | 146 | 147 | R0.08a (August 16, 2010) 148 | 149 | Added f_getcwd(). (_FS_RPATH = 2) 150 | Added sector erase feature. (_USE_ERASE) 151 | Moved file lock semaphore table from fs object to the bss. 152 | Fixed f_mkfs() creates wrong FAT32 volume. 153 | 154 | 155 | 156 | R0.08b (January 15, 2011) 157 | 158 | Fast seek feature is also applied to f_read() and f_write(). 159 | f_lseek() reports required table size on creating CLMP. 160 | Extended format syntax of f_printf(). 161 | Ignores duplicated directory separators in given path name. 162 | 163 | 164 | 165 | R0.09 (September 06, 2011) 166 | 167 | f_mkfs() supports multiple partition to complete the multiple partition feature. 168 | Added f_fdisk(). 169 | 170 | 171 | 172 | R0.09a (August 27, 2012) 173 | 174 | Changed f_open() and f_opendir() reject null object pointer to avoid crash. 175 | Changed option name _FS_SHARE to _FS_LOCK. 176 | Fixed assertion failure due to OS/2 EA on FAT12/16 volume. 177 | 178 | 179 | 180 | R0.09b (January 24, 2013) 181 | 182 | Added f_setlabel() and f_getlabel(). 183 | 184 | 185 | 186 | R0.10 (October 02, 2013) 187 | 188 | Added selection of character encoding on the file. (_STRF_ENCODE) 189 | Added f_closedir(). 190 | Added forced full FAT scan for f_getfree(). (_FS_NOFSINFO) 191 | Added forced mount feature with changes of f_mount(). 192 | Improved behavior of volume auto detection. 193 | Improved write throughput of f_puts() and f_printf(). 194 | Changed argument of f_chdrive(), f_mkfs(), disk_read() and disk_write(). 195 | Fixed f_write() can be truncated when the file size is close to 4GB. 196 | Fixed f_open(), f_mkdir() and f_setlabel() can return incorrect error code. 197 | 198 | 199 | 200 | R0.10a (January 15, 2014) 201 | 202 | Added arbitrary strings as drive number in the path name. (_STR_VOLUME_ID) 203 | Added a configuration option of minimum sector size. (_MIN_SS) 204 | 2nd argument of f_rename() can have a drive number and it will be ignored. 205 | Fixed f_mount() with forced mount fails when drive number is >= 1. (appeared at R0.10) 206 | Fixed f_close() invalidates the file object without volume lock. 207 | Fixed f_closedir() returns but the volume lock is left acquired. (appeared at R0.10) 208 | Fixed creation of an entry with LFN fails on too many SFN collisions. (appeared at R0.07) 209 | 210 | 211 | 212 | R0.10b (May 19, 2014) 213 | 214 | Fixed a hard error in the disk I/O layer can collapse the directory entry. 215 | Fixed LFN entry is not deleted on delete/rename an object with lossy converted SFN. (appeared at R0.07) 216 | 217 | 218 | 219 | R0.10c (November 09, 2014) 220 | 221 | Added a configuration option for the platforms without RTC. (_FS_NORTC) 222 | Changed option name _USE_ERASE to _USE_TRIM. 223 | Fixed volume label created by Mac OS X cannot be retrieved with f_getlabel(). (appeared at R0.09b) 224 | Fixed a potential problem of FAT access that can appear on disk error. 225 | Fixed null pointer dereference on attempting to delete the root direcotry. (appeared at R0.08) 226 | 227 | 228 | 229 | R0.11 (February 09, 2015) 230 | 231 | Added f_findfirst(), f_findnext() and f_findclose(). (_USE_FIND) 232 | Fixed f_unlink() does not remove cluster chain of the file. (appeared at R0.10c) 233 | Fixed _FS_NORTC option does not work properly. (appeared at R0.10c) 234 | 235 | 236 | 237 | R0.11a (September 05, 2015) 238 | 239 | Fixed wrong media change can lead a deadlock at thread-safe configuration. 240 | Added code page 771, 860, 861, 863, 864, 865 and 869. (_CODE_PAGE) 241 | Removed some code pages actually not exist on the standard systems. (_CODE_PAGE) 242 | Fixed errors in the case conversion teble of code page 437 and 850 (ff.c). 243 | Fixed errors in the case conversion teble of Unicode (cc*.c). 244 | 245 | 246 | -------------------------------------------------------------------------------- /Libraries/FWlib/src/misc.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file misc.c 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 11-March-2011 7 | * @brief This file provides all the miscellaneous firmware functions (add-on 8 | * to CMSIS functions). 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 13 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 14 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 15 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 16 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 17 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 18 | * 19 | *

© COPYRIGHT 2011 STMicroelectronics

20 | ****************************************************************************** 21 | */ 22 | 23 | /* Includes ------------------------------------------------------------------*/ 24 | #include "misc.h" 25 | 26 | /** @addtogroup STM32F10x_StdPeriph_Driver 27 | * @{ 28 | */ 29 | 30 | /** @defgroup MISC 31 | * @brief MISC driver modules 32 | * @{ 33 | */ 34 | 35 | /** @defgroup MISC_Private_TypesDefinitions 36 | * @{ 37 | */ 38 | 39 | /** 40 | * @} 41 | */ 42 | 43 | /** @defgroup MISC_Private_Defines 44 | * @{ 45 | */ 46 | 47 | #define AIRCR_VECTKEY_MASK ((uint32_t)0x05FA0000) 48 | /** 49 | * @} 50 | */ 51 | 52 | /** @defgroup MISC_Private_Macros 53 | * @{ 54 | */ 55 | 56 | /** 57 | * @} 58 | */ 59 | 60 | /** @defgroup MISC_Private_Variables 61 | * @{ 62 | */ 63 | 64 | /** 65 | * @} 66 | */ 67 | 68 | /** @defgroup MISC_Private_FunctionPrototypes 69 | * @{ 70 | */ 71 | 72 | /** 73 | * @} 74 | */ 75 | 76 | /** @defgroup MISC_Private_Functions 77 | * @{ 78 | */ 79 | 80 | /** 81 | * @brief Configures the priority grouping: pre-emption priority and subpriority. 82 | * @param NVIC_PriorityGroup: specifies the priority grouping bits length. 83 | * This parameter can be one of the following values: 84 | * @arg NVIC_PriorityGroup_0: 0 bits for pre-emption priority 85 | * 4 bits for subpriority 86 | * @arg NVIC_PriorityGroup_1: 1 bits for pre-emption priority 87 | * 3 bits for subpriority 88 | * @arg NVIC_PriorityGroup_2: 2 bits for pre-emption priority 89 | * 2 bits for subpriority 90 | * @arg NVIC_PriorityGroup_3: 3 bits for pre-emption priority 91 | * 1 bits for subpriority 92 | * @arg NVIC_PriorityGroup_4: 4 bits for pre-emption priority 93 | * 0 bits for subpriority 94 | * @retval None 95 | */ 96 | void NVIC_PriorityGroupConfig(uint32_t NVIC_PriorityGroup) 97 | { 98 | /* Check the parameters */ 99 | assert_param(IS_NVIC_PRIORITY_GROUP(NVIC_PriorityGroup)); 100 | 101 | /* Set the PRIGROUP[10:8] bits according to NVIC_PriorityGroup value */ 102 | SCB->AIRCR = AIRCR_VECTKEY_MASK | NVIC_PriorityGroup; 103 | } 104 | 105 | /** 106 | * @brief Initializes the NVIC peripheral according to the specified 107 | * parameters in the NVIC_InitStruct. 108 | * @param NVIC_InitStruct: pointer to a NVIC_InitTypeDef structure that contains 109 | * the configuration information for the specified NVIC peripheral. 110 | * @retval None 111 | */ 112 | void NVIC_Init(NVIC_InitTypeDef* NVIC_InitStruct) 113 | { 114 | uint32_t tmppriority = 0x00, tmppre = 0x00, tmpsub = 0x0F; 115 | 116 | /* Check the parameters */ 117 | assert_param(IS_FUNCTIONAL_STATE(NVIC_InitStruct->NVIC_IRQChannelCmd)); 118 | assert_param(IS_NVIC_PREEMPTION_PRIORITY(NVIC_InitStruct->NVIC_IRQChannelPreemptionPriority)); 119 | assert_param(IS_NVIC_SUB_PRIORITY(NVIC_InitStruct->NVIC_IRQChannelSubPriority)); 120 | 121 | if (NVIC_InitStruct->NVIC_IRQChannelCmd != DISABLE) 122 | { 123 | /* Compute the Corresponding IRQ Priority --------------------------------*/ 124 | tmppriority = (0x700 - ((SCB->AIRCR) & (uint32_t)0x700))>> 0x08; 125 | tmppre = (0x4 - tmppriority); 126 | tmpsub = tmpsub >> tmppriority; 127 | 128 | tmppriority = (uint32_t)NVIC_InitStruct->NVIC_IRQChannelPreemptionPriority << tmppre; 129 | tmppriority |= NVIC_InitStruct->NVIC_IRQChannelSubPriority & tmpsub; 130 | tmppriority = tmppriority << 0x04; 131 | 132 | NVIC->IP[NVIC_InitStruct->NVIC_IRQChannel] = tmppriority; 133 | 134 | /* Enable the Selected IRQ Channels --------------------------------------*/ 135 | NVIC->ISER[NVIC_InitStruct->NVIC_IRQChannel >> 0x05] = 136 | (uint32_t)0x01 << (NVIC_InitStruct->NVIC_IRQChannel & (uint8_t)0x1F); 137 | } 138 | else 139 | { 140 | /* Disable the Selected IRQ Channels -------------------------------------*/ 141 | NVIC->ICER[NVIC_InitStruct->NVIC_IRQChannel >> 0x05] = 142 | (uint32_t)0x01 << (NVIC_InitStruct->NVIC_IRQChannel & (uint8_t)0x1F); 143 | } 144 | } 145 | 146 | /** 147 | * @brief Sets the vector table location and Offset. 148 | * @param NVIC_VectTab: specifies if the vector table is in RAM or FLASH memory. 149 | * This parameter can be one of the following values: 150 | * @arg NVIC_VectTab_RAM 151 | * @arg NVIC_VectTab_FLASH 152 | * @param Offset: Vector Table base offset field. This value must be a multiple 153 | * of 0x200. 154 | * @retval None 155 | */ 156 | void NVIC_SetVectorTable(uint32_t NVIC_VectTab, uint32_t Offset) 157 | { 158 | /* Check the parameters */ 159 | assert_param(IS_NVIC_VECTTAB(NVIC_VectTab)); 160 | assert_param(IS_NVIC_OFFSET(Offset)); 161 | 162 | SCB->VTOR = NVIC_VectTab | (Offset & (uint32_t)0x1FFFFF80); 163 | } 164 | 165 | /** 166 | * @brief Selects the condition for the system to enter low power mode. 167 | * @param LowPowerMode: Specifies the new mode for the system to enter low power mode. 168 | * This parameter can be one of the following values: 169 | * @arg NVIC_LP_SEVONPEND 170 | * @arg NVIC_LP_SLEEPDEEP 171 | * @arg NVIC_LP_SLEEPONEXIT 172 | * @param NewState: new state of LP condition. This parameter can be: ENABLE or DISABLE. 173 | * @retval None 174 | */ 175 | void NVIC_SystemLPConfig(uint8_t LowPowerMode, FunctionalState NewState) 176 | { 177 | /* Check the parameters */ 178 | assert_param(IS_NVIC_LP(LowPowerMode)); 179 | assert_param(IS_FUNCTIONAL_STATE(NewState)); 180 | 181 | if (NewState != DISABLE) 182 | { 183 | SCB->SCR |= LowPowerMode; 184 | } 185 | else 186 | { 187 | SCB->SCR &= (uint32_t)(~(uint32_t)LowPowerMode); 188 | } 189 | } 190 | 191 | /** 192 | * @brief Configures the SysTick clock source. 193 | * @param SysTick_CLKSource: specifies the SysTick clock source. 194 | * This parameter can be one of the following values: 195 | * @arg SysTick_CLKSource_HCLK_Div8: AHB clock divided by 8 selected as SysTick clock source. 196 | * @arg SysTick_CLKSource_HCLK: AHB clock selected as SysTick clock source. 197 | * @retval None 198 | */ 199 | void SysTick_CLKSourceConfig(uint32_t SysTick_CLKSource) 200 | { 201 | /* Check the parameters */ 202 | assert_param(IS_SYSTICK_CLK_SOURCE(SysTick_CLKSource)); 203 | if (SysTick_CLKSource == SysTick_CLKSource_HCLK) 204 | { 205 | SysTick->CTRL |= SysTick_CLKSource_HCLK; 206 | } 207 | else 208 | { 209 | SysTick->CTRL &= SysTick_CLKSource_HCLK_Div8; 210 | } 211 | } 212 | 213 | /** 214 | * @} 215 | */ 216 | 217 | /** 218 | * @} 219 | */ 220 | 221 | /** 222 | * @} 223 | */ 224 | 225 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 226 | -------------------------------------------------------------------------------- /Libraries/FWlib/src/stm32f10x_exti.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f10x_exti.c 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 11-March-2011 7 | * @brief This file provides all the EXTI firmware functions. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2011 STMicroelectronics

19 | ****************************************************************************** 20 | */ 21 | 22 | /* Includes ------------------------------------------------------------------*/ 23 | #include "stm32f10x_exti.h" 24 | 25 | /** @addtogroup STM32F10x_StdPeriph_Driver 26 | * @{ 27 | */ 28 | 29 | /** @defgroup EXTI 30 | * @brief EXTI driver modules 31 | * @{ 32 | */ 33 | 34 | /** @defgroup EXTI_Private_TypesDefinitions 35 | * @{ 36 | */ 37 | 38 | /** 39 | * @} 40 | */ 41 | 42 | /** @defgroup EXTI_Private_Defines 43 | * @{ 44 | */ 45 | 46 | #define EXTI_LINENONE ((uint32_t)0x00000) /* No interrupt selected */ 47 | 48 | /** 49 | * @} 50 | */ 51 | 52 | /** @defgroup EXTI_Private_Macros 53 | * @{ 54 | */ 55 | 56 | /** 57 | * @} 58 | */ 59 | 60 | /** @defgroup EXTI_Private_Variables 61 | * @{ 62 | */ 63 | 64 | /** 65 | * @} 66 | */ 67 | 68 | /** @defgroup EXTI_Private_FunctionPrototypes 69 | * @{ 70 | */ 71 | 72 | /** 73 | * @} 74 | */ 75 | 76 | /** @defgroup EXTI_Private_Functions 77 | * @{ 78 | */ 79 | 80 | /** 81 | * @brief Deinitializes the EXTI peripheral registers to their default reset values. 82 | * @param None 83 | * @retval None 84 | */ 85 | void EXTI_DeInit(void) 86 | { 87 | EXTI->IMR = 0x00000000; 88 | EXTI->EMR = 0x00000000; 89 | EXTI->RTSR = 0x00000000; 90 | EXTI->FTSR = 0x00000000; 91 | EXTI->PR = 0x000FFFFF; 92 | } 93 | 94 | /** 95 | * @brief Initializes the EXTI peripheral according to the specified 96 | * parameters in the EXTI_InitStruct. 97 | * @param EXTI_InitStruct: pointer to a EXTI_InitTypeDef structure 98 | * that contains the configuration information for the EXTI peripheral. 99 | * @retval None 100 | */ 101 | void EXTI_Init(EXTI_InitTypeDef* EXTI_InitStruct) 102 | { 103 | uint32_t tmp = 0; 104 | 105 | /* Check the parameters */ 106 | assert_param(IS_EXTI_MODE(EXTI_InitStruct->EXTI_Mode)); 107 | assert_param(IS_EXTI_TRIGGER(EXTI_InitStruct->EXTI_Trigger)); 108 | assert_param(IS_EXTI_LINE(EXTI_InitStruct->EXTI_Line)); 109 | assert_param(IS_FUNCTIONAL_STATE(EXTI_InitStruct->EXTI_LineCmd)); 110 | 111 | tmp = (uint32_t)EXTI_BASE; 112 | 113 | if (EXTI_InitStruct->EXTI_LineCmd != DISABLE) 114 | { 115 | /* Clear EXTI line configuration */ 116 | EXTI->IMR &= ~EXTI_InitStruct->EXTI_Line; 117 | EXTI->EMR &= ~EXTI_InitStruct->EXTI_Line; 118 | 119 | tmp += EXTI_InitStruct->EXTI_Mode; 120 | 121 | *(__IO uint32_t *) tmp |= EXTI_InitStruct->EXTI_Line; 122 | 123 | /* Clear Rising Falling edge configuration */ 124 | EXTI->RTSR &= ~EXTI_InitStruct->EXTI_Line; 125 | EXTI->FTSR &= ~EXTI_InitStruct->EXTI_Line; 126 | 127 | /* Select the trigger for the selected external interrupts */ 128 | if (EXTI_InitStruct->EXTI_Trigger == EXTI_Trigger_Rising_Falling) 129 | { 130 | /* Rising Falling edge */ 131 | EXTI->RTSR |= EXTI_InitStruct->EXTI_Line; 132 | EXTI->FTSR |= EXTI_InitStruct->EXTI_Line; 133 | } 134 | else 135 | { 136 | tmp = (uint32_t)EXTI_BASE; 137 | tmp += EXTI_InitStruct->EXTI_Trigger; 138 | 139 | *(__IO uint32_t *) tmp |= EXTI_InitStruct->EXTI_Line; 140 | } 141 | } 142 | else 143 | { 144 | tmp += EXTI_InitStruct->EXTI_Mode; 145 | 146 | /* Disable the selected external lines */ 147 | *(__IO uint32_t *) tmp &= ~EXTI_InitStruct->EXTI_Line; 148 | } 149 | } 150 | 151 | /** 152 | * @brief Fills each EXTI_InitStruct member with its reset value. 153 | * @param EXTI_InitStruct: pointer to a EXTI_InitTypeDef structure which will 154 | * be initialized. 155 | * @retval None 156 | */ 157 | void EXTI_StructInit(EXTI_InitTypeDef* EXTI_InitStruct) 158 | { 159 | EXTI_InitStruct->EXTI_Line = EXTI_LINENONE; 160 | EXTI_InitStruct->EXTI_Mode = EXTI_Mode_Interrupt; 161 | EXTI_InitStruct->EXTI_Trigger = EXTI_Trigger_Falling; 162 | EXTI_InitStruct->EXTI_LineCmd = DISABLE; 163 | } 164 | 165 | /** 166 | * @brief Generates a Software interrupt. 167 | * @param EXTI_Line: specifies the EXTI lines to be enabled or disabled. 168 | * This parameter can be any combination of EXTI_Linex where x can be (0..19). 169 | * @retval None 170 | */ 171 | void EXTI_GenerateSWInterrupt(uint32_t EXTI_Line) 172 | { 173 | /* Check the parameters */ 174 | assert_param(IS_EXTI_LINE(EXTI_Line)); 175 | 176 | EXTI->SWIER |= EXTI_Line; 177 | } 178 | 179 | /** 180 | * @brief Checks whether the specified EXTI line flag is set or not. 181 | * @param EXTI_Line: specifies the EXTI line flag to check. 182 | * This parameter can be: 183 | * @arg EXTI_Linex: External interrupt line x where x(0..19) 184 | * @retval The new state of EXTI_Line (SET or RESET). 185 | */ 186 | FlagStatus EXTI_GetFlagStatus(uint32_t EXTI_Line) 187 | { 188 | FlagStatus bitstatus = RESET; 189 | /* Check the parameters */ 190 | assert_param(IS_GET_EXTI_LINE(EXTI_Line)); 191 | 192 | if ((EXTI->PR & EXTI_Line) != (uint32_t)RESET) 193 | { 194 | bitstatus = SET; 195 | } 196 | else 197 | { 198 | bitstatus = RESET; 199 | } 200 | return bitstatus; 201 | } 202 | 203 | /** 204 | * @brief Clears the EXTI's line pending flags. 205 | * @param EXTI_Line: specifies the EXTI lines flags to clear. 206 | * This parameter can be any combination of EXTI_Linex where x can be (0..19). 207 | * @retval None 208 | */ 209 | void EXTI_ClearFlag(uint32_t EXTI_Line) 210 | { 211 | /* Check the parameters */ 212 | assert_param(IS_EXTI_LINE(EXTI_Line)); 213 | 214 | EXTI->PR = EXTI_Line; 215 | } 216 | 217 | /** 218 | * @brief Checks whether the specified EXTI line is asserted or not. 219 | * @param EXTI_Line: specifies the EXTI line to check. 220 | * This parameter can be: 221 | * @arg EXTI_Linex: External interrupt line x where x(0..19) 222 | * @retval The new state of EXTI_Line (SET or RESET). 223 | */ 224 | ITStatus EXTI_GetITStatus(uint32_t EXTI_Line) 225 | { 226 | ITStatus bitstatus = RESET; 227 | uint32_t enablestatus = 0; 228 | /* Check the parameters */ 229 | assert_param(IS_GET_EXTI_LINE(EXTI_Line)); 230 | 231 | enablestatus = EXTI->IMR & EXTI_Line; 232 | if (((EXTI->PR & EXTI_Line) != (uint32_t)RESET) && (enablestatus != (uint32_t)RESET)) 233 | { 234 | bitstatus = SET; 235 | } 236 | else 237 | { 238 | bitstatus = RESET; 239 | } 240 | return bitstatus; 241 | } 242 | 243 | /** 244 | * @brief Clears the EXTI's line pending bits. 245 | * @param EXTI_Line: specifies the EXTI lines to clear. 246 | * This parameter can be any combination of EXTI_Linex where x can be (0..19). 247 | * @retval None 248 | */ 249 | void EXTI_ClearITPendingBit(uint32_t EXTI_Line) 250 | { 251 | /* Check the parameters */ 252 | assert_param(IS_EXTI_LINE(EXTI_Line)); 253 | 254 | EXTI->PR = EXTI_Line; 255 | } 256 | 257 | /** 258 | * @} 259 | */ 260 | 261 | /** 262 | * @} 263 | */ 264 | 265 | /** 266 | * @} 267 | */ 268 | 269 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 270 | -------------------------------------------------------------------------------- /User/nmea_decode/src/generate.c: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * NMEA library 4 | * URL: http://nmea.sourceforge.net 5 | * Author: Tim (xtimor@gmail.com) 6 | * Licence: http://www.gnu.org/licenses/lgpl.html 7 | * $Id: generate.c 17 2008-03-11 11:56:11Z xtimor $ 8 | * 9 | */ 10 | 11 | #include "nmea/tok.h" 12 | #include "nmea/sentence.h" 13 | #include "nmea/generate.h" 14 | #include "nmea/units.h" 15 | 16 | #include 17 | #include 18 | #include 19 | 20 | int nmea_gen_GPGGA(char *buff, int buff_sz, nmeaGPGGA *pack) 21 | { 22 | return nmea_printf(buff, buff_sz, 23 | "$GPGGA,%02d%02d%02d.%02d,%07.4f,%C,%07.4f,%C,%1d,%02d,%03.1f,%03.1f,%C,%03.1f,%C,%03.1f,%04d", 24 | pack->utc.hour, pack->utc.min, pack->utc.sec, pack->utc.hsec, 25 | pack->lat, pack->ns, pack->lon, pack->ew, 26 | pack->sig, pack->satinuse, pack->HDOP, pack->elv, pack->elv_units, 27 | pack->diff, pack->diff_units, pack->dgps_age, pack->dgps_sid); 28 | } 29 | 30 | int nmea_gen_GPGSA(char *buff, int buff_sz, nmeaGPGSA *pack) 31 | { 32 | return nmea_printf(buff, buff_sz, 33 | "$GPGSA,%C,%1d,%02d,%02d,%02d,%02d,%02d,%02d,%02d,%02d,%02d,%02d,%02d,%02d,%03.1f,%03.1f,%03.1f", 34 | pack->fix_mode, pack->fix_type, 35 | pack->sat_prn[0], pack->sat_prn[1], pack->sat_prn[2], pack->sat_prn[3], pack->sat_prn[4], pack->sat_prn[5], 36 | pack->sat_prn[6], pack->sat_prn[7], pack->sat_prn[8], pack->sat_prn[9], pack->sat_prn[10], pack->sat_prn[11], 37 | pack->PDOP, pack->HDOP, pack->VDOP); 38 | } 39 | 40 | int nmea_gen_GPGSV(char *buff, int buff_sz, nmeaGPGSV *pack) 41 | { 42 | return nmea_printf(buff, buff_sz, 43 | "$GPGSV,%1d,%1d,%02d," 44 | "%02d,%02d,%03d,%02d," 45 | "%02d,%02d,%03d,%02d," 46 | "%02d,%02d,%03d,%02d," 47 | "%02d,%02d,%03d,%02d", 48 | pack->pack_count, pack->pack_index + 1, pack->sat_count, 49 | pack->sat_data[0].id, pack->sat_data[0].elv, pack->sat_data[0].azimuth, pack->sat_data[0].sig, 50 | pack->sat_data[1].id, pack->sat_data[1].elv, pack->sat_data[1].azimuth, pack->sat_data[1].sig, 51 | pack->sat_data[2].id, pack->sat_data[2].elv, pack->sat_data[2].azimuth, pack->sat_data[2].sig, 52 | pack->sat_data[3].id, pack->sat_data[3].elv, pack->sat_data[3].azimuth, pack->sat_data[3].sig); 53 | } 54 | 55 | int nmea_gen_GPRMC(char *buff, int buff_sz, nmeaGPRMC *pack) 56 | { 57 | return nmea_printf(buff, buff_sz, 58 | "$GPRMC,%02d%02d%02d.%02d,%C,%07.4f,%C,%07.4f,%C,%03.1f,%03.1f,%02d%02d%02d,%03.1f,%C,%C", 59 | pack->utc.hour, pack->utc.min, pack->utc.sec, pack->utc.hsec, 60 | pack->status, pack->lat, pack->ns, pack->lon, pack->ew, 61 | pack->speed, pack->direction, 62 | pack->utc.day, pack->utc.mon + 1, pack->utc.year - 100, 63 | pack->declination, pack->declin_ew, pack->mode); 64 | } 65 | 66 | int nmea_gen_GPVTG(char *buff, int buff_sz, nmeaGPVTG *pack) 67 | { 68 | return nmea_printf(buff, buff_sz, 69 | "$GPVTG,%.1f,%C,%.1f,%C,%.1f,%C,%.1f,%C", 70 | pack->dir, pack->dir_t, 71 | pack->dec, pack->dec_m, 72 | pack->spn, pack->spn_n, 73 | pack->spk, pack->spk_k); 74 | } 75 | 76 | void nmea_info2GPGGA(const nmeaINFO *info, nmeaGPGGA *pack) 77 | { 78 | nmea_zero_GPGGA(pack); 79 | 80 | pack->utc = info->utc; 81 | pack->lat = fabs(info->lat); 82 | pack->ns = ((info->lat > 0)?'N':'S'); 83 | pack->lon = fabs(info->lon); 84 | pack->ew = ((info->lon > 0)?'E':'W'); 85 | pack->sig = info->sig; 86 | pack->satinuse = info->satinfo.inuse; 87 | pack->HDOP = info->HDOP; 88 | pack->elv = info->elv; 89 | } 90 | 91 | void nmea_info2GPGSA(const nmeaINFO *info, nmeaGPGSA *pack) 92 | { 93 | int it; 94 | 95 | nmea_zero_GPGSA(pack); 96 | 97 | pack->fix_type = info->fix; 98 | pack->PDOP = info->PDOP; 99 | pack->HDOP = info->HDOP; 100 | pack->VDOP = info->VDOP; 101 | 102 | for(it = 0; it < NMEA_MAXSAT; ++it) 103 | { 104 | pack->sat_prn[it] = 105 | ((info->satinfo.sat[it].in_use)?info->satinfo.sat[it].id:0); 106 | } 107 | } 108 | 109 | int nmea_gsv_npack(int sat_count) 110 | { 111 | int pack_count = (int)ceil(((double)sat_count) / NMEA_SATINPACK); 112 | 113 | if(0 == pack_count) 114 | pack_count = 1; 115 | 116 | return pack_count; 117 | } 118 | 119 | void nmea_info2GPGSV(const nmeaINFO *info, nmeaGPGSV *pack, int pack_idx) 120 | { 121 | int sit, pit; 122 | 123 | nmea_zero_GPGSV(pack); 124 | 125 | pack->sat_count = (info->satinfo.inview <= NMEA_MAXSAT)?info->satinfo.inview:NMEA_MAXSAT; 126 | pack->pack_count = nmea_gsv_npack(pack->sat_count); 127 | 128 | if(pack->pack_count == 0) 129 | pack->pack_count = 1; 130 | 131 | if(pack_idx >= pack->pack_count) 132 | pack->pack_index = pack_idx % pack->pack_count; 133 | else 134 | pack->pack_index = pack_idx; 135 | 136 | for(pit = 0, sit = pack->pack_index * NMEA_SATINPACK; pit < NMEA_SATINPACK; ++pit, ++sit) 137 | pack->sat_data[pit] = info->satinfo.sat[sit]; 138 | } 139 | 140 | void nmea_info2GPRMC(const nmeaINFO *info, nmeaGPRMC *pack) 141 | { 142 | nmea_zero_GPRMC(pack); 143 | 144 | pack->utc = info->utc; 145 | pack->status = ((info->sig > 0)?'A':'V'); 146 | pack->lat = fabs(info->lat); 147 | pack->ns = ((info->lat > 0)?'N':'S'); 148 | pack->lon = fabs(info->lon); 149 | pack->ew = ((info->lon > 0)?'E':'W'); 150 | pack->speed = info->speed / NMEA_TUD_KNOTS; 151 | pack->direction = info->direction; 152 | pack->declination = info->declination; 153 | pack->declin_ew = 'E'; 154 | pack->mode = ((info->sig > 0)?'A':'N'); 155 | } 156 | 157 | void nmea_info2GPVTG(const nmeaINFO *info, nmeaGPVTG *pack) 158 | { 159 | nmea_zero_GPVTG(pack); 160 | 161 | pack->dir = info->direction; 162 | pack->dec = info->declination; 163 | pack->spn = info->speed / NMEA_TUD_KNOTS; 164 | pack->spk = info->speed; 165 | } 166 | 167 | int nmea_generate( 168 | char *buff, int buff_sz, 169 | const nmeaINFO *info, 170 | int generate_mask 171 | ) 172 | { 173 | int gen_count = 0, gsv_it, gsv_count; 174 | int pack_mask = generate_mask; 175 | 176 | nmeaGPGGA gga; 177 | nmeaGPGSA gsa; 178 | nmeaGPGSV gsv; 179 | nmeaGPRMC rmc; 180 | nmeaGPVTG vtg; 181 | 182 | if(!buff) 183 | return 0; 184 | 185 | while(pack_mask) 186 | { 187 | if(pack_mask & GPGGA) 188 | { 189 | nmea_info2GPGGA(info, &gga); 190 | gen_count += nmea_gen_GPGGA(buff + gen_count, buff_sz - gen_count, &gga); 191 | pack_mask &= ~GPGGA; 192 | } 193 | else if(pack_mask & GPGSA) 194 | { 195 | nmea_info2GPGSA(info, &gsa); 196 | gen_count += nmea_gen_GPGSA(buff + gen_count, buff_sz - gen_count, &gsa); 197 | pack_mask &= ~GPGSA; 198 | } 199 | else if(pack_mask & GPGSV) 200 | { 201 | gsv_count = nmea_gsv_npack(info->satinfo.inview); 202 | for(gsv_it = 0; gsv_it < gsv_count && buff_sz - gen_count > 0; ++gsv_it) 203 | { 204 | nmea_info2GPGSV(info, &gsv, gsv_it); 205 | gen_count += nmea_gen_GPGSV(buff + gen_count, buff_sz - gen_count, &gsv); 206 | } 207 | pack_mask &= ~GPGSV; 208 | } 209 | else if(pack_mask & GPRMC) 210 | { 211 | nmea_info2GPRMC(info, &rmc); 212 | gen_count += nmea_gen_GPRMC(buff + gen_count, buff_sz - gen_count, &rmc); 213 | pack_mask &= ~GPRMC; 214 | } 215 | else if(pack_mask & GPVTG) 216 | { 217 | nmea_info2GPVTG(info, &vtg); 218 | gen_count += nmea_gen_GPVTG(buff + gen_count, buff_sz - gen_count, &vtg); 219 | pack_mask &= ~GPVTG; 220 | } 221 | else 222 | break; 223 | 224 | if(buff_sz - gen_count <= 0) 225 | break; 226 | } 227 | 228 | return gen_count; 229 | } 230 | -------------------------------------------------------------------------------- /Libraries/FWlib/inc/stm32f10x_bkp.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f10x_bkp.h 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 11-March-2011 7 | * @brief This file contains all the functions prototypes for the BKP firmware 8 | * library. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 13 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 14 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 15 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 16 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 17 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 18 | * 19 | *

© COPYRIGHT 2011 STMicroelectronics

20 | ****************************************************************************** 21 | */ 22 | 23 | /* Define to prevent recursive inclusion -------------------------------------*/ 24 | #ifndef __STM32F10x_BKP_H 25 | #define __STM32F10x_BKP_H 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | /* Includes ------------------------------------------------------------------*/ 32 | #include "stm32f10x.h" 33 | 34 | /** @addtogroup STM32F10x_StdPeriph_Driver 35 | * @{ 36 | */ 37 | 38 | /** @addtogroup BKP 39 | * @{ 40 | */ 41 | 42 | /** @defgroup BKP_Exported_Types 43 | * @{ 44 | */ 45 | 46 | /** 47 | * @} 48 | */ 49 | 50 | /** @defgroup BKP_Exported_Constants 51 | * @{ 52 | */ 53 | 54 | /** @defgroup Tamper_Pin_active_level 55 | * @{ 56 | */ 57 | 58 | #define BKP_TamperPinLevel_High ((uint16_t)0x0000) 59 | #define BKP_TamperPinLevel_Low ((uint16_t)0x0001) 60 | #define IS_BKP_TAMPER_PIN_LEVEL(LEVEL) (((LEVEL) == BKP_TamperPinLevel_High) || \ 61 | ((LEVEL) == BKP_TamperPinLevel_Low)) 62 | /** 63 | * @} 64 | */ 65 | 66 | /** @defgroup RTC_output_source_to_output_on_the_Tamper_pin 67 | * @{ 68 | */ 69 | 70 | #define BKP_RTCOutputSource_None ((uint16_t)0x0000) 71 | #define BKP_RTCOutputSource_CalibClock ((uint16_t)0x0080) 72 | #define BKP_RTCOutputSource_Alarm ((uint16_t)0x0100) 73 | #define BKP_RTCOutputSource_Second ((uint16_t)0x0300) 74 | #define IS_BKP_RTC_OUTPUT_SOURCE(SOURCE) (((SOURCE) == BKP_RTCOutputSource_None) || \ 75 | ((SOURCE) == BKP_RTCOutputSource_CalibClock) || \ 76 | ((SOURCE) == BKP_RTCOutputSource_Alarm) || \ 77 | ((SOURCE) == BKP_RTCOutputSource_Second)) 78 | /** 79 | * @} 80 | */ 81 | 82 | /** @defgroup Data_Backup_Register 83 | * @{ 84 | */ 85 | 86 | #define BKP_DR1 ((uint16_t)0x0004) 87 | #define BKP_DR2 ((uint16_t)0x0008) 88 | #define BKP_DR3 ((uint16_t)0x000C) 89 | #define BKP_DR4 ((uint16_t)0x0010) 90 | #define BKP_DR5 ((uint16_t)0x0014) 91 | #define BKP_DR6 ((uint16_t)0x0018) 92 | #define BKP_DR7 ((uint16_t)0x001C) 93 | #define BKP_DR8 ((uint16_t)0x0020) 94 | #define BKP_DR9 ((uint16_t)0x0024) 95 | #define BKP_DR10 ((uint16_t)0x0028) 96 | #define BKP_DR11 ((uint16_t)0x0040) 97 | #define BKP_DR12 ((uint16_t)0x0044) 98 | #define BKP_DR13 ((uint16_t)0x0048) 99 | #define BKP_DR14 ((uint16_t)0x004C) 100 | #define BKP_DR15 ((uint16_t)0x0050) 101 | #define BKP_DR16 ((uint16_t)0x0054) 102 | #define BKP_DR17 ((uint16_t)0x0058) 103 | #define BKP_DR18 ((uint16_t)0x005C) 104 | #define BKP_DR19 ((uint16_t)0x0060) 105 | #define BKP_DR20 ((uint16_t)0x0064) 106 | #define BKP_DR21 ((uint16_t)0x0068) 107 | #define BKP_DR22 ((uint16_t)0x006C) 108 | #define BKP_DR23 ((uint16_t)0x0070) 109 | #define BKP_DR24 ((uint16_t)0x0074) 110 | #define BKP_DR25 ((uint16_t)0x0078) 111 | #define BKP_DR26 ((uint16_t)0x007C) 112 | #define BKP_DR27 ((uint16_t)0x0080) 113 | #define BKP_DR28 ((uint16_t)0x0084) 114 | #define BKP_DR29 ((uint16_t)0x0088) 115 | #define BKP_DR30 ((uint16_t)0x008C) 116 | #define BKP_DR31 ((uint16_t)0x0090) 117 | #define BKP_DR32 ((uint16_t)0x0094) 118 | #define BKP_DR33 ((uint16_t)0x0098) 119 | #define BKP_DR34 ((uint16_t)0x009C) 120 | #define BKP_DR35 ((uint16_t)0x00A0) 121 | #define BKP_DR36 ((uint16_t)0x00A4) 122 | #define BKP_DR37 ((uint16_t)0x00A8) 123 | #define BKP_DR38 ((uint16_t)0x00AC) 124 | #define BKP_DR39 ((uint16_t)0x00B0) 125 | #define BKP_DR40 ((uint16_t)0x00B4) 126 | #define BKP_DR41 ((uint16_t)0x00B8) 127 | #define BKP_DR42 ((uint16_t)0x00BC) 128 | 129 | #define IS_BKP_DR(DR) (((DR) == BKP_DR1) || ((DR) == BKP_DR2) || ((DR) == BKP_DR3) || \ 130 | ((DR) == BKP_DR4) || ((DR) == BKP_DR5) || ((DR) == BKP_DR6) || \ 131 | ((DR) == BKP_DR7) || ((DR) == BKP_DR8) || ((DR) == BKP_DR9) || \ 132 | ((DR) == BKP_DR10) || ((DR) == BKP_DR11) || ((DR) == BKP_DR12) || \ 133 | ((DR) == BKP_DR13) || ((DR) == BKP_DR14) || ((DR) == BKP_DR15) || \ 134 | ((DR) == BKP_DR16) || ((DR) == BKP_DR17) || ((DR) == BKP_DR18) || \ 135 | ((DR) == BKP_DR19) || ((DR) == BKP_DR20) || ((DR) == BKP_DR21) || \ 136 | ((DR) == BKP_DR22) || ((DR) == BKP_DR23) || ((DR) == BKP_DR24) || \ 137 | ((DR) == BKP_DR25) || ((DR) == BKP_DR26) || ((DR) == BKP_DR27) || \ 138 | ((DR) == BKP_DR28) || ((DR) == BKP_DR29) || ((DR) == BKP_DR30) || \ 139 | ((DR) == BKP_DR31) || ((DR) == BKP_DR32) || ((DR) == BKP_DR33) || \ 140 | ((DR) == BKP_DR34) || ((DR) == BKP_DR35) || ((DR) == BKP_DR36) || \ 141 | ((DR) == BKP_DR37) || ((DR) == BKP_DR38) || ((DR) == BKP_DR39) || \ 142 | ((DR) == BKP_DR40) || ((DR) == BKP_DR41) || ((DR) == BKP_DR42)) 143 | 144 | #define IS_BKP_CALIBRATION_VALUE(VALUE) ((VALUE) <= 0x7F) 145 | /** 146 | * @} 147 | */ 148 | 149 | /** 150 | * @} 151 | */ 152 | 153 | /** @defgroup BKP_Exported_Macros 154 | * @{ 155 | */ 156 | 157 | /** 158 | * @} 159 | */ 160 | 161 | /** @defgroup BKP_Exported_Functions 162 | * @{ 163 | */ 164 | 165 | void BKP_DeInit(void); 166 | void BKP_TamperPinLevelConfig(uint16_t BKP_TamperPinLevel); 167 | void BKP_TamperPinCmd(FunctionalState NewState); 168 | void BKP_ITConfig(FunctionalState NewState); 169 | void BKP_RTCOutputConfig(uint16_t BKP_RTCOutputSource); 170 | void BKP_SetRTCCalibrationValue(uint8_t CalibrationValue); 171 | void BKP_WriteBackupRegister(uint16_t BKP_DR, uint16_t Data); 172 | uint16_t BKP_ReadBackupRegister(uint16_t BKP_DR); 173 | FlagStatus BKP_GetFlagStatus(void); 174 | void BKP_ClearFlag(void); 175 | ITStatus BKP_GetITStatus(void); 176 | void BKP_ClearITPendingBit(void); 177 | 178 | #ifdef __cplusplus 179 | } 180 | #endif 181 | 182 | #endif /* __STM32F10x_BKP_H */ 183 | /** 184 | * @} 185 | */ 186 | 187 | /** 188 | * @} 189 | */ 190 | 191 | /** 192 | * @} 193 | */ 194 | 195 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 196 | -------------------------------------------------------------------------------- /User/jt808/include/protocol_parameter.h: -------------------------------------------------------------------------------- 1 | #ifndef JT808_PROTOCOL_PARAMETER_H_ 2 | #define JT808_PROTOCOL_PARAMETER_H_ 3 | 4 | //#include 5 | //#include 6 | //#include 7 | 8 | #include "location_report.h" 9 | #include "terminal_parameter.h" 10 | #include "terminal_control.h" 11 | 12 | // #define PACKAGER_NUM 9 13 | // #define PARSER_NUM 9 14 | 15 | // 已支持的协议命令. 16 | enum SupportedCommands 17 | { 18 | kTerminalGeneralResponse = 0x0001, // 终端通用应答. 19 | kPlatformGeneralResponse = 0x8001, // 平台通用应答. 20 | kTerminalHeartBeat = 0x0002, // 终端心跳. 21 | kFillPacketRequest = 0x8003, // 补传分包请求. 22 | kTerminalRegister = 0x0100, // 终端注册. 23 | kTerminalRegisterResponse = 0x8100, // 终端注册应答. 24 | kTerminalLogOut = 0x0003, // 终端注销. 25 | kTerminalAuthentication = 0x0102, // 终端鉴权. 26 | kSetTerminalParameters = 0x8103, // 设置终端参数. 27 | kGetTerminalParameters = 0x8104, // 查询终端参数. 28 | kGetSpecificTerminalParameters = 0x8106, // 查询指定终端参数. 29 | kGetTerminalParametersResponse = 0x0104, // 查询终端参数应答. 30 | kTerminalControl = 0x8105, //终端控制 31 | kTerminalUpgrade = 0x8108, // 下发终端升级包. 32 | kTerminalUpgradeResultReport = 0x0108, // 终端升级结果通知. 33 | kLocationReport = 0x0200, // 位置信息汇报. 34 | kGetLocationInformation = 0x8201, // 位置信息查询. 35 | kGetLocationInformationResponse = 0x0201, // 位置信息查询应答. 36 | kLocationTrackingControl = 0x8202, // 临时位置跟踪控制. 37 | 38 | }; 39 | 40 | // // 所有应答命令. 41 | // unsigned short kResponseCommand[] = { 42 | // kTerminalGeneralResponse, //终端通用应答 43 | // kPlatformGeneralResponse, //平台通用应答 44 | // kTerminalRegisterResponse, //终端注册应答 45 | // kGetTerminalParametersResponse, //查询终端参数应答 46 | // kGetLocationInformationResponse, //位置信息查询应答 47 | // }; 48 | 49 | // // 所有终端解析命令. 50 | // unsigned short kTerminalParserCMD[PARSER_NUM] = { 51 | // kPlatformGeneralResponse, //平台通用应答 52 | // kFillPacketRequest, // 补传分包请求. 53 | // kTerminalRegisterResponse, // 终端注册应答. 54 | // kSetTerminalParameters, // 设置终端参数. 55 | // kGetTerminalParameters, // 查询终端参数. 56 | // kGetSpecificTerminalParameters, // 查询指定终端参数. 57 | // kTerminalControl, //终端控制 58 | // kTerminalUpgrade, // 下发终端升级包. 59 | // kGetLocationInformation, // 位置信息查询. 60 | // }; 61 | 62 | // // 所有终端数据打包命令. 63 | // unsigned short kTerminalPackagerCMD[PACKAGER_NUM] = { 64 | // kTerminalGeneralResponse, // 终端通用应答. 65 | // kTerminalHeartBeat, // 终端心跳. 66 | // kTerminalRegister, // 终端注册. 67 | // kTerminalLogOut, // 终端注销. 68 | // kTerminalAuthentication, // 终端鉴权. 69 | // kGetTerminalParametersResponse, // 查询终端参数应答. 70 | // kTerminalUpgradeResultReport, // 终端升级结果通知. 71 | // kLocationReport, // 位置信息汇报. 72 | // kGetLocationInformationResponse, // 位置信息查询应答. 73 | // }; 74 | 75 | // 车牌颜色. 76 | enum VehiclePlateColor 77 | { 78 | kVin = 0x0, // 车辆未上牌. 79 | kBlue, 80 | kYellow, 81 | kBlack, 82 | kWhite, 83 | kOther 84 | }; 85 | 86 | // 通用应答结果. 87 | enum GeneralResponseResult 88 | { 89 | kSuccess = 0x0, // 成功/确认. 90 | kFailure = 0x1, // 失败. 91 | kMessageHasWrong =0x2, // 消息有误. 92 | kNotSupport = 0x3, // 不支持. 93 | kAlarmHandlingConfirmation = 0x4, // 报警处理确认, 仅平台应答使用. 94 | }; 95 | 96 | // 注册应答结果. 97 | enum RegisterResponseResult 98 | { 99 | kRegisterSuccess = 0x0, // 成功. 100 | kVehiclesHaveBeenRegistered = 0x1, // 车辆已被注册. 101 | kNoSuchVehicleInTheDatabase =0x2, // 数据库中无该车辆. 102 | kTerminalHaveBeenRegistered = 0x3, // 终端已被注册. 103 | kNoSuchTerminalInTheDatabase = 0x4, // 数据库中无该终端. 104 | }; 105 | 106 | // 消息体属性. 107 | union MsgBodyAttribute 108 | { 109 | struct 110 | { 111 | // 消息体长度, 占用10bit. 112 | unsigned short msglen : 10; 113 | // 数据加密方式, 当此三位都为0, 表示消息体不加密, 114 | // 当第10位为1, 表示消息体经过RSA算法加密. 115 | unsigned short encrypt : 3; 116 | // 分包标记. 117 | unsigned short packet : 1; 118 | // 保留2位. 119 | unsigned short retain : 2; 120 | } bit; 121 | unsigned short u16val; 122 | }; 123 | 124 | // 消息内容起始位置. 125 | enum MsgBodyPos 126 | { 127 | MSGBODY_NOPACKET_POS = 13, // 短消息体消息内容起始位置.SMS 128 | MSGBODY_PACKET_POS = 17, // 长消息体消息内容起始位置. 129 | }; 130 | 131 | // 转义相关标识. 132 | enum ProtocolEscapeFlag 133 | { 134 | PROTOCOL_SIGN = 0x7E, // 标识位. 135 | PROTOCOL_ESCAPE = 0x7D, // 转义标识. 136 | PROTOCOL_ESCAPE_SIGN = 0x02, // 0x7E<-->0x7D后紧跟一个0x02. 137 | PROTOCOL_ESCAPE_ESCAPE = 0x01, // 0x7D<-->0x7D后紧跟一个0x01. 138 | }; 139 | 140 | // 消息头. 141 | struct MsgHead 142 | { 143 | // 消息ID. 144 | unsigned short msg_id; 145 | // 消息体属性. 146 | union MsgBodyAttribute msgbody_attr; 147 | // 终端手机号. 148 | unsigned char phone_num[13]; 149 | // 消息流水号. 150 | unsigned short msg_flow_num; 151 | // 总包数, 分包情况下使用. 152 | unsigned short total_packet; 153 | // 当前包编号, 分包情况下使用. 154 | unsigned short packet_seq; 155 | }; 156 | 157 | // 注册信息. 158 | struct RegisterInfo 159 | { 160 | // 省域ID. 161 | unsigned short province_id; 162 | 163 | // 市县域ID. 164 | unsigned short city_id; 165 | 166 | // 制造商ID, 固定5个字节. 167 | unsigned char manufacturer_id[5]; 168 | 169 | // 终端型号, 固定20个字节, 位数不足后补0x00. 170 | unsigned char terminal_model[20]; 171 | 172 | // 终端ID, 固定7个字节, 位数不足后补0x00. 173 | unsigned char terminal_id[7]; 174 | 175 | // 车牌颜色, 0表示未上牌. 176 | unsigned char car_plate_color; 177 | 178 | // 车辆标识, 仅在上牌时使用. 179 | unsigned char car_plate_num[12]; 180 | }; 181 | 182 | //struct RegisterID 183 | //{ 184 | // unsigned char PhoneNumber[20]; 185 | // unsigned char TerminalId[20]; 186 | //}; 187 | 188 | // 升级类型. 189 | enum kTerminalUpgradeType 190 | { 191 | // 终端. 192 | kTerminal = 0x0, 193 | // 道路运输证 IC 卡读卡器 194 | kICCardReader = 0xc, 195 | // 北斗卫星定位模块. 196 | kGNSS = 0x34, 197 | }; 198 | 199 | // 升级结果. 200 | enum kTerminalUpgradeResultType 201 | { 202 | // 终端升级成功. 203 | kTerminalUpgradeSuccess = 0x0, 204 | // 终端升级失败. 205 | kTerminalUpgradeFailed, 206 | // 终端升级取消. 207 | kTerminalUpgradeCancel 208 | }; 209 | 210 | // 升级信息. 211 | struct UpgradeInfo 212 | { 213 | // 升级类型. 214 | unsigned char upgrade_type; 215 | // 升级结果. 216 | unsigned char upgrade_result; 217 | // 制造商ID, 固定5个字节. 218 | unsigned char manufacturer_id[6]; 219 | //版本号长度 220 | unsigned char version_id_len; 221 | // 升级版本号. 222 | unsigned char *version_id; 223 | // 升级包总长度. 224 | unsigned int upgrade_data_total_len; 225 | // 升级数据包. 226 | unsigned char *upgrade_data; 227 | }; 228 | 229 | // 补传分包信息. 230 | struct FillPacket 231 | { 232 | // 分包数据首包的消息流水号. 233 | unsigned short first_packet_msg_flow_num; 234 | // 需要重传包的ID. 235 | const char packet_id[50]; 236 | }; 237 | 238 | // 协议格式、各消息ID等相关参数. 239 | struct ProtocolParameter 240 | { 241 | unsigned char respone_result; 242 | unsigned short respone_msg_id; 243 | unsigned short respone_flow_num; 244 | // 消息头. 245 | struct MsgHead msg_head; 246 | // 终端注册时需填充注册信息. 247 | struct RegisterInfo register_info; 248 | // struct RegisterID register_id; 249 | // 平台随机生成鉴权码. 250 | unsigned char *authentication_code; 251 | // 设置终端参数项. 252 | struct TerminalParameters terminal_parameters; 253 | // 查询终端参数ID列表. 254 | // std::vector terminal_parameter_ids; 255 | // 位置上报时填充位置基本信息, 必须项. 256 | struct LocationBasicInformation location_info; 257 | // 位置上报时填充位置附加信息, 可选项. 258 | // LocationExtensions location_extension; 259 | // 临时位置跟踪控制信息. 260 | struct LocationTrackingControl location_tracking_control; 261 | 262 | // 升级信息. 263 | struct UpgradeInfo upgrade_info; 264 | // 补传分包信息. 265 | struct FillPacket fill_packet; 266 | 267 | //终端控制 268 | struct TerminalControl terminal_control; 269 | 270 | // // 保留字段. 271 | // std::vector retain; 272 | 273 | // 用于解析消息. 274 | struct 275 | { 276 | unsigned char respone_result; 277 | unsigned short respone_msg_id; 278 | unsigned short respone_flow_num; 279 | // 解析出的消息头. 280 | struct MsgHead msg_head; 281 | // 解析出的注册信息. 282 | struct RegisterInfo register_info; 283 | // 解析出的鉴权码. 284 | // 平台随机生成鉴权码. 285 | unsigned char *authentication_code; 286 | // 解析出的设置终端参数项. 287 | struct TerminalParameters terminal_parameters; 288 | // 解析出的查询终端参数ID列表. 289 | // std::vector terminal_parameter_ids; 290 | // 解析出的位置基本信息. 291 | struct LocationBasicInformation location_info; 292 | // 解析出的位置附加信息. 293 | // LocationExtensions location_extension; 294 | // 解析出的临时位置跟踪控制信息. 295 | struct LocationTrackingControl location_tracking_control; 296 | 297 | // 解析出的升级信息. 298 | struct UpgradeInfo upgrade_info; 299 | // 解析出的补传分包信息. 300 | struct FillPacket fill_packet; 301 | 302 | //终端控制 303 | struct TerminalControl terminal_control; 304 | 305 | // 解析出的保留字段. 306 | // std::vector retain; 307 | 308 | } parse; 309 | }; 310 | 311 | //struct ProtocolParameter parameter_; 312 | 313 | #endif // JT808_PROTOCOL_PARAMETER_H_ 314 | --------------------------------------------------------------------------------