[WIP] Add syntax check for rust and C\C++ code (#108)
* proof of concept * fix syntax for rust and add auto fix syntax * fix syntax for C * fix bug with files owner * add information to wiki * try to add ci * format code from master * even more format fixes * change docker to docker-compose * Exclude ./target_*/build directories from format check * Run rustfmt only on project files * add ulimit setup for long clang list * merge * fix rustfmt, exclude target Inc directory * sync with master * abspath Co-authored-by: aanper <mail@s3f.ru> Co-authored-by: Vadim Kaushan <admin@disasm.info>
This commit is contained in:
		
							parent
							
								
									7ded31c19d
								
							
						
					
					
						commit
						110a9efc3c
					
				
							
								
								
									
										86
									
								
								.clang-format
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										86
									
								
								.clang-format
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,86 @@ | ||||
| AccessModifierOffset: -4 | ||||
| AlignAfterOpenBracket: Align | ||||
| AlignConsecutiveAssignments: false | ||||
| AlignConsecutiveDeclarations: false | ||||
| AlignEscapedNewlines: Left | ||||
| AlignOperands: true | ||||
| AlignTrailingComments: false | ||||
| AllowAllParametersOfDeclarationOnNextLine: false | ||||
| AllowShortBlocksOnASingleLine: false | ||||
| AllowShortCaseLabelsOnASingleLine: false | ||||
| AllowShortFunctionsOnASingleLine: None | ||||
| AllowShortIfStatementsOnASingleLine: true | ||||
| AllowShortLoopsOnASingleLine: true | ||||
| AlwaysBreakAfterDefinitionReturnType: None | ||||
| AlwaysBreakAfterReturnType: None | ||||
| AlwaysBreakBeforeMultilineStrings: false | ||||
| AlwaysBreakTemplateDeclarations: false | ||||
| BinPackArguments: false | ||||
| BinPackParameters: false | ||||
| BreakBeforeBinaryOperators: None | ||||
| BreakBeforeBraces: Attach | ||||
| BreakBeforeTernaryOperators: false | ||||
| BreakConstructorInitializers: BeforeComma | ||||
| BreakStringLiterals: false | ||||
| ColumnLimit: 99 | ||||
| CompactNamespaces: false | ||||
| ConstructorInitializerAllOnOneLineOrOnePerLine: false | ||||
| ConstructorInitializerIndentWidth: 4 | ||||
| ContinuationIndentWidth: 4 | ||||
| Cpp11BracedListStyle: true | ||||
| DerivePointerAlignment: false | ||||
| DisableFormat: false | ||||
| ExperimentalAutoDetectBinPacking: false | ||||
| FixNamespaceComments: false | ||||
| 
 | ||||
| IncludeBlocks: Preserve | ||||
| IncludeCategories: | ||||
|   - Regex: '.*' | ||||
|     Priority: 1 | ||||
| IncludeIsMainRegex: '(Test)?$' | ||||
| IndentCaseLabels: false | ||||
| IndentPPDirectives: None | ||||
| IndentWidth: 4 | ||||
| IndentWrappedFunctionNames: false | ||||
| JavaScriptQuotes: Leave | ||||
| JavaScriptWrapImports: true | ||||
| KeepEmptyLinesAtTheStartOfBlocks: false | ||||
| MacroBlockBegin: '' | ||||
| MacroBlockEnd: '' | ||||
| MaxEmptyLinesToKeep: 1 | ||||
| NamespaceIndentation: None | ||||
| ObjCBinPackProtocolList: Auto | ||||
| ObjCBlockIndentWidth: 4 | ||||
| ObjCSpaceAfterProperty: true | ||||
| ObjCSpaceBeforeProtocolList: true | ||||
| 
 | ||||
| # Taken from git's rules | ||||
| PenaltyBreakAssignment: 10 | ||||
| PenaltyBreakBeforeFirstCallParameter: 30 | ||||
| PenaltyBreakComment: 10 | ||||
| PenaltyBreakFirstLessLess: 0 | ||||
| PenaltyBreakString: 10 | ||||
| PenaltyExcessCharacter: 100 | ||||
| PenaltyReturnTypeOnItsOwnLine: 60 | ||||
| 
 | ||||
| PointerAlignment: Left | ||||
| ReflowComments: false | ||||
| SortIncludes: false | ||||
| SortUsingDeclarations: false | ||||
| SpaceAfterCStyleCast: false | ||||
| SpaceAfterTemplateKeyword: true | ||||
| SpaceBeforeAssignmentOperators: true | ||||
| SpaceBeforeCtorInitializerColon: true | ||||
| SpaceBeforeInheritanceColon: true | ||||
| SpaceBeforeParens: Never | ||||
| SpaceBeforeRangeBasedForLoopColon: true | ||||
| SpaceInEmptyParentheses: false | ||||
| SpacesBeforeTrailingComments: 1 | ||||
| SpacesInAngles: false | ||||
| SpacesInContainerLiterals: false | ||||
| SpacesInCStyleCastParentheses: false | ||||
| SpacesInParentheses: false | ||||
| SpacesInSquareBrackets: false | ||||
| Standard: Cpp03 | ||||
| TabWidth: 4 | ||||
| UseTab: Never | ||||
							
								
								
									
										6
									
								
								.github/workflows/ci.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										6
									
								
								.github/workflows/ci.yml
									
									
									
									
										vendored
									
									
								
							| @ -23,6 +23,12 @@ jobs: | ||||
|       - name: Build docker image | ||||
|         uses: ./.github/actions/docker | ||||
| 
 | ||||
|       - name: Check syntax | ||||
|         uses: ./.github/actions/docker | ||||
|         continue-on-error: true | ||||
|         with: | ||||
|           run: /syntax_check.sh | ||||
| 
 | ||||
|       - name: Build target_lo in docker | ||||
|         uses: ./.github/actions/docker | ||||
|         with: | ||||
|  | ||||
							
								
								
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							| @ -1,5 +1,4 @@ | ||||
| .idea/ | ||||
| target_lo/build/ | ||||
| target_*/build/ | ||||
| bindings/ | ||||
| 
 | ||||
|  | ||||
| @ -9,9 +9,7 @@ void coreglitch_demo_0(void* p) { | ||||
|     fuprintf(log, "coreglitch demo!\n"); | ||||
| 
 | ||||
|     // open record
 | ||||
|     FuriRecordSubscriber* fb_record = furi_open( | ||||
|         "u8g2_fb", false, false, NULL, NULL, NULL | ||||
|     ); | ||||
|     FuriRecordSubscriber* fb_record = furi_open("u8g2_fb", false, false, NULL, NULL, NULL); | ||||
| 
 | ||||
|     if(fb_record == NULL) { | ||||
|         fuprintf(log, "[widget] cannot create fb record\n"); | ||||
| @ -33,18 +31,17 @@ void coreglitch_demo_0(void* p) { | ||||
|         1.0, | ||||
|         1.5, | ||||
|         0.75, | ||||
|         0.8 | ||||
|         0.8, | ||||
|     }; | ||||
| 
 | ||||
|     uint8_t cnt = 0; | ||||
| 
 | ||||
|     while(1) { | ||||
| 
 | ||||
|         for(size_t note_idx = 0; note_idx < 400; note_idx++) { | ||||
|             float scale = scales[((cnt + note_idx)/16) % 4]; | ||||
|             float scale = scales[((cnt + note_idx) / 16) % 4]; | ||||
| 
 | ||||
|             float freq = notes[(note_idx + cnt / 2) % 8] * scale; | ||||
|             float width = 0.001 + 0.05 * (note_idx % (cnt/7 + 5)); | ||||
|             float width = 0.001 + 0.05 * (note_idx % (cnt / 7 + 5)); | ||||
| 
 | ||||
|             if(note_idx % 8 == 0) { | ||||
|                 freq = 0; | ||||
| @ -56,7 +53,6 @@ void coreglitch_demo_0(void* p) { | ||||
| 
 | ||||
|             cnt++; | ||||
| 
 | ||||
|              | ||||
|             u8g2_t* fb = furi_take(fb_record); | ||||
|             if(fb != NULL) { | ||||
|                 u8g2_SetDrawColor(fb, 0); | ||||
|  | ||||
| @ -7,104 +7,107 @@ extern SPI_HandleTypeDef hspi1; | ||||
| 
 | ||||
| // TODO rewrite u8g2 to pass thread-local context in this handlers
 | ||||
| 
 | ||||
| static uint8_t u8g2_gpio_and_delay_stm32(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr) { | ||||
| static uint8_t | ||||
| u8g2_gpio_and_delay_stm32(u8x8_t* u8x8, uint8_t msg, uint8_t arg_int, void* arg_ptr) { | ||||
|     switch(msg) { | ||||
|         //Initialize SPI peripheral
 | ||||
|         case U8X8_MSG_GPIO_AND_DELAY_INIT: | ||||
|             /* HAL initialization contains all what we need so we can skip this part. */ | ||||
|     //Initialize SPI peripheral
 | ||||
|     case U8X8_MSG_GPIO_AND_DELAY_INIT: | ||||
|         /* HAL initialization contains all what we need so we can skip this part. */ | ||||
|         break; | ||||
| 
 | ||||
|         //Function which implements a delay, arg_int contains the amount of ms
 | ||||
|         case U8X8_MSG_DELAY_MILLI: | ||||
|             osDelay(arg_int); | ||||
|     //Function which implements a delay, arg_int contains the amount of ms
 | ||||
|     case U8X8_MSG_DELAY_MILLI: | ||||
|         osDelay(arg_int); | ||||
|         break; | ||||
| 
 | ||||
|         //Function which delays 10us
 | ||||
|         case U8X8_MSG_DELAY_10MICRO: | ||||
|             delay_us(10); | ||||
|     //Function which delays 10us
 | ||||
|     case U8X8_MSG_DELAY_10MICRO: | ||||
|         delay_us(10); | ||||
|         break; | ||||
| 
 | ||||
|         //Function which delays 100ns
 | ||||
|         case U8X8_MSG_DELAY_100NANO: | ||||
|             asm("nop"); | ||||
|     //Function which delays 100ns
 | ||||
|     case U8X8_MSG_DELAY_100NANO: | ||||
|         asm("nop"); | ||||
|         break; | ||||
| 
 | ||||
|         // Function to define the logic level of the RESET line
 | ||||
|         case U8X8_MSG_GPIO_RESET: | ||||
|             #ifdef DEBUG | ||||
|                 fuprintf(log, "[u8g2] rst %d\n", arg_int); | ||||
|             #endif | ||||
|     // Function to define the logic level of the RESET line
 | ||||
|     case U8X8_MSG_GPIO_RESET: | ||||
| #ifdef DEBUG | ||||
|         fuprintf(log, "[u8g2] rst %d\n", arg_int); | ||||
| #endif | ||||
| 
 | ||||
|             // TODO change it to FuriRecord pin
 | ||||
|             HAL_GPIO_WritePin(DISPLAY_RST_GPIO_Port, DISPLAY_RST_Pin, arg_int ? GPIO_PIN_SET : GPIO_PIN_RESET); | ||||
|         // TODO change it to FuriRecord pin
 | ||||
|         HAL_GPIO_WritePin( | ||||
|             DISPLAY_RST_GPIO_Port, DISPLAY_RST_Pin, arg_int ? GPIO_PIN_SET : GPIO_PIN_RESET); | ||||
|         break; | ||||
| 
 | ||||
|         default: | ||||
|             #ifdef DEBUG | ||||
|                 fufuprintf(log, "[u8g2] unknown io %d\n", msg); | ||||
|             #endif | ||||
|     default: | ||||
| #ifdef DEBUG | ||||
|         fufuprintf(log, "[u8g2] unknown io %d\n", msg); | ||||
| #endif | ||||
| 
 | ||||
|             return 0; //A message was received which is not implemented, return 0 to indicate an error
 | ||||
|         return 0; //A message was received which is not implemented, return 0 to indicate an error
 | ||||
|     } | ||||
| 
 | ||||
|     return 1; // command processed successfully.
 | ||||
| } | ||||
| 
 | ||||
| static uint8_t u8x8_hw_spi_stm32(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr){ | ||||
|     switch (msg) { | ||||
|         case U8X8_MSG_BYTE_SEND: | ||||
|             #ifdef DEBUG | ||||
|                 fuprintf(log, "[u8g2] send %d bytes %02X\n", arg_int, ((uint8_t*)arg_ptr)[0]); | ||||
|             #endif | ||||
| static uint8_t u8x8_hw_spi_stm32(u8x8_t* u8x8, uint8_t msg, uint8_t arg_int, void* arg_ptr) { | ||||
|     switch(msg) { | ||||
|     case U8X8_MSG_BYTE_SEND: | ||||
| #ifdef DEBUG | ||||
|         fuprintf(log, "[u8g2] send %d bytes %02X\n", arg_int, ((uint8_t*)arg_ptr)[0]); | ||||
| #endif | ||||
| 
 | ||||
|             // TODO change it to FuriRecord SPI
 | ||||
|             HAL_SPI_Transmit(&hspi1, (uint8_t *)arg_ptr, arg_int, 10000); | ||||
|         // TODO change it to FuriRecord SPI
 | ||||
|         HAL_SPI_Transmit(&hspi1, (uint8_t*)arg_ptr, arg_int, 10000); | ||||
|         break; | ||||
| 
 | ||||
|         case U8X8_MSG_BYTE_SET_DC: | ||||
|             #ifdef DEBUG | ||||
|                 fuprintf(log, "[u8g2] dc %d\n", arg_int); | ||||
|             #endif | ||||
|     case U8X8_MSG_BYTE_SET_DC: | ||||
| #ifdef DEBUG | ||||
|         fuprintf(log, "[u8g2] dc %d\n", arg_int); | ||||
| #endif | ||||
| 
 | ||||
|             // TODO change it to FuriRecord pin
 | ||||
|             HAL_GPIO_WritePin(DISPLAY_DI_GPIO_Port, DISPLAY_DI_Pin, arg_int ? GPIO_PIN_SET : GPIO_PIN_RESET); | ||||
|         // TODO change it to FuriRecord pin
 | ||||
|         HAL_GPIO_WritePin( | ||||
|             DISPLAY_DI_GPIO_Port, DISPLAY_DI_Pin, arg_int ? GPIO_PIN_SET : GPIO_PIN_RESET); | ||||
|         break; | ||||
| 
 | ||||
|         case U8X8_MSG_BYTE_INIT: | ||||
|             #ifdef DEBUG | ||||
|                 fuprintf(log, "[u8g2] init\n"); | ||||
|             #endif | ||||
|     case U8X8_MSG_BYTE_INIT: | ||||
| #ifdef DEBUG | ||||
|         fuprintf(log, "[u8g2] init\n"); | ||||
| #endif | ||||
| 
 | ||||
|             // TODO change it to FuriRecord pin
 | ||||
|             HAL_GPIO_WritePin(DISPLAY_CS_GPIO_Port, DISPLAY_CS_Pin, GPIO_PIN_RESET); | ||||
|         // TODO change it to FuriRecord pin
 | ||||
|         HAL_GPIO_WritePin(DISPLAY_CS_GPIO_Port, DISPLAY_CS_Pin, GPIO_PIN_RESET); | ||||
|         break; | ||||
| 
 | ||||
|         case U8X8_MSG_BYTE_START_TRANSFER: | ||||
|             #ifdef DEBUG | ||||
|                 fuprintf(log, "[u8g2] start\n"); | ||||
|             #endif | ||||
|     case U8X8_MSG_BYTE_START_TRANSFER: | ||||
| #ifdef DEBUG | ||||
|         fuprintf(log, "[u8g2] start\n"); | ||||
| #endif | ||||
| 
 | ||||
|             // TODO change it to FuriRecord pin
 | ||||
|             HAL_GPIO_WritePin(DISPLAY_CS_GPIO_Port, DISPLAY_CS_Pin, GPIO_PIN_RESET); | ||||
|             asm("nop"); | ||||
|         // TODO change it to FuriRecord pin
 | ||||
|         HAL_GPIO_WritePin(DISPLAY_CS_GPIO_Port, DISPLAY_CS_Pin, GPIO_PIN_RESET); | ||||
|         asm("nop"); | ||||
|         break; | ||||
| 
 | ||||
|         case U8X8_MSG_BYTE_END_TRANSFER: | ||||
|             #ifdef DEBUG | ||||
|                 fuprintf(log, "[u8g2] end\n"); | ||||
|             #endif | ||||
|     case U8X8_MSG_BYTE_END_TRANSFER: | ||||
| #ifdef DEBUG | ||||
|         fuprintf(log, "[u8g2] end\n"); | ||||
| #endif | ||||
| 
 | ||||
|             asm("nop"); | ||||
|             // TODO change it to FuriRecord pin
 | ||||
|             HAL_GPIO_WritePin(DISPLAY_CS_GPIO_Port, DISPLAY_CS_Pin, GPIO_PIN_SET); | ||||
|         asm("nop"); | ||||
|         // TODO change it to FuriRecord pin
 | ||||
|         HAL_GPIO_WritePin(DISPLAY_CS_GPIO_Port, DISPLAY_CS_Pin, GPIO_PIN_SET); | ||||
|         break; | ||||
| 
 | ||||
|         default: | ||||
|             #ifdef DEBUG | ||||
|                 fuprintf(log, "[u8g2] unknown xfer %d\n", msg); | ||||
|             #endif | ||||
|     default: | ||||
| #ifdef DEBUG | ||||
|         fuprintf(log, "[u8g2] unknown xfer %d\n", msg); | ||||
| #endif | ||||
| 
 | ||||
|             return 0; | ||||
|         return 0; | ||||
|     } | ||||
| 
 | ||||
|     return 1; | ||||
| @ -131,8 +134,10 @@ void display_u8g2(void* p) { | ||||
|     HAL_GPIO_WritePin(DISPLAY_BACKLIGHT_GPIO_Port, DISPLAY_BACKLIGHT_Pin, GPIO_PIN_SET); | ||||
| 
 | ||||
|     u8g2_t _u8g2; | ||||
|     u8g2_Setup_st7565_erc12864_alt_f(&_u8g2, U8G2_R0, u8x8_hw_spi_stm32, u8g2_gpio_and_delay_stm32); | ||||
|     u8g2_InitDisplay(&_u8g2); // send init sequence to the display, display is in sleep mode after this
 | ||||
|     u8g2_Setup_st7565_erc12864_alt_f( | ||||
|         &_u8g2, U8G2_R0, u8x8_hw_spi_stm32, u8g2_gpio_and_delay_stm32); | ||||
|     u8g2_InitDisplay( | ||||
|         &_u8g2); // send init sequence to the display, display is in sleep mode after this
 | ||||
|     u8g2_SetContrast(&_u8g2, 36); | ||||
| 
 | ||||
|     if(!furi_create("u8g2_fb", (void*)&_u8g2, sizeof(_u8g2))) { | ||||
| @ -153,9 +158,8 @@ void display_u8g2(void* p) { | ||||
|     DisplayCtx ctx = {.update = update, .log = log}; | ||||
| 
 | ||||
|     // subscribe to record. ctx will be passed to handle_fb_change
 | ||||
|     FuriRecordSubscriber* fb_record = furi_open( | ||||
|         "u8g2_fb", false, false, handle_fb_change, NULL, &ctx | ||||
|     ); | ||||
|     FuriRecordSubscriber* fb_record = | ||||
|         furi_open("u8g2_fb", false, false, handle_fb_change, NULL, &ctx); | ||||
| 
 | ||||
|     if(fb_record == NULL) { | ||||
|         fuprintf(log, "[display] cannot open fb record\n"); | ||||
|  | ||||
| @ -78,57 +78,53 @@ void application_ipc_display(void* p) { | ||||
|     IpcCtx ctx = {.events = events, .log = log}; | ||||
| 
 | ||||
|     // subscribe to record. ctx will be passed to handle_fb_change
 | ||||
|     FuriRecordSubscriber* fb_record = furi_open( | ||||
|         "test_fb", false, false, handle_fb_change, NULL, &ctx | ||||
|     ); | ||||
|     FuriRecordSubscriber* fb_record = | ||||
|         furi_open("test_fb", false, false, handle_fb_change, NULL, &ctx); | ||||
| 
 | ||||
|     if(fb_record == NULL) { | ||||
|         fuprintf(log, "[display] cannot open fb record\n"); | ||||
|         furiac_exit(NULL); | ||||
|     } | ||||
| 
 | ||||
|     #ifdef HW_DISPLAY | ||||
| #ifdef HW_DISPLAY | ||||
|     // on Flipper target -- open screen
 | ||||
| 
 | ||||
|     // draw border
 | ||||
| 
 | ||||
|     #else | ||||
| #else | ||||
|     // on Local target -- print "blank screen"
 | ||||
|     { | ||||
|         void* fb = furi_take(fb_record); | ||||
|         print_fb((char*)fb, log); | ||||
|         furi_give(fb_record); | ||||
|     } | ||||
|     #endif | ||||
| #endif | ||||
| 
 | ||||
|     while(1) { | ||||
|         // wait for event
 | ||||
|         if(xSemaphoreTake(events, portMAX_DELAY) == pdTRUE) { | ||||
|             fuprintf(log, "[display] get fb update\n\n"); | ||||
| 
 | ||||
|             #ifdef HW_DISPLAY | ||||
|             // on Flipper target draw the screen
 | ||||
|             #else | ||||
| #ifdef HW_DISPLAY | ||||
| // on Flipper target draw the screen
 | ||||
| #else | ||||
|             // on local target just print
 | ||||
|             { | ||||
|                 void* fb = furi_take(fb_record); | ||||
|                 print_fb((char*)fb, log); | ||||
|                 furi_give(fb_record); | ||||
|             } | ||||
|             #endif | ||||
| #endif | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| // Widget application
 | ||||
| void application_ipc_widget(void* p) { | ||||
|     FuriRecordSubscriber* log = get_default_log(); | ||||
| 
 | ||||
|     // open record
 | ||||
|     FuriRecordSubscriber* fb_record = furi_open( | ||||
|         "test_fb", false, false, NULL, NULL, NULL | ||||
|     ); | ||||
|     FuriRecordSubscriber* fb_record = furi_open("test_fb", false, false, NULL, NULL, NULL); | ||||
| 
 | ||||
|     if(fb_record == NULL) { | ||||
|         fuprintf(log, "[widget] cannot create fb record\n"); | ||||
|  | ||||
| @ -8,9 +8,7 @@ void u8g2_example(void* p) { | ||||
|     delay(1000); | ||||
| 
 | ||||
|     // open record
 | ||||
|     FuriRecordSubscriber* fb_record = furi_open( | ||||
|         "u8g2_fb", false, false, NULL, NULL, NULL | ||||
|     ); | ||||
|     FuriRecordSubscriber* fb_record = furi_open("u8g2_fb", false, false, NULL, NULL, NULL); | ||||
| 
 | ||||
|     if(fb_record == NULL) { | ||||
|         fuprintf(log, "[widget] cannot create fb record\n"); | ||||
|  | ||||
| @ -23,25 +23,25 @@ void u8g2_example(void* p); | ||||
| void coreglitch_demo_0(void* p); | ||||
| 
 | ||||
| const FlipperStartupApp FLIPPER_STARTUP[] = { | ||||
|     #ifndef TEST | ||||
| #ifndef TEST | ||||
|     {.app = display_u8g2, .name = "display_u8g2"}, | ||||
|     {.app = u8g2_example, .name = "u8g2_example"}, | ||||
|     #endif | ||||
| #endif | ||||
| 
 | ||||
|     // {.app = coreglitch_demo_0, .name = "coreglitch_demo_0"},
 | ||||
| // {.app = coreglitch_demo_0, .name = "coreglitch_demo_0"},
 | ||||
| 
 | ||||
|     #ifdef TEST | ||||
| #ifdef TEST | ||||
|     {.app = flipper_test_app, .name = "test app"}, | ||||
|     #endif | ||||
| #endif | ||||
| 
 | ||||
|     #ifdef EXAMPLE_BLINK | ||||
| #ifdef EXAMPLE_BLINK | ||||
|     {.app = application_blink, .name = "blink"}, | ||||
|     #endif | ||||
|     #ifdef EXAMPLE_UART_WRITE | ||||
| #endif | ||||
| #ifdef EXAMPLE_UART_WRITE | ||||
|     {.app = application_uart_write, .name = "uart write"}, | ||||
|     #endif | ||||
|     #ifdef EXAMPLE_IPC | ||||
| #endif | ||||
| #ifdef EXAMPLE_IPC | ||||
|     {.app = application_ipc_display, .name = "ipc display"}, | ||||
|     {.app = application_ipc_widget, .name = "ipc widget"}, | ||||
|     #endif | ||||
| #endif | ||||
| }; | ||||
| @ -30,9 +30,8 @@ bool test_furi_pipe_record(FuriRecordSubscriber* log) { | ||||
|     } | ||||
| 
 | ||||
|     // 2. Open/subscribe to it
 | ||||
|     FuriRecordSubscriber* pipe_record = furi_open( | ||||
|         "test/pipe", false, false, pipe_record_cb, NULL, NULL | ||||
|     ); | ||||
|     FuriRecordSubscriber* pipe_record = | ||||
|         furi_open("test/pipe", false, false, pipe_record_cb, NULL, NULL); | ||||
|     if(pipe_record == NULL) { | ||||
|         fuprintf(log, "cannot open record\n"); | ||||
|         return false; | ||||
| @ -97,9 +96,8 @@ bool test_furi_holding_data(FuriRecordSubscriber* log) { | ||||
|     } | ||||
| 
 | ||||
|     // 2. Open/Subscribe on it
 | ||||
|     FuriRecordSubscriber* holding_record = furi_open( | ||||
|         "test/holding", false, false, holding_record_cb, NULL, NULL | ||||
|     ); | ||||
|     FuriRecordSubscriber* holding_record = | ||||
|         furi_open("test/holding", false, false, holding_record_cb, NULL, NULL); | ||||
|     if(holding_record == NULL) { | ||||
|         fuprintf(log, "cannot open record\n"); | ||||
|         return false; | ||||
| @ -163,9 +161,8 @@ typedef struct { | ||||
| void furi_concurent_app(void* p) { | ||||
|     FuriRecordSubscriber* log = (FuriRecordSubscriber*)p; | ||||
| 
 | ||||
|     FuriRecordSubscriber* holding_record = furi_open( | ||||
|         "test/concurrent", false, false, NULL, NULL, NULL | ||||
|     ); | ||||
|     FuriRecordSubscriber* holding_record = | ||||
|         furi_open("test/concurrent", false, false, NULL, NULL, NULL); | ||||
|     if(holding_record == NULL) { | ||||
|         fuprintf(log, "cannot open record\n"); | ||||
|         furiac_exit(NULL); | ||||
| @ -202,18 +199,15 @@ bool test_furi_concurrent_access(FuriRecordSubscriber* log) { | ||||
|     } | ||||
| 
 | ||||
|     // 2. Open it
 | ||||
|     FuriRecordSubscriber* holding_record = furi_open( | ||||
|         "test/concurrent", false, false, NULL, NULL, NULL | ||||
|     ); | ||||
|     FuriRecordSubscriber* holding_record = | ||||
|         furi_open("test/concurrent", false, false, NULL, NULL, NULL); | ||||
|     if(holding_record == NULL) { | ||||
|         fuprintf(log, "cannot open record\n"); | ||||
|         return false; | ||||
|     } | ||||
| 
 | ||||
|     // 3. Create second app for interact with it
 | ||||
|     FuriApp* second_app = furiac_start( | ||||
|         furi_concurent_app, "furi concurent app", (void*)log | ||||
|     ); | ||||
|     FuriApp* second_app = furiac_start(furi_concurent_app, "furi concurent app", (void*)log); | ||||
| 
 | ||||
|     // 4. multiply ConcurrentValue::a
 | ||||
|     for(size_t i = 0; i < 4; i++) { | ||||
| @ -259,7 +253,6 @@ TEST: non-existent data | ||||
| TODO: implement this test | ||||
| */ | ||||
| bool test_furi_nonexistent_data(FuriRecordSubscriber* log) { | ||||
| 
 | ||||
|     return true; | ||||
| } | ||||
| 
 | ||||
| @ -326,9 +319,8 @@ void furi_mute_parent_app(void* p) { | ||||
|     } | ||||
| 
 | ||||
|     // 2. Open watch handler: solo=false, no_mute=false, subscribe to data
 | ||||
|     FuriRecordSubscriber* watch_handler = furi_open( | ||||
|         "test/mute", false, false, mute_record_cb, NULL, NULL | ||||
|     ); | ||||
|     FuriRecordSubscriber* watch_handler = | ||||
|         furi_open("test/mute", false, false, mute_record_cb, NULL, NULL); | ||||
|     if(watch_handler == NULL) { | ||||
|         fuprintf(log, "cannot open watch handler\n"); | ||||
|         furiac_exit(NULL); | ||||
| @ -342,16 +334,13 @@ void furi_mute_parent_app(void* p) { | ||||
| 
 | ||||
| bool test_furi_mute_algorithm(FuriRecordSubscriber* log) { | ||||
|     // 1. Create "parent" application:
 | ||||
|     FuriApp* parent_app = furiac_start( | ||||
|         furi_mute_parent_app, "parent app", (void*)log | ||||
|     ); | ||||
|     FuriApp* parent_app = furiac_start(furi_mute_parent_app, "parent app", (void*)log); | ||||
| 
 | ||||
|     delay(2); // wait creating record
 | ||||
| 
 | ||||
|     // 2. Open handler A: solo=false, no_mute=false, NULL subscriber. Subscribe to state.
 | ||||
|     FuriRecordSubscriber* handler_a = furi_open( | ||||
|         "test/mute", false, false, NULL, mute_record_state_cb, NULL | ||||
|     ); | ||||
|     FuriRecordSubscriber* handler_a = | ||||
|         furi_open("test/mute", false, false, NULL, mute_record_state_cb, NULL); | ||||
|     if(handler_a == NULL) { | ||||
|         fuprintf(log, "cannot open handler A\n"); | ||||
|         return false; | ||||
| @ -371,9 +360,7 @@ bool test_furi_mute_algorithm(FuriRecordSubscriber* log) { | ||||
|     } | ||||
| 
 | ||||
|     // 3. Open handler B: solo=true, no_mute=true, NULL subscriber.
 | ||||
|     FuriRecordSubscriber* handler_b = furi_open( | ||||
|         "test/mute", true, true, NULL, NULL, NULL | ||||
|     ); | ||||
|     FuriRecordSubscriber* handler_b = furi_open("test/mute", true, true, NULL, NULL, NULL); | ||||
|     if(handler_b == NULL) { | ||||
|         fuprintf(log, "cannot open handler B\n"); | ||||
|         return false; | ||||
| @ -400,7 +387,6 @@ bool test_furi_mute_algorithm(FuriRecordSubscriber* log) { | ||||
| 
 | ||||
|     test_counter = 3; | ||||
| 
 | ||||
| 
 | ||||
|     // Try to write data to B and check that subscriber get data.
 | ||||
|     if(!furi_write(handler_b, &test_counter, sizeof(uint8_t))) { | ||||
|         fuprintf(log, "write to B failed\n"); | ||||
| @ -412,11 +398,8 @@ bool test_furi_mute_algorithm(FuriRecordSubscriber* log) { | ||||
|         return false; | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
|     // 4. Open hadler C: solo=true, no_mute=false, NULL subscriber.
 | ||||
|     FuriRecordSubscriber* handler_c = furi_open( | ||||
|         "test/mute", true, false, NULL, NULL, NULL | ||||
|     ); | ||||
|     FuriRecordSubscriber* handler_c = furi_open("test/mute", true, false, NULL, NULL, NULL); | ||||
|     if(handler_c == NULL) { | ||||
|         fuprintf(log, "cannot open handler C\n"); | ||||
|         return false; | ||||
| @ -427,9 +410,7 @@ bool test_furi_mute_algorithm(FuriRecordSubscriber* log) { | ||||
|     // TODO: Try to write data to C and check that subscriber get data.
 | ||||
| 
 | ||||
|     // 5. Open handler D: solo=false, no_mute=false, NULL subscriber.
 | ||||
|     FuriRecordSubscriber* handler_d = furi_open( | ||||
|         "test/mute", false, false, NULL, NULL, NULL | ||||
|     ); | ||||
|     FuriRecordSubscriber* handler_d = furi_open("test/mute", false, false, NULL, NULL, NULL); | ||||
|     if(handler_d == NULL) { | ||||
|         fuprintf(log, "cannot open handler D\n"); | ||||
|         return false; | ||||
|  | ||||
| @ -78,7 +78,7 @@ typedef struct { | ||||
| void task_a(void*); | ||||
| void task_b(void*); | ||||
| 
 | ||||
| void task_a(void *p) { | ||||
| void task_a(void* p) { | ||||
|     // simply starts, add 'A' letter to sequence and switch
 | ||||
|     // if sequence counter = 0, call task B, exit otherwise
 | ||||
| 
 | ||||
|  | ||||
| @ -66,6 +66,5 @@ void flipper_test_app(void* p) { | ||||
| 
 | ||||
|     rust_uart_write(); | ||||
| 
 | ||||
| 
 | ||||
|     furiac_exit(NULL); | ||||
| } | ||||
| @ -8,6 +8,8 @@ fn main() { | ||||
|     cbindgen::generate(&crate_dir) | ||||
|         .expect("Unable to generate cbindgen bindings") | ||||
|         .write_to_file( | ||||
|             Path::new(&crate_dir).join("bindings").join(format!("{}.h", pkg_name)) | ||||
|             Path::new(&crate_dir) | ||||
|                 .join("bindings") | ||||
|                 .join(format!("{}.h", pkg_name)), | ||||
|         ); | ||||
| } | ||||
| @ -1,14 +1,13 @@ | ||||
| #![no_std] | ||||
| 
 | ||||
| #[cfg(target_arch = "arm")] | ||||
| use flipper_f1_sys::hal::{HAL_UART_Transmit_IT, huart1}; | ||||
| use flipper_f1_sys::hal::{huart1, HAL_UART_Transmit_IT}; | ||||
| 
 | ||||
| #[no_mangle] | ||||
| pub extern "C" fn add(a: u32, b: u32) -> u32 { | ||||
|     a + b | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| #[no_mangle] | ||||
| pub extern "C" fn rust_uart_write() { | ||||
|     let string = "Rust test string\n"; | ||||
| @ -28,12 +27,13 @@ pub extern "C" fn rust_uart_write() { | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| mod aux { | ||||
|     use core::panic::PanicInfo; | ||||
| 
 | ||||
|     #[panic_handler] | ||||
|     fn panic(_info: &PanicInfo) -> ! { | ||||
|         loop { continue } | ||||
|         loop { | ||||
|             continue; | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -64,28 +64,23 @@ impl BindingsGenerator { | ||||
|         let includes = [ | ||||
|             // This are bindings generated by cbindgen nearby
 | ||||
|             &flipper_core_bindings.to_string_lossy(), | ||||
| 
 | ||||
|             &self.gcc_include_dir.to_string_lossy(), | ||||
|         ]; | ||||
| 
 | ||||
|         #[rustfmt::skip] | ||||
|         return bindgen::Builder::default() | ||||
|             .use_core() | ||||
|     
 | ||||
|             .ctypes_prefix("self") | ||||
|             .blacklist_type("__uint8_t") | ||||
|             .blacklist_type("__uint32_t") | ||||
|             .blacklist_type("c_int") | ||||
|             .blacklist_type("__int32_t") | ||||
|     
 | ||||
|             // TODO there's no .no_debug method, to disable only for specific type
 | ||||
|             .derive_debug(false) | ||||
|     
 | ||||
|             .clang_arg("-DUSE_HAL_DRIVER") | ||||
|             .clang_arg("-DSTM32L476xx") | ||||
|             .clang_arg("-DBUTON_INVERT=false") | ||||
|             .clang_arg("-DDEBUG_UART=huart1") | ||||
|     
 | ||||
|             .clang_args( | ||||
|                 (includes.iter().map(|x| From::from(x as &str)).chain(stm32_sdk_includes)) | ||||
|                     .map(|include| format!("-I{}", include)) | ||||
|  | ||||
| @ -1,5 +1,4 @@ | ||||
| #![no_std] | ||||
| 
 | ||||
| #![allow(dead_code)] | ||||
| #![allow(non_camel_case_types)] | ||||
| #![allow(non_upper_case_globals)] | ||||
|  | ||||
							
								
								
									
										14
									
								
								core/app.cpp
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								core/app.cpp
									
									
									
									
									
								
							| @ -2,10 +2,10 @@ | ||||
| #include <stdio.h> | ||||
| 
 | ||||
| extern "C" { | ||||
|     #include "startup.h" | ||||
|     #include "furi.h" | ||||
|     #include "log.h" | ||||
|     #include "tty_uart.h" | ||||
| #include "startup.h" | ||||
| #include "furi.h" | ||||
| #include "log.h" | ||||
| #include "tty_uart.h" | ||||
| } | ||||
| 
 | ||||
| extern "C" void app() { | ||||
| @ -15,16 +15,16 @@ extern "C" void app() { | ||||
|     fuprintf(log, "\n=== Welcome to Flipper Zero! ===\n\n"); | ||||
| 
 | ||||
|     // FURI startup
 | ||||
|     FuriApp* handlers[sizeof(FLIPPER_STARTUP)/sizeof(FLIPPER_STARTUP[0])]; | ||||
|     FuriApp* handlers[sizeof(FLIPPER_STARTUP) / sizeof(FLIPPER_STARTUP[0])]; | ||||
| 
 | ||||
|     for(size_t i = 0; i < sizeof(FLIPPER_STARTUP)/sizeof(FLIPPER_STARTUP[0]); i++) { | ||||
|     for(size_t i = 0; i < sizeof(FLIPPER_STARTUP) / sizeof(FLIPPER_STARTUP[0]); i++) { | ||||
|         handlers[i] = furiac_start(FLIPPER_STARTUP[i].app, FLIPPER_STARTUP[i].name, NULL); | ||||
|     } | ||||
| 
 | ||||
|     bool is_alive = false; | ||||
|     do { | ||||
|         is_alive = false; | ||||
|         for(size_t i = 0; i < sizeof(FLIPPER_STARTUP)/sizeof(FLIPPER_STARTUP[0]); i++) { | ||||
|         for(size_t i = 0; i < sizeof(FLIPPER_STARTUP) / sizeof(FLIPPER_STARTUP[0]); i++) { | ||||
|             if(handlers[i]->handler != NULL) { | ||||
|                 is_alive = true; | ||||
|             } | ||||
|  | ||||
| @ -4,11 +4,11 @@ | ||||
| extern "C" { | ||||
| #endif | ||||
| 
 | ||||
|     #include "main.h" | ||||
|     #include "flipper_hal.h" | ||||
|     #include "cmsis_os.h" | ||||
|     #include "furi.h" | ||||
|     #include "log.h" | ||||
| #include "main.h" | ||||
| #include "flipper_hal.h" | ||||
| #include "cmsis_os.h" | ||||
| #include "furi.h" | ||||
| #include "log.h" | ||||
| 
 | ||||
| #ifdef __cplusplus | ||||
| } | ||||
|  | ||||
							
								
								
									
										124
									
								
								core/furi.c
									
									
									
									
									
								
							
							
						
						
									
										124
									
								
								core/furi.c
									
									
									
									
									
								
							| @ -29,16 +29,16 @@ static FuriRecord* find_record(const char* name) { | ||||
| 
 | ||||
| // TODO: change open-create to only open
 | ||||
| bool furi_create(const char* name, void* value, size_t size) { | ||||
|     #ifdef FURI_DEBUG | ||||
|         printf("[FURI] creating %s record\n", name); | ||||
|     #endif | ||||
| #ifdef FURI_DEBUG | ||||
|     printf("[FURI] creating %s record\n", name); | ||||
| #endif | ||||
| 
 | ||||
|     FuriRecord* record = find_record(name); | ||||
| 
 | ||||
|     if(record != NULL) { | ||||
|         #ifdef FURI_DEBUG | ||||
|             printf("[FURI] record already exist\n"); | ||||
|         #endif | ||||
| #ifdef FURI_DEBUG | ||||
|         printf("[FURI] record already exist\n"); | ||||
| #endif | ||||
| 
 | ||||
|         record->value = value; | ||||
|         record->size = size; | ||||
| @ -49,17 +49,16 @@ bool furi_create(const char* name, void* value, size_t size) { | ||||
|     // record not exist, create new
 | ||||
| 
 | ||||
|     if(current_buffer_idx >= MAX_RECORD_COUNT) { | ||||
|         // max record count exceed
 | ||||
|         #ifdef FURI_DEBUG | ||||
|             printf("[FURI] create: max record count exceed\n"); | ||||
|         #endif | ||||
| // max record count exceed
 | ||||
| #ifdef FURI_DEBUG | ||||
|         printf("[FURI] create: max record count exceed\n"); | ||||
| #endif | ||||
|         return NULL; | ||||
|     } | ||||
| 
 | ||||
|     records[current_buffer_idx].mute_counter = 0; | ||||
|     records[current_buffer_idx].mutex = xSemaphoreCreateMutexStatic( | ||||
|         &records[current_buffer_idx].mutex_buffer | ||||
|     ); | ||||
|     records[current_buffer_idx].mutex = | ||||
|         xSemaphoreCreateMutexStatic(&records[current_buffer_idx].mutex_buffer); | ||||
|     records[current_buffer_idx].value = value; | ||||
|     records[current_buffer_idx].size = size; | ||||
|     records[current_buffer_idx].name = name; | ||||
| @ -74,26 +73,24 @@ bool furi_create(const char* name, void* value, size_t size) { | ||||
|     return true; | ||||
| } | ||||
| 
 | ||||
| FuriRecordSubscriber* furi_open( | ||||
|     const char* name, | ||||
|     bool solo, | ||||
|     bool no_mute, | ||||
|     FlipperRecordCallback value_callback, | ||||
|     FlipperRecordStateCallback state_callback, | ||||
|     void* ctx | ||||
| ) { | ||||
|     #ifdef FURI_DEBUG | ||||
|         printf("[FURI] opening %s record\n", name); | ||||
|     #endif | ||||
| FuriRecordSubscriber* furi_open(const char* name, | ||||
|                                 bool solo, | ||||
|                                 bool no_mute, | ||||
|                                 FlipperRecordCallback value_callback, | ||||
|                                 FlipperRecordStateCallback state_callback, | ||||
|                                 void* ctx) { | ||||
| #ifdef FURI_DEBUG | ||||
|     printf("[FURI] opening %s record\n", name); | ||||
| #endif | ||||
| 
 | ||||
|     // get furi record by name
 | ||||
|     FuriRecord* record = find_record(name); | ||||
| 
 | ||||
|     if(record == NULL) { | ||||
|         // cannot find record
 | ||||
|         #ifdef FURI_DEBUG | ||||
|             printf("[FURI] cannot find record %s\n", name); | ||||
|         #endif | ||||
| // cannot find record
 | ||||
| #ifdef FURI_DEBUG | ||||
|         printf("[FURI] cannot find record %s\n", name); | ||||
| #endif | ||||
| 
 | ||||
|         // create record if not exist
 | ||||
|         if(!furi_create(name, NULL, 0)) { | ||||
| @ -118,10 +115,10 @@ FuriRecordSubscriber* furi_open( | ||||
|     } | ||||
| 
 | ||||
|     if(subscriber == NULL) { | ||||
|         // cannot add subscriber (full)
 | ||||
|         #ifdef FURI_DEBUG | ||||
|             printf("[FURI] open: cannot add subscriber (full)\n"); | ||||
|         #endif | ||||
| // cannot add subscriber (full)
 | ||||
| #ifdef FURI_DEBUG | ||||
|         printf("[FURI] open: cannot add subscriber (full)\n"); | ||||
| #endif | ||||
| 
 | ||||
|         return NULL; | ||||
|     } | ||||
| @ -147,19 +144,18 @@ FuriRecordSubscriber* furi_open( | ||||
|         current_task->records[current_task->records_count] = record; | ||||
|         current_task->records_count++; | ||||
|     } else { | ||||
|         #ifdef FURI_DEBUG | ||||
|             printf("[FURI] open: no current task\n"); | ||||
|         #endif | ||||
| #ifdef FURI_DEBUG | ||||
|         printf("[FURI] open: no current task\n"); | ||||
| #endif | ||||
|     } | ||||
| 
 | ||||
|     return subscriber; | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| void furi_close(FuriRecordSubscriber* handler) { | ||||
|     #ifdef FURI_DEBUG | ||||
|         printf("[FURI] closing %s record\n", handler->record->name); | ||||
|     #endif | ||||
| #ifdef FURI_DEBUG | ||||
|     printf("[FURI] closing %s record\n", handler->record->name); | ||||
| #endif | ||||
| 
 | ||||
|     // deallocate subscriber
 | ||||
|     handler->allocated = false; | ||||
| @ -181,10 +177,7 @@ static void furi_notify(FuriRecordSubscriber* handler, const void* value, size_t | ||||
|         if(handler->record->subscribers[i].allocated) { | ||||
|             if(handler->record->subscribers[i].cb != NULL) { | ||||
|                 handler->record->subscribers[i].cb( | ||||
|                     value, | ||||
|                     size, | ||||
|                     handler->record->subscribers[i].ctx | ||||
|                 ); | ||||
|                     value, size, handler->record->subscribers[i].ctx); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| @ -193,7 +186,7 @@ static void furi_notify(FuriRecordSubscriber* handler, const void* value, size_t | ||||
| void* furi_take(FuriRecordSubscriber* handler) { | ||||
|     if(handler == NULL || handler->record == NULL) return NULL; | ||||
| 
 | ||||
|     if (xSemaphoreTake(handler->record->mutex, portMAX_DELAY) == pdTRUE) { | ||||
|     if(xSemaphoreTake(handler->record->mutex, portMAX_DELAY) == pdTRUE) { | ||||
|         return handler->record->value; | ||||
|     } else { | ||||
|         return NULL; | ||||
| @ -214,9 +207,9 @@ void furi_commit(FuriRecordSubscriber* handler) { | ||||
| } | ||||
| 
 | ||||
| bool furi_read(FuriRecordSubscriber* handler, void* value, size_t size) { | ||||
|     #ifdef FURI_DEBUG | ||||
|         printf("[FURI] read from %s\n", handler->record->name); | ||||
|     #endif | ||||
| #ifdef FURI_DEBUG | ||||
|     printf("[FURI] read from %s\n", handler->record->name); | ||||
| #endif | ||||
| 
 | ||||
|     if(handler == NULL || handler->record == NULL || value == NULL) return false; | ||||
| 
 | ||||
| @ -234,41 +227,40 @@ bool furi_read(FuriRecordSubscriber* handler, void* value, size_t size) { | ||||
| } | ||||
| 
 | ||||
| bool furi_write(FuriRecordSubscriber* handler, const void* value, size_t size) { | ||||
|     #ifdef FURI_DEBUG | ||||
|         printf("[FURI] write to %s\n", handler->record->name); | ||||
|     #endif | ||||
| #ifdef FURI_DEBUG | ||||
|     printf("[FURI] write to %s\n", handler->record->name); | ||||
| #endif | ||||
| 
 | ||||
|     if(handler == NULL || handler->record == NULL || value == NULL) { | ||||
|         #ifdef FURI_DEBUG | ||||
|             printf("[FURI] write: null param %x %x\n", (uint32_t)(size_t)handler, (uint32_t)(size_t)value); | ||||
|         #endif | ||||
| #ifdef FURI_DEBUG | ||||
|         printf("[FURI] write: null param %x %x\n", | ||||
|                (uint32_t)(size_t)handler, | ||||
|                (uint32_t)(size_t)value); | ||||
| #endif | ||||
| 
 | ||||
|         return false; | ||||
|     } | ||||
| 
 | ||||
|     // check if closed
 | ||||
|     if(!handler->allocated) { | ||||
|         #ifdef FURI_DEBUG | ||||
|             printf("[FURI] write: handler closed\n"); | ||||
|         #endif | ||||
| #ifdef FURI_DEBUG | ||||
|         printf("[FURI] write: handler closed\n"); | ||||
| #endif | ||||
|         return false; | ||||
|     } | ||||
| 
 | ||||
|     if(handler->record->value != NULL && size > handler->record->size) { | ||||
|         #ifdef FURI_DEBUG | ||||
|             printf("[FURI] write: wrong size %d\n", (uint32_t)size); | ||||
|         #endif | ||||
| #ifdef FURI_DEBUG | ||||
|         printf("[FURI] write: wrong size %d\n", (uint32_t)size); | ||||
| #endif | ||||
|         return false; | ||||
|     } | ||||
| 
 | ||||
|     // check mute
 | ||||
|     if( | ||||
|         handler->record->mute_counter != handler->mute_counter | ||||
|         && !handler->no_mute | ||||
|     ) { | ||||
|         #ifdef FURI_DEBUG | ||||
|             printf("[FURI] write: muted\n"); | ||||
|         #endif | ||||
|     if(handler->record->mute_counter != handler->mute_counter && !handler->no_mute) { | ||||
| #ifdef FURI_DEBUG | ||||
|         printf("[FURI] write: muted\n"); | ||||
| #endif | ||||
|         return false; | ||||
|     } | ||||
| 
 | ||||
|  | ||||
							
								
								
									
										21
									
								
								core/furi.h
									
									
									
									
									
								
							
							
						
						
									
										21
									
								
								core/furi.h
									
									
									
									
									
								
							| @ -8,10 +8,10 @@ | ||||
| #define MAX_RECORD_SUBSCRIBERS 8 | ||||
| 
 | ||||
| /// application is just a function
 | ||||
| typedef void(*FlipperApplication)(void*); | ||||
| typedef void (*FlipperApplication)(void*); | ||||
| 
 | ||||
| /// pointer to value callback function
 | ||||
| typedef void(*FlipperRecordCallback)(const void*, size_t, void*); | ||||
| typedef void (*FlipperRecordCallback)(const void*, size_t, void*); | ||||
| 
 | ||||
| typedef enum { | ||||
|     FlipperRecordStateMute, ///< record open and mute this handler
 | ||||
| @ -20,7 +20,7 @@ typedef enum { | ||||
| } FlipperRecordState; | ||||
| 
 | ||||
| /// pointer to state callback function
 | ||||
| typedef void(*FlipperRecordStateCallback)(FlipperRecordState, void*); | ||||
| typedef void (*FlipperRecordStateCallback)(FlipperRecordState, void*); | ||||
| 
 | ||||
| struct _FuriRecord; | ||||
| 
 | ||||
| @ -90,7 +90,6 @@ bool furiac_kill(FuriApp* app); | ||||
| // find task pointer by handle
 | ||||
| FuriApp* find_task(TaskHandle_t handler); | ||||
| 
 | ||||
| 
 | ||||
| /*!
 | ||||
| Creates named FURI record. | ||||
| \param[in] name you can open this record anywhere | ||||
| @ -110,14 +109,12 @@ When appication has exited or record has closed, all handlers is unmuted. | ||||
| It may be useful for concurrently acces to resources like framebuffer or beeper. | ||||
| \param[in] no_mute if true, another applications cannot mute this handler. | ||||
| */ | ||||
| FuriRecordSubscriber* furi_open( | ||||
|     const char* name, | ||||
|     bool solo, | ||||
|     bool no_mute, | ||||
|     FlipperRecordCallback value_callback, | ||||
|     FlipperRecordStateCallback state_callback, | ||||
|     void* ctx | ||||
| ); | ||||
| FuriRecordSubscriber* furi_open(const char* name, | ||||
|                                 bool solo, | ||||
|                                 bool no_mute, | ||||
|                                 FlipperRecordCallback value_callback, | ||||
|                                 FlipperRecordStateCallback state_callback, | ||||
|                                 void* ctx); | ||||
| 
 | ||||
| /*!
 | ||||
| 
 | ||||
|  | ||||
| @ -29,30 +29,29 @@ FuriApp* find_task(TaskHandle_t handler) { | ||||
| } | ||||
| 
 | ||||
| FuriApp* furiac_start(FlipperApplication app, const char* name, void* param) { | ||||
|     #ifdef FURI_DEBUG | ||||
|         printf("[FURIAC] start %s\n", name); | ||||
|     #endif | ||||
| #ifdef FURI_DEBUG | ||||
|     printf("[FURIAC] start %s\n", name); | ||||
| #endif | ||||
| 
 | ||||
|     // TODO check first free item (.handler == NULL) and use it
 | ||||
| 
 | ||||
|     if(current_buffer_idx >= MAX_TASK_COUNT) { | ||||
|         // max task count exceed
 | ||||
|         #ifdef FURI_DEBUG | ||||
|             printf("[FURIAC] max task count exceed\n"); | ||||
|         #endif | ||||
| // max task count exceed
 | ||||
| #ifdef FURI_DEBUG | ||||
|         printf("[FURIAC] max task count exceed\n"); | ||||
| #endif | ||||
|         return NULL; | ||||
|     } | ||||
| 
 | ||||
|     // create task on static stack memory
 | ||||
|     task_buffer[current_buffer_idx].handler = xTaskCreateStatic( | ||||
|         (TaskFunction_t)app, | ||||
|         (const char * const)name, | ||||
|         DEFAULT_STACK_SIZE / 4, // freertos specify stack size in words
 | ||||
|         (void * const) param, | ||||
|         tskIDLE_PRIORITY + 3, // normal priority
 | ||||
|         stack_buffer[current_buffer_idx], | ||||
|         &task_info_buffer[current_buffer_idx] | ||||
|     ); | ||||
|     task_buffer[current_buffer_idx].handler = | ||||
|         xTaskCreateStatic((TaskFunction_t)app, | ||||
|                           (const char* const)name, | ||||
|                           DEFAULT_STACK_SIZE / 4, // freertos specify stack size in words
 | ||||
|                           (void* const)param, | ||||
|                           tskIDLE_PRIORITY + 3, // normal priority
 | ||||
|                           stack_buffer[current_buffer_idx], | ||||
|                           &task_info_buffer[current_buffer_idx]); | ||||
| 
 | ||||
|     // save task
 | ||||
|     task_buffer[current_buffer_idx].application = app; | ||||
| @ -67,9 +66,9 @@ FuriApp* furiac_start(FlipperApplication app, const char* name, void* param) { | ||||
| } | ||||
| 
 | ||||
| bool furiac_kill(FuriApp* app) { | ||||
|     #ifdef FURI_DEBUG | ||||
|         printf("[FURIAC] kill %s\n", app->name); | ||||
|     #endif | ||||
| #ifdef FURI_DEBUG | ||||
|     printf("[FURIAC] kill %s\n", app->name); | ||||
| #endif | ||||
| 
 | ||||
|     // check handler
 | ||||
|     if(app == NULL || app->handler == NULL) return false; | ||||
| @ -90,16 +89,16 @@ void furiac_exit(void* param) { | ||||
| 
 | ||||
|     // run prev
 | ||||
|     if(current_task != NULL) { | ||||
|         #ifdef FURI_DEBUG | ||||
|             printf("[FURIAC] exit %s\n", current_task->name); | ||||
|         #endif | ||||
| #ifdef FURI_DEBUG | ||||
|         printf("[FURIAC] exit %s\n", current_task->name); | ||||
| #endif | ||||
| 
 | ||||
|         if(current_task->prev != NULL) { | ||||
|             furiac_start(current_task->prev, current_task->prev_name, param); | ||||
|         } else { | ||||
|             #ifdef FURI_DEBUG | ||||
|                 printf("[FURIAC] no prev\n"); | ||||
|             #endif | ||||
| #ifdef FURI_DEBUG | ||||
|             printf("[FURIAC] no prev\n"); | ||||
| #endif | ||||
|         } | ||||
| 
 | ||||
|         // cleanup registry
 | ||||
| @ -108,7 +107,7 @@ void furiac_exit(void* param) { | ||||
|     } | ||||
| 
 | ||||
|     // kill itself
 | ||||
|      vTaskDelete(NULL); | ||||
|     vTaskDelete(NULL); | ||||
| } | ||||
| 
 | ||||
| void furiac_switch(FlipperApplication app, char* name, void* param) { | ||||
| @ -116,14 +115,14 @@ void furiac_switch(FlipperApplication app, char* name, void* param) { | ||||
|     FuriApp* current_task = find_task(xTaskGetCurrentTaskHandle()); | ||||
| 
 | ||||
|     if(current_task == NULL) { | ||||
|         #ifdef FURI_DEBUG | ||||
|             printf("[FURIAC] no current task found\n"); | ||||
|         #endif | ||||
| #ifdef FURI_DEBUG | ||||
|         printf("[FURIAC] no current task found\n"); | ||||
| #endif | ||||
|     } | ||||
| 
 | ||||
|     #ifdef FURI_DEBUG | ||||
|         printf("[FURIAC] switch %s to %s\n", current_task->name, name); | ||||
|     #endif | ||||
| #ifdef FURI_DEBUG | ||||
|     printf("[FURIAC] switch %s to %s\n", current_task->name, name); | ||||
| #endif | ||||
| 
 | ||||
|     // run next
 | ||||
|     FuriApp* next = furiac_start(app, name, param); | ||||
|  | ||||
| @ -9,7 +9,7 @@ | ||||
| 
 | ||||
| #define PRINT_STR_SIZE 64 | ||||
| 
 | ||||
| void fuprintf(FuriRecordSubscriber* f, const char * format, ...) { | ||||
| void fuprintf(FuriRecordSubscriber* f, const char* format, ...) { | ||||
|     char buffer[PRINT_STR_SIZE]; | ||||
| 
 | ||||
|     va_list args; | ||||
|  | ||||
| @ -3,4 +3,4 @@ | ||||
| #include "furi.h" | ||||
| 
 | ||||
| FuriRecordSubscriber* get_default_log(); | ||||
| void fuprintf(FuriRecordSubscriber* f, const char * format, ...); | ||||
| void fuprintf(FuriRecordSubscriber* f, const char* format, ...); | ||||
|  | ||||
| @ -6,19 +6,19 @@ | ||||
| extern UART_HandleTypeDef DEBUG_UART; | ||||
| 
 | ||||
| void handle_uart_write(const void* data, size_t size, void* ctx) { | ||||
| 	HAL_UART_Transmit(&DEBUG_UART, (uint8_t*)data, (uint16_t)size, HAL_MAX_DELAY); | ||||
|     HAL_UART_Transmit(&DEBUG_UART, (uint8_t*)data, (uint16_t)size, HAL_MAX_DELAY); | ||||
| } | ||||
| 
 | ||||
| static ssize_t stdout_write(void *_cookie, const char *buf, size_t n) { | ||||
|     FuriRecordSubscriber *log = pvTaskGetThreadLocalStoragePointer(NULL, 0); | ||||
|     if (log == NULL) { | ||||
| static ssize_t stdout_write(void* _cookie, const char* buf, size_t n) { | ||||
|     FuriRecordSubscriber* log = pvTaskGetThreadLocalStoragePointer(NULL, 0); | ||||
|     if(log == NULL) { | ||||
|         log = furi_open("tty", false, false, NULL, NULL, NULL); | ||||
|         if (log == NULL) { | ||||
|         if(log == NULL) { | ||||
|             return -1; | ||||
|         } | ||||
|         vTaskSetThreadLocalStoragePointer(NULL, 0, log); | ||||
|     } | ||||
|     if (buf == 0) { | ||||
|     if(buf == 0) { | ||||
|         /*
 | ||||
|          * This means that we should flush internal buffers.  Since we | ||||
|          * don't we just return.  (Remember, "handle" == -1 means that all | ||||
| @ -33,22 +33,24 @@ static ssize_t stdout_write(void *_cookie, const char *buf, size_t n) { | ||||
| } | ||||
| 
 | ||||
| bool register_tty_uart() { | ||||
| 	if(!furi_create("tty", NULL, 0)) { | ||||
| 		return false; | ||||
| 	} | ||||
|     if(!furi_create("tty", NULL, 0)) { | ||||
|         return false; | ||||
|     } | ||||
| 
 | ||||
| 	if(furi_open("tty", false, false, handle_uart_write, NULL, NULL) == NULL) { | ||||
| 		return false; | ||||
| 	} | ||||
|     if(furi_open("tty", false, false, handle_uart_write, NULL, NULL) == NULL) { | ||||
|         return false; | ||||
|     } | ||||
| 
 | ||||
|     FILE* fp = fopencookie(NULL, "w", (cookie_io_functions_t) { | ||||
|         .read = NULL, | ||||
|         .write = stdout_write, | ||||
|         .seek = NULL, | ||||
|         .close = NULL, | ||||
|     }); | ||||
|     FILE* fp = fopencookie(NULL, | ||||
|                            "w", | ||||
|                            (cookie_io_functions_t){ | ||||
|                                .read = NULL, | ||||
|                                .write = stdout_write, | ||||
|                                .seek = NULL, | ||||
|                                .close = NULL, | ||||
|                            }); | ||||
|     setvbuf(fp, NULL, _IONBF, 0); | ||||
|     stdout = fp; | ||||
| 
 | ||||
| 	return true; | ||||
|     return true; | ||||
| } | ||||
|  | ||||
| @ -12,4 +12,5 @@ services: | ||||
|     working_dir: "/project" | ||||
|     environment: | ||||
|       DISPLAY: $DISPLAY | ||||
|       TERM: xterm-256color | ||||
|       PATH: /root/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin | ||||
|  | ||||
| @ -1,6 +1,8 @@ | ||||
| FROM ubuntu:18.04 | ||||
| 
 | ||||
| RUN apt-get update && \ | ||||
| ENV PATH /root/.cargo/bin:$PATH | ||||
| 
 | ||||
| RUN apt update && \ | ||||
|     apt install -y --no-install-recommends \ | ||||
|         make \ | ||||
|         gcc-arm-none-eabi \ | ||||
| @ -17,10 +19,15 @@ RUN apt-get update && \ | ||||
|         python \ | ||||
|         python-pip \ | ||||
|         libstdc++-arm-none-eabi-newlib \ | ||||
|         libclang-10-dev && \ | ||||
|     apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* | ||||
|         libclang-10-dev \ | ||||
|         clang-format-10 \ | ||||
|         && apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* | ||||
| 
 | ||||
| RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --profile=minimal --target thumbv7em-none-eabi thumbv7em-none-eabihf | ||||
| RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --profile=minimal --target thumbv7em-none-eabi thumbv7em-none-eabihf && \ | ||||
|     rustup component add rustfmt --toolchain stable-x86_64-unknown-linux-gnu | ||||
| 
 | ||||
| COPY entrypoint.sh syntax_check.sh / | ||||
| 
 | ||||
| RUN chmod +x /syntax_check.sh | ||||
| 
 | ||||
| COPY entrypoint.sh /entrypoint.sh | ||||
| ENTRYPOINT ["/entrypoint.sh"] | ||||
|  | ||||
							
								
								
									
										43
									
								
								docker/syntax_check.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										43
									
								
								docker/syntax_check.sh
									
									
									
									
									
										Executable file
									
								
							| @ -0,0 +1,43 @@ | ||||
| #!/usr/bin/env bash | ||||
| 
 | ||||
| set -e | ||||
| 
 | ||||
| CLANG_FORMAT_BIN="/usr/bin/clang-format-10" | ||||
| PATH="$HOME/.cargo/bin:${PATH}" | ||||
| 
 | ||||
| PROJECT_DIR=$(pwd) | ||||
| 
 | ||||
| cd $PROJECT_DIR | ||||
| 
 | ||||
| echo "RUN C\C++ SYNTAX CHECK" | ||||
| C_FILES=$(find . \ | ||||
|     -not \( -path './target_*/Middlewares' -prune \) \ | ||||
|     -not \( -path './target_*/Drivers' -prune \) \ | ||||
|     -not \( -path './target_*/build' -prune \) \ | ||||
|     -not \( -path './target_*/Inc' -prune \) \ | ||||
|     -not \( -path ./lib -prune \) \ | ||||
|     -name *.c -o -name *.h -o -name *.cpp) | ||||
| 
 | ||||
| ulimit -s 65536 | ||||
| $CLANG_FORMAT_BIN --verbose -style=file -n --Werror --ferror-limit=0 $C_FILES | ||||
| c_syntax_rc=$? | ||||
| 
 | ||||
| echo "RUN RUST SYNTAX CHECK" | ||||
| cd $PROJECT_DIR/core-rs && cargo fmt -- --check | ||||
| rust_syntax_rc=$? | ||||
| 
 | ||||
| if [[ $rust_syntax_rc -eq 0 ]] && [[ $c_syntax_rc -eq 0 ]]; then | ||||
|     echo "Code looks fine for me!" | ||||
|     exit 1 | ||||
| fi | ||||
| 
 | ||||
| read -p "Do you want fix syntax? (y/n): " confirm && [[ $confirm == [yY] || $confirm == [yY][eE][sS] ]] || exit 1 | ||||
| 
 | ||||
| cd $PROJECT_DIR/core-rs && cargo fmt -- | ||||
| 
 | ||||
| cd $PROJECT_DIR | ||||
| 
 | ||||
| # We use root in container and clang-format rewriting files. We'll need change owner to original | ||||
| local_user=$(stat -c '%u' .clang-format) | ||||
| $CLANG_FORMAT_BIN -style=file -i $C_FILES | ||||
| chown $local_user $C_FILES | ||||
							
								
								
									
										4
									
								
								syntax_check.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										4
									
								
								syntax_check.sh
									
									
									
									
									
										Executable file
									
								
							| @ -0,0 +1,4 @@ | ||||
| #!/usr/bin/env bash | ||||
| 
 | ||||
| echo "RUN SYNTAX CHECK INSIDE CONTAINER" | ||||
| docker-compose exec dev ./docker/syntax_check.sh | ||||
| @ -25,7 +25,7 @@ | ||||
|  * | ||||
|  * 1 tab == 4 spaces! | ||||
|  */ | ||||
|  /* USER CODE END Header */ | ||||
| /* USER CODE END Header */ | ||||
| 
 | ||||
| #ifndef FREERTOS_CONFIG_H | ||||
| #define FREERTOS_CONFIG_H | ||||
| @ -48,9 +48,9 @@ | ||||
| 
 | ||||
| /* Ensure definitions are only used by the compiler, and not by the assembler. */ | ||||
| #if defined(__ICCARM__) || defined(__CC_ARM) || defined(__GNUC__) | ||||
|   #include <stdint.h> | ||||
|   extern uint32_t SystemCoreClock; | ||||
|   void xPortSysTickHandler(void); | ||||
| #include <stdint.h> | ||||
| extern uint32_t SystemCoreClock; | ||||
| void xPortSysTickHandler(void); | ||||
| #endif | ||||
| #define configUSE_PREEMPTION                     1 | ||||
| #define configSUPPORT_STATIC_ALLOCATION          1 | ||||
| @ -71,37 +71,37 @@ | ||||
| #define configNUM_THREAD_LOCAL_STORAGE_POINTERS  1 | ||||
| 
 | ||||
| /* Co-routine definitions. */ | ||||
| #define configUSE_CO_ROUTINES                    0 | ||||
| #define configMAX_CO_ROUTINE_PRIORITIES          ( 2 ) | ||||
| #define configUSE_CO_ROUTINES 0 | ||||
| #define configMAX_CO_ROUTINE_PRIORITIES (2) | ||||
| 
 | ||||
| /* Software timer definitions. */ | ||||
| #define configUSE_TIMERS                         1 | ||||
| #define configTIMER_TASK_PRIORITY                ( 2 ) | ||||
| #define configTIMER_QUEUE_LENGTH                 10 | ||||
| #define configTIMER_TASK_STACK_DEPTH             256 | ||||
| #define configUSE_TIMERS 1 | ||||
| #define configTIMER_TASK_PRIORITY (2) | ||||
| #define configTIMER_QUEUE_LENGTH 10 | ||||
| #define configTIMER_TASK_STACK_DEPTH 256 | ||||
| 
 | ||||
| /* Set the following definitions to 1 to include the API function, or zero
 | ||||
| to exclude the API function. */ | ||||
| #define INCLUDE_vTaskPrioritySet            1 | ||||
| #define INCLUDE_uxTaskPriorityGet           1 | ||||
| #define INCLUDE_vTaskDelete                 1 | ||||
| #define INCLUDE_vTaskCleanUpResources       0 | ||||
| #define INCLUDE_vTaskSuspend                1 | ||||
| #define INCLUDE_vTaskDelayUntil             0 | ||||
| #define INCLUDE_vTaskDelay                  1 | ||||
| #define INCLUDE_xTaskGetSchedulerState      1 | ||||
| #define INCLUDE_vTaskPrioritySet 1 | ||||
| #define INCLUDE_uxTaskPriorityGet 1 | ||||
| #define INCLUDE_vTaskDelete 1 | ||||
| #define INCLUDE_vTaskCleanUpResources 0 | ||||
| #define INCLUDE_vTaskSuspend 1 | ||||
| #define INCLUDE_vTaskDelayUntil 0 | ||||
| #define INCLUDE_vTaskDelay 1 | ||||
| #define INCLUDE_xTaskGetSchedulerState 1 | ||||
| 
 | ||||
| /* Cortex-M specific definitions. */ | ||||
| #ifdef __NVIC_PRIO_BITS | ||||
|  /* __BVIC_PRIO_BITS will be specified when CMSIS is being used. */ | ||||
|  #define configPRIO_BITS         __NVIC_PRIO_BITS | ||||
| /* __BVIC_PRIO_BITS will be specified when CMSIS is being used. */ | ||||
| #define configPRIO_BITS __NVIC_PRIO_BITS | ||||
| #else | ||||
|  #define configPRIO_BITS         4 | ||||
| #define configPRIO_BITS 4 | ||||
| #endif | ||||
| 
 | ||||
| /* The lowest interrupt priority that can be used in a call to a "set priority"
 | ||||
| function. */ | ||||
| #define configLIBRARY_LOWEST_INTERRUPT_PRIORITY   15 | ||||
| #define configLIBRARY_LOWEST_INTERRUPT_PRIORITY 15 | ||||
| 
 | ||||
| /* The highest interrupt priority that can be used by any interrupt service
 | ||||
| routine that makes calls to interrupt safe FreeRTOS API functions.  DO NOT CALL | ||||
| @ -111,20 +111,27 @@ PRIORITY THAN THIS! (higher priorities are lower numeric values. */ | ||||
| 
 | ||||
| /* Interrupt priorities used by the kernel port layer itself.  These are generic
 | ||||
| to all Cortex-M ports, and do not rely on any particular library functions. */ | ||||
| #define configKERNEL_INTERRUPT_PRIORITY 		( configLIBRARY_LOWEST_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) ) | ||||
| #define configKERNEL_INTERRUPT_PRIORITY \ | ||||
|     (configLIBRARY_LOWEST_INTERRUPT_PRIORITY << (8 - configPRIO_BITS)) | ||||
| /* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!!
 | ||||
| See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */
 | ||||
| #define configMAX_SYSCALL_INTERRUPT_PRIORITY 	( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) ) | ||||
| #define configMAX_SYSCALL_INTERRUPT_PRIORITY \ | ||||
|     (configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS)) | ||||
| 
 | ||||
| /* Normal assert() semantics without relying on the provision of an assert.h
 | ||||
| header file. */ | ||||
| /* USER CODE BEGIN 1 */ | ||||
| #define configASSERT( x ) if ((x) == 0) {taskDISABLE_INTERRUPTS(); for( ;; );}  | ||||
| #define configASSERT(x)           \ | ||||
|     if((x) == 0) {                \ | ||||
|         taskDISABLE_INTERRUPTS(); \ | ||||
|         for(;;)                   \ | ||||
|             ;                     \ | ||||
|     } | ||||
| /* USER CODE END 1 */ | ||||
| 
 | ||||
| /* Definitions that map the FreeRTOS port interrupt handlers to their CMSIS
 | ||||
| standard names. */ | ||||
| #define vPortSVCHandler    SVC_Handler | ||||
| #define vPortSVCHandler SVC_Handler | ||||
| #define xPortPendSVHandler PendSV_Handler | ||||
| 
 | ||||
| /* IMPORTANT: This define is commented when used with STM32Cube firmware, when the timebase source is SysTick,
 | ||||
|  | ||||
| @ -9,11 +9,7 @@ GPIO and HAL implementations | ||||
| #include <stdbool.h> | ||||
| #include "main.h" | ||||
| 
 | ||||
| typedef enum { | ||||
|     GpioModeInput, | ||||
|     GpioModeOutput, | ||||
|     GpioModeOpenDrain | ||||
| } GpioMode; | ||||
| typedef enum { GpioModeInput, GpioModeOutput, GpioModeOpenDrain } GpioMode; | ||||
| 
 | ||||
| typedef struct { | ||||
|     GPIO_TypeDef* port; | ||||
| @ -50,7 +46,8 @@ inline void app_tim_ic_init(bool both) { | ||||
|     HAL_TIM_OC_Stop(&htim8, TIM_CHANNEL_2); | ||||
| 
 | ||||
|     TIM_IC_InitTypeDef sConfigIC = {0}; | ||||
|     sConfigIC.ICPolarity = both ? TIM_INPUTCHANNELPOLARITY_BOTHEDGE : TIM_INPUTCHANNELPOLARITY_FALLING; | ||||
|     sConfigIC.ICPolarity = both ? TIM_INPUTCHANNELPOLARITY_BOTHEDGE : | ||||
|                                   TIM_INPUTCHANNELPOLARITY_FALLING; | ||||
|     sConfigIC.ICSelection = TIM_ICSELECTION_DIRECTTI; | ||||
|     sConfigIC.ICPrescaler = TIM_ICPSC_DIV1; | ||||
|     sConfigIC.ICFilter = 0; | ||||
|  | ||||
| @ -38,10 +38,7 @@ extern "C" { | ||||
| /* Exported types ------------------------------------------------------------*/ | ||||
| /* USER CODE BEGIN ET */ | ||||
| 
 | ||||
| typedef enum { | ||||
|   TimerEventInputCapture, | ||||
|   TimerEventEndOfPulse | ||||
| } TimerEvent; | ||||
| typedef enum { TimerEventInputCapture, TimerEventEndOfPulse } TimerEvent; | ||||
| 
 | ||||
| /* USER CODE END ET */ | ||||
| 
 | ||||
| @ -55,14 +52,14 @@ typedef enum { | ||||
| 
 | ||||
| /* USER CODE END EM */ | ||||
| 
 | ||||
| void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim); | ||||
| void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim); | ||||
| 
 | ||||
| /* Exported functions prototypes ---------------------------------------------*/ | ||||
| void Error_Handler(void); | ||||
| 
 | ||||
| /* USER CODE BEGIN EFP */ | ||||
| 
 | ||||
| void register_tim8_callback_ch2(void(*callback)(uint16_t ccr, TimerEvent tim_event)); | ||||
| void register_tim8_callback_ch2(void (*callback)(uint16_t ccr, TimerEvent tim_event)); | ||||
| 
 | ||||
| /* USER CODE END EFP */ | ||||
| 
 | ||||
| @ -138,12 +135,24 @@ void register_tim8_callback_ch2(void(*callback)(uint16_t ccr, TimerEvent tim_eve | ||||
| #define EM_PIN_GPIO_Port RFID_OUT_GPIO_Port | ||||
| #define EM_PIN_Pin RFID_OUT_Pin | ||||
| 
 | ||||
| #define MISO_PIN GpioPin{.port = GPIOC, .pin = GPIO_PIN_11} | ||||
| #define MISO_PIN                          \ | ||||
|     GpioPin {                             \ | ||||
|         .port = GPIOC, .pin = GPIO_PIN_11 \ | ||||
|     } | ||||
| // #define MOSI_PIN 11
 | ||||
| #define SS_PIN   GpioPin{.port = CC1101_CS_GPIO_Port, .pin = CC1101_CS_Pin} | ||||
| #define SS_PIN                                            \ | ||||
|     GpioPin {                                             \ | ||||
|         .port = CC1101_CS_GPIO_Port, .pin = CC1101_CS_Pin \ | ||||
|     } | ||||
| //2 main, 5 remote, 3 M16
 | ||||
| #define GDO2     GpioPin{.port = NULL, .pin = 0} | ||||
| #define GDO0     GpioPin{.port = CC1101_G0_GPIO_Port, .pin = CC1101_G0_Pin} | ||||
| #define GDO2                   \ | ||||
|     GpioPin {                  \ | ||||
|         .port = NULL, .pin = 0 \ | ||||
|     } | ||||
| #define GDO0                                              \ | ||||
|     GpioPin {                                             \ | ||||
|         .port = CC1101_G0_GPIO_Port, .pin = CC1101_G0_Pin \ | ||||
|     } | ||||
| 
 | ||||
| /* USER CODE END Private defines */ | ||||
| 
 | ||||
|  | ||||
| @ -37,7 +37,7 @@ | ||||
| #define __STM32L4xx_HAL_CONF_H | ||||
| 
 | ||||
| #ifdef __cplusplus | ||||
|  extern "C" { | ||||
| extern "C" { | ||||
| #endif | ||||
| 
 | ||||
| /* Exported types ------------------------------------------------------------*/ | ||||
| @ -109,28 +109,28 @@ | ||||
|   *        This value is used by the RCC HAL module to compute the system frequency | ||||
|   *        (when HSE is used as system clock source, directly or through the PLL).   | ||||
|   */ | ||||
| #if !defined  (HSE_VALUE)  | ||||
|   #define HSE_VALUE    ((uint32_t)16000000U) /*!< Value of the External oscillator in Hz */ | ||||
| #if !defined(HSE_VALUE) | ||||
| #define HSE_VALUE ((uint32_t)16000000U) /*!< Value of the External oscillator in Hz */ | ||||
| #endif /* HSE_VALUE */ | ||||
| 
 | ||||
| #if !defined  (HSE_STARTUP_TIMEOUT) | ||||
|   #define HSE_STARTUP_TIMEOUT    ((uint32_t)100U)   /*!< Time out for HSE start up, in ms */ | ||||
| #if !defined(HSE_STARTUP_TIMEOUT) | ||||
| #define HSE_STARTUP_TIMEOUT ((uint32_t)100U) /*!< Time out for HSE start up, in ms */ | ||||
| #endif /* HSE_STARTUP_TIMEOUT */ | ||||
| 
 | ||||
| /**
 | ||||
|   * @brief Internal Multiple Speed oscillator (MSI) default value. | ||||
|   *        This value is the default MSI range value after Reset. | ||||
|   */ | ||||
| #if !defined  (MSI_VALUE) | ||||
|   #define MSI_VALUE    ((uint32_t)4000000U) /*!< Value of the Internal oscillator in Hz*/ | ||||
| #if !defined(MSI_VALUE) | ||||
| #define MSI_VALUE ((uint32_t)4000000U) /*!< Value of the Internal oscillator in Hz*/ | ||||
| #endif /* MSI_VALUE */ | ||||
| /**
 | ||||
|   * @brief Internal High Speed oscillator (HSI) value. | ||||
|   *        This value is used by the RCC HAL module to compute the system frequency | ||||
|   *        (when HSI is used as system clock source, directly or through the PLL).  | ||||
|   */ | ||||
| #if !defined  (HSI_VALUE) | ||||
|   #define HSI_VALUE    ((uint32_t)16000000U) /*!< Value of the Internal oscillator in Hz*/ | ||||
| #if !defined(HSI_VALUE) | ||||
| #define HSI_VALUE ((uint32_t)16000000U) /*!< Value of the Internal oscillator in Hz*/ | ||||
| #endif /* HSI_VALUE */ | ||||
| 
 | ||||
| /**
 | ||||
| @ -140,17 +140,18 @@ | ||||
|   *        When the CRS is not used, the HSI48 RC oscillator runs on it default frequency | ||||
|   *        which is subject to manufacturing process variations. | ||||
|   */ | ||||
| #if !defined  (HSI48_VALUE)  | ||||
|  #define HSI48_VALUE   ((uint32_t)48000000U) /*!< Value of the Internal High Speed oscillator for USB FS/SDMMC/RNG in Hz. | ||||
| #if !defined(HSI48_VALUE) | ||||
| #define HSI48_VALUE \ | ||||
|     ((uint32_t)48000000U) /*!< Value of the Internal High Speed oscillator for USB FS/SDMMC/RNG in Hz.
 | ||||
|                                               The real value my vary depending on manufacturing process variations.*/ | ||||
| #endif /* HSI48_VALUE */ | ||||
| 
 | ||||
| /**
 | ||||
|   * @brief Internal Low Speed oscillator (LSI) value. | ||||
|   */ | ||||
| #if !defined  (LSI_VALUE)  | ||||
|  #define LSI_VALUE  ((uint32_t)32000U)       /*!< LSI Typical Value in Hz*/ | ||||
| #endif /* LSI_VALUE */                      /*!< Value of the Internal Low Speed oscillator in Hz | ||||
| #if !defined(LSI_VALUE) | ||||
| #define LSI_VALUE ((uint32_t)32000U) /*!< LSI Typical Value in Hz*/ | ||||
| #endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz | ||||
|                                              The real value may vary depending on the variations | ||||
|                                              in voltage and temperature.*/ | ||||
| 
 | ||||
| @ -158,12 +159,12 @@ | ||||
|   * @brief External Low Speed oscillator (LSE) value. | ||||
|   *        This value is used by the UART, RTC HAL module to compute the system frequency | ||||
|   */ | ||||
| #if !defined  (LSE_VALUE) | ||||
|   #define LSE_VALUE    ((uint32_t)32768U) /*!< Value of the External oscillator in Hz*/ | ||||
| #if !defined(LSE_VALUE) | ||||
| #define LSE_VALUE ((uint32_t)32768U) /*!< Value of the External oscillator in Hz*/ | ||||
| #endif /* LSE_VALUE */ | ||||
| 
 | ||||
| #if !defined  (LSE_STARTUP_TIMEOUT) | ||||
|   #define LSE_STARTUP_TIMEOUT    ((uint32_t)5000U)   /*!< Time out for LSE start up, in ms */ | ||||
| #if !defined(LSE_STARTUP_TIMEOUT) | ||||
| #define LSE_STARTUP_TIMEOUT ((uint32_t)5000U) /*!< Time out for LSE start up, in ms */ | ||||
| #endif /* HSE_STARTUP_TIMEOUT */ | ||||
| 
 | ||||
| /**
 | ||||
| @ -171,8 +172,9 @@ | ||||
|   *        This value is used by the RCC HAL module to compute the SAI1 & SAI2 clock source  | ||||
|   *        frequency. | ||||
|   */ | ||||
| #if !defined  (EXTERNAL_SAI1_CLOCK_VALUE) | ||||
|   #define EXTERNAL_SAI1_CLOCK_VALUE    ((uint32_t)2097000U) /*!< Value of the SAI1 External clock source in Hz*/ | ||||
| #if !defined(EXTERNAL_SAI1_CLOCK_VALUE) | ||||
| #define EXTERNAL_SAI1_CLOCK_VALUE \ | ||||
|     ((uint32_t)2097000U) /*!< Value of the SAI1 External clock source in Hz*/ | ||||
| #endif /* EXTERNAL_SAI1_CLOCK_VALUE */ | ||||
| 
 | ||||
| /**
 | ||||
| @ -180,8 +182,9 @@ | ||||
|   *        This value is used by the RCC HAL module to compute the SAI1 & SAI2 clock source  | ||||
|   *        frequency. | ||||
|   */ | ||||
| #if !defined  (EXTERNAL_SAI2_CLOCK_VALUE) | ||||
|   #define EXTERNAL_SAI2_CLOCK_VALUE    ((uint32_t)2097000U) /*!< Value of the SAI2 External clock source in Hz*/ | ||||
| #if !defined(EXTERNAL_SAI2_CLOCK_VALUE) | ||||
| #define EXTERNAL_SAI2_CLOCK_VALUE \ | ||||
|     ((uint32_t)2097000U) /*!< Value of the SAI2 External clock source in Hz*/ | ||||
| #endif /* EXTERNAL_SAI2_CLOCK_VALUE */ | ||||
| 
 | ||||
| /* Tip: To avoid modifying this file each time you need to use different HSE,
 | ||||
| @ -192,12 +195,12 @@ | ||||
|   * @brief This is the HAL system configuration section | ||||
|   */ | ||||
| 
 | ||||
| #define  VDD_VALUE					  ((uint32_t)3300U) /*!< Value of VDD in mv */            | ||||
| #define  TICK_INT_PRIORITY            ((uint32_t)15U)    /*!< tick interrupt priority */             | ||||
| #define  USE_RTOS                     0U      | ||||
| #define  PREFETCH_ENABLE              1U | ||||
| #define  INSTRUCTION_CACHE_ENABLE     1U | ||||
| #define  DATA_CACHE_ENABLE            1U | ||||
| #define VDD_VALUE ((uint32_t)3300U) /*!< Value of VDD in mv */ | ||||
| #define TICK_INT_PRIORITY ((uint32_t)15U) /*!< tick interrupt priority */ | ||||
| #define USE_RTOS 0U | ||||
| #define PREFETCH_ENABLE 1U | ||||
| #define INSTRUCTION_CACHE_ENABLE 1U | ||||
| #define DATA_CACHE_ENABLE 1U | ||||
| 
 | ||||
| /* ########################## Assert Selection ############################## */ | ||||
| /**
 | ||||
| @ -213,7 +216,7 @@ | ||||
|  * Deactivated: CRC code cleaned from driver | ||||
|  */ | ||||
| 
 | ||||
| #define USE_SPI_CRC                   0U | ||||
| #define USE_SPI_CRC 0U | ||||
| 
 | ||||
| /* Includes ------------------------------------------------------------------*/ | ||||
| /**
 | ||||
| @ -221,201 +224,201 @@ | ||||
|   */ | ||||
| 
 | ||||
| #ifdef HAL_RCC_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_rcc.h" | ||||
|   #include "stm32l4xx_hal_rcc_ex.h" | ||||
| #include "stm32l4xx_hal_rcc.h" | ||||
| #include "stm32l4xx_hal_rcc_ex.h" | ||||
| #endif /* HAL_RCC_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_EXTI_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_exti.h" | ||||
| #include "stm32l4xx_hal_exti.h" | ||||
| #endif /* HAL_EXTI_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_GPIO_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_gpio.h" | ||||
| #include "stm32l4xx_hal_gpio.h" | ||||
| #endif /* HAL_GPIO_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_DMA_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_dma.h" | ||||
|   #include "stm32l4xx_hal_dma_ex.h" | ||||
| #include "stm32l4xx_hal_dma.h" | ||||
| #include "stm32l4xx_hal_dma_ex.h" | ||||
| #endif /* HAL_DMA_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_DFSDM_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_dfsdm.h" | ||||
| #include "stm32l4xx_hal_dfsdm.h" | ||||
| #endif /* HAL_DFSDM_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_CORTEX_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_cortex.h" | ||||
| #include "stm32l4xx_hal_cortex.h" | ||||
| #endif /* HAL_CORTEX_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_ADC_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_adc.h" | ||||
| #include "stm32l4xx_hal_adc.h" | ||||
| #endif /* HAL_ADC_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_CAN_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_can.h" | ||||
| #include "stm32l4xx_hal_can.h" | ||||
| #endif /* HAL_CAN_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_COMP_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_comp.h" | ||||
| #include "stm32l4xx_hal_comp.h" | ||||
| #endif /* HAL_COMP_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_CRC_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_crc.h" | ||||
| #include "stm32l4xx_hal_crc.h" | ||||
| #endif /* HAL_CRC_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_CRYP_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_cryp.h" | ||||
| #include "stm32l4xx_hal_cryp.h" | ||||
| #endif /* HAL_CRYP_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_DAC_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_dac.h" | ||||
| #include "stm32l4xx_hal_dac.h" | ||||
| #endif /* HAL_DAC_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_DCMI_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_dcmi.h" | ||||
| #include "stm32l4xx_hal_dcmi.h" | ||||
| #endif /* HAL_DCMI_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_DMA2D_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_dma2d.h" | ||||
| #include "stm32l4xx_hal_dma2d.h" | ||||
| #endif /* HAL_DMA2D_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_DSI_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_dsi.h" | ||||
| #include "stm32l4xx_hal_dsi.h" | ||||
| #endif /* HAL_DSI_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_FIREWALL_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_firewall.h" | ||||
| #include "stm32l4xx_hal_firewall.h" | ||||
| #endif /* HAL_FIREWALL_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_FLASH_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_flash.h" | ||||
| #include "stm32l4xx_hal_flash.h" | ||||
| #endif /* HAL_FLASH_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_HASH_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_hash.h" | ||||
| #include "stm32l4xx_hal_hash.h" | ||||
| #endif /* HAL_HASH_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_SRAM_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_sram.h" | ||||
| #include "stm32l4xx_hal_sram.h" | ||||
| #endif /* HAL_SRAM_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_MMC_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_mmc.h" | ||||
| #include "stm32l4xx_hal_mmc.h" | ||||
| #endif /* HAL_MMC_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_NOR_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_nor.h" | ||||
| #include "stm32l4xx_hal_nor.h" | ||||
| #endif /* HAL_NOR_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_NAND_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_nand.h" | ||||
| #include "stm32l4xx_hal_nand.h" | ||||
| #endif /* HAL_NAND_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_I2C_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_i2c.h" | ||||
| #include "stm32l4xx_hal_i2c.h" | ||||
| #endif /* HAL_I2C_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_IWDG_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_iwdg.h" | ||||
| #include "stm32l4xx_hal_iwdg.h" | ||||
| #endif /* HAL_IWDG_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_LCD_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_lcd.h" | ||||
| #include "stm32l4xx_hal_lcd.h" | ||||
| #endif /* HAL_LCD_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_LPTIM_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_lptim.h" | ||||
| #include "stm32l4xx_hal_lptim.h" | ||||
| #endif /* HAL_LPTIM_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_LTDC_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_ltdc.h" | ||||
| #include "stm32l4xx_hal_ltdc.h" | ||||
| #endif /* HAL_LTDC_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_OPAMP_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_opamp.h" | ||||
| #include "stm32l4xx_hal_opamp.h" | ||||
| #endif /* HAL_OPAMP_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_OSPI_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_ospi.h" | ||||
| #include "stm32l4xx_hal_ospi.h" | ||||
| #endif /* HAL_OSPI_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_PWR_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_pwr.h" | ||||
| #include "stm32l4xx_hal_pwr.h" | ||||
| #endif /* HAL_PWR_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_QSPI_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_qspi.h" | ||||
| #include "stm32l4xx_hal_qspi.h" | ||||
| #endif /* HAL_QSPI_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_RNG_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_rng.h" | ||||
| #include "stm32l4xx_hal_rng.h" | ||||
| #endif /* HAL_RNG_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_RTC_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_rtc.h" | ||||
| #include "stm32l4xx_hal_rtc.h" | ||||
| #endif /* HAL_RTC_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_SAI_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_sai.h" | ||||
| #include "stm32l4xx_hal_sai.h" | ||||
| #endif /* HAL_SAI_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_SD_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_sd.h" | ||||
| #include "stm32l4xx_hal_sd.h" | ||||
| #endif /* HAL_SD_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_SMBUS_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_smbus.h" | ||||
| #include "stm32l4xx_hal_smbus.h" | ||||
| #endif /* HAL_SMBUS_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_SPI_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_spi.h" | ||||
| #include "stm32l4xx_hal_spi.h" | ||||
| #endif /* HAL_SPI_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_SWPMI_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_swpmi.h" | ||||
| #include "stm32l4xx_hal_swpmi.h" | ||||
| #endif /* HAL_SWPMI_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_TIM_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_tim.h" | ||||
| #include "stm32l4xx_hal_tim.h" | ||||
| #endif /* HAL_TIM_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_TSC_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_tsc.h" | ||||
| #include "stm32l4xx_hal_tsc.h" | ||||
| #endif /* HAL_TSC_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_UART_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_uart.h" | ||||
| #include "stm32l4xx_hal_uart.h" | ||||
| #endif /* HAL_UART_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_USART_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_usart.h" | ||||
| #include "stm32l4xx_hal_usart.h" | ||||
| #endif /* HAL_USART_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_IRDA_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_irda.h" | ||||
| #include "stm32l4xx_hal_irda.h" | ||||
| #endif /* HAL_IRDA_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_SMARTCARD_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_smartcard.h" | ||||
| #include "stm32l4xx_hal_smartcard.h" | ||||
| #endif /* HAL_SMARTCARD_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_WWDG_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_wwdg.h" | ||||
| #include "stm32l4xx_hal_wwdg.h" | ||||
| #endif /* HAL_WWDG_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_PCD_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_pcd.h" | ||||
| #include "stm32l4xx_hal_pcd.h" | ||||
| #endif /* HAL_PCD_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_HCD_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_hcd.h" | ||||
| #include "stm32l4xx_hal_hcd.h" | ||||
| #endif /* HAL_HCD_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_GFXMMU_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_gfxmmu.h" | ||||
| #include "stm32l4xx_hal_gfxmmu.h" | ||||
| #endif /* HAL_GFXMMU_MODULE_ENABLED */ | ||||
| 
 | ||||
| /* Exported macro ------------------------------------------------------------*/ | ||||
| #ifdef  USE_FULL_ASSERT | ||||
| #ifdef USE_FULL_ASSERT | ||||
| /**
 | ||||
|   * @brief  The assert_param macro is used for function's parameters check. | ||||
|   * @param  expr: If expr is false, it calls assert_failed function | ||||
| @ -424,11 +427,11 @@ | ||||
|   *         If expr is true, it returns no value. | ||||
|   * @retval None | ||||
|   */ | ||||
|   #define assert_param(expr) ((expr) ? (void)0U : assert_failed((char *)__FILE__, __LINE__)) | ||||
| #define assert_param(expr) ((expr) ? (void)0U : assert_failed((char*)__FILE__, __LINE__)) | ||||
| /* Exported functions ------------------------------------------------------- */ | ||||
|   void assert_failed(char *file, uint32_t line); | ||||
| void assert_failed(char* file, uint32_t line); | ||||
| #else | ||||
|   #define assert_param(expr) ((void)0U) | ||||
| #define assert_param(expr) ((void)0U) | ||||
| #endif /* USE_FULL_ASSERT */ | ||||
| 
 | ||||
| #ifdef __cplusplus | ||||
|  | ||||
| @ -23,7 +23,7 @@ | ||||
| #define __STM32L4xx_IT_H | ||||
| 
 | ||||
| #ifdef __cplusplus | ||||
|  extern "C" { | ||||
| extern "C" { | ||||
| #endif | ||||
| 
 | ||||
| /* Private includes ----------------------------------------------------------*/ | ||||
|  | ||||
| @ -24,7 +24,7 @@ | ||||
| #define __USB_DEVICE__H__ | ||||
| 
 | ||||
| #ifdef __cplusplus | ||||
|  extern "C" { | ||||
| extern "C" { | ||||
| #endif | ||||
| 
 | ||||
| /* Includes ------------------------------------------------------------------*/ | ||||
|  | ||||
| @ -24,7 +24,7 @@ | ||||
| #define __USBD_CDC_IF_H__ | ||||
| 
 | ||||
| #ifdef __cplusplus | ||||
|  extern "C" { | ||||
| extern "C" { | ||||
| #endif | ||||
| 
 | ||||
| /* Includes ------------------------------------------------------------------*/ | ||||
|  | ||||
| @ -24,7 +24,7 @@ | ||||
| #define __USBD_CONF__H__ | ||||
| 
 | ||||
| #ifdef __cplusplus | ||||
|  extern "C" { | ||||
| extern "C" { | ||||
| #endif | ||||
| 
 | ||||
| /* Includes ------------------------------------------------------------------*/ | ||||
| @ -61,21 +61,21 @@ | ||||
|   */ | ||||
| 
 | ||||
| /*---------- -----------*/ | ||||
| #define USBD_MAX_NUM_INTERFACES     1U | ||||
| #define USBD_MAX_NUM_INTERFACES 1U | ||||
| /*---------- -----------*/ | ||||
| #define USBD_MAX_NUM_CONFIGURATION     1U | ||||
| #define USBD_MAX_NUM_CONFIGURATION 1U | ||||
| /*---------- -----------*/ | ||||
| #define USBD_MAX_STR_DESC_SIZ     512U | ||||
| #define USBD_MAX_STR_DESC_SIZ 512U | ||||
| /*---------- -----------*/ | ||||
| #define USBD_DEBUG_LEVEL     0U | ||||
| #define USBD_DEBUG_LEVEL 0U | ||||
| /*---------- -----------*/ | ||||
| #define USBD_LPM_ENABLED     1U | ||||
| #define USBD_LPM_ENABLED 1U | ||||
| /*---------- -----------*/ | ||||
| #define USBD_SELF_POWERED     1U | ||||
| #define USBD_SELF_POWERED 1U | ||||
| 
 | ||||
| /****************************************/ | ||||
| /* #define for FS and HS identification */ | ||||
| #define DEVICE_FS 		0 | ||||
| #define DEVICE_FS 0 | ||||
| 
 | ||||
| /**
 | ||||
|   * @} | ||||
| @ -89,42 +89,45 @@ | ||||
| /* Memory management macros */ | ||||
| 
 | ||||
| /** Alias for memory allocation. */ | ||||
| #define USBD_malloc         (uint32_t *)USBD_static_malloc | ||||
| #define USBD_malloc (uint32_t*)USBD_static_malloc | ||||
| 
 | ||||
| /** Alias for memory release. */ | ||||
| #define USBD_free           USBD_static_free | ||||
| #define USBD_free USBD_static_free | ||||
| 
 | ||||
| /** Alias for memory set. */ | ||||
| #define USBD_memset         /* Not used */ | ||||
| #define USBD_memset /* Not used */ | ||||
| 
 | ||||
| /** Alias for memory copy. */ | ||||
| #define USBD_memcpy         /* Not used */ | ||||
| #define USBD_memcpy /* Not used */ | ||||
| 
 | ||||
| /** Alias for delay. */ | ||||
| #define USBD_Delay          HAL_Delay | ||||
| #define USBD_Delay HAL_Delay | ||||
| 
 | ||||
| /* DEBUG macros */ | ||||
| 
 | ||||
| #if (USBD_DEBUG_LEVEL > 0) | ||||
| #define USBD_UsrLog(...)    printf(__VA_ARGS__);\ | ||||
|                             printf("\n"); | ||||
| #if(USBD_DEBUG_LEVEL > 0) | ||||
| #define USBD_UsrLog(...) \ | ||||
|     printf(__VA_ARGS__); \ | ||||
|     printf("\n"); | ||||
| #else | ||||
| #define USBD_UsrLog(...) | ||||
| #endif | ||||
| 
 | ||||
| #if (USBD_DEBUG_LEVEL > 1) | ||||
| #if(USBD_DEBUG_LEVEL > 1) | ||||
| 
 | ||||
| #define USBD_ErrLog(...)    printf("ERROR: ") ;\ | ||||
|                             printf(__VA_ARGS__);\ | ||||
|                             printf("\n"); | ||||
| #define USBD_ErrLog(...) \ | ||||
|     printf("ERROR: ");   \ | ||||
|     printf(__VA_ARGS__); \ | ||||
|     printf("\n"); | ||||
| #else | ||||
| #define USBD_ErrLog(...) | ||||
| #endif | ||||
| 
 | ||||
| #if (USBD_DEBUG_LEVEL > 2) | ||||
| #define USBD_DbgLog(...)    printf("DEBUG : ") ;\ | ||||
|                             printf(__VA_ARGS__);\ | ||||
|                             printf("\n"); | ||||
| #if(USBD_DEBUG_LEVEL > 2) | ||||
| #define USBD_DbgLog(...) \ | ||||
|     printf("DEBUG : ");  \ | ||||
|     printf(__VA_ARGS__); \ | ||||
|     printf("\n"); | ||||
| #else | ||||
| #define USBD_DbgLog(...) | ||||
| #endif | ||||
| @ -148,8 +151,8 @@ | ||||
|   */ | ||||
| 
 | ||||
| /* Exported functions -------------------------------------------------------*/ | ||||
| void *USBD_static_malloc(uint32_t size); | ||||
| void USBD_static_free(void *p); | ||||
| void* USBD_static_malloc(uint32_t size); | ||||
| void USBD_static_free(void* p); | ||||
| 
 | ||||
| /**
 | ||||
|   * @} | ||||
|  | ||||
| @ -23,7 +23,7 @@ | ||||
| #define __USBD_DESC__C__ | ||||
| 
 | ||||
| #ifdef __cplusplus | ||||
|  extern "C" { | ||||
| extern "C" { | ||||
| #endif | ||||
| 
 | ||||
| /* Includes ------------------------------------------------------------------*/ | ||||
| @ -46,11 +46,11 @@ | ||||
|   * @brief Constants. | ||||
|   * @{ | ||||
|   */ | ||||
| #define         DEVICE_ID1          (UID_BASE) | ||||
| #define         DEVICE_ID2          (UID_BASE + 0x4) | ||||
| #define         DEVICE_ID3          (UID_BASE + 0x8) | ||||
| #define DEVICE_ID1 (UID_BASE) | ||||
| #define DEVICE_ID2 (UID_BASE + 0x4) | ||||
| #define DEVICE_ID3 (UID_BASE + 0x8) | ||||
| 
 | ||||
| #define  USB_SIZ_STRING_SERIAL       0x1A | ||||
| #define USB_SIZ_STRING_SERIAL 0x1A | ||||
| 
 | ||||
| /* USER CODE BEGIN EXPORTED_CONSTANTS */ | ||||
| 
 | ||||
|  | ||||
| @ -15,18 +15,18 @@ void app_gpio_init(GpioPin gpio, GpioMode mode) { | ||||
|         GPIO_InitStruct.Pull = GPIO_NOPULL; | ||||
| 
 | ||||
|         switch(mode) { | ||||
|             case GpioModeInput: | ||||
|                 GPIO_InitStruct.Mode = GPIO_MODE_INPUT; | ||||
|         case GpioModeInput: | ||||
|             GPIO_InitStruct.Mode = GPIO_MODE_INPUT; | ||||
|             break; | ||||
| 
 | ||||
|             case GpioModeOutput:  | ||||
|                 GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; | ||||
|                 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM; | ||||
|         case GpioModeOutput: | ||||
|             GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; | ||||
|             GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM; | ||||
|             break; | ||||
| 
 | ||||
|             case GpioModeOpenDrain: | ||||
|                 GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_OD; | ||||
|                 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM; | ||||
|         case GpioModeOpenDrain: | ||||
|             GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_OD; | ||||
|             GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM; | ||||
|             break; | ||||
|         } | ||||
| 
 | ||||
| @ -36,14 +36,15 @@ void app_gpio_init(GpioPin gpio, GpioMode mode) { | ||||
| 
 | ||||
| // TODO delay from timer
 | ||||
| void delay_us(uint32_t time) { | ||||
|   time *= 11.8; | ||||
|     time *= 11.8; | ||||
| 
 | ||||
|   while(time--) {} | ||||
|     while(time--) { | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void pwm_set(float value, float freq, TIM_HandleTypeDef* tim, uint32_t channel) { | ||||
|     tim->Init.CounterMode = TIM_COUNTERMODE_UP; | ||||
|     tim->Init.Period = (uint32_t)((SystemCoreClock/tim->Init.Prescaler)/freq); | ||||
|     tim->Init.Period = (uint32_t)((SystemCoreClock / tim->Init.Prescaler) / freq); | ||||
|     tim->Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; | ||||
|     tim->Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; | ||||
|     HAL_TIM_PWM_Init(tim); | ||||
|  | ||||
| @ -55,18 +55,21 @@ | ||||
| /* USER CODE END FunctionPrototypes */ | ||||
| 
 | ||||
| /* GetIdleTaskMemory prototype (linked to static allocation support) */ | ||||
| void vApplicationGetIdleTaskMemory( StaticTask_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize ); | ||||
| void vApplicationGetIdleTaskMemory(StaticTask_t** ppxIdleTaskTCBBuffer, | ||||
|                                    StackType_t** ppxIdleTaskStackBuffer, | ||||
|                                    uint32_t* pulIdleTaskStackSize); | ||||
| 
 | ||||
| /* GetTimerTaskMemory prototype (linked to static allocation support) */ | ||||
| void vApplicationGetTimerTaskMemory( StaticTask_t **ppxTimerTaskTCBBuffer, StackType_t **ppxTimerTaskStackBuffer, uint32_t *pulTimerTaskStackSize ); | ||||
| void vApplicationGetTimerTaskMemory(StaticTask_t** ppxTimerTaskTCBBuffer, | ||||
|                                     StackType_t** ppxTimerTaskStackBuffer, | ||||
|                                     uint32_t* pulTimerTaskStackSize); | ||||
| 
 | ||||
| /* Hook prototypes */ | ||||
| void vApplicationIdleHook(void); | ||||
| 
 | ||||
| /* USER CODE BEGIN 2 */ | ||||
| __weak void vApplicationIdleHook( void ) | ||||
| { | ||||
|    /* vApplicationIdleHook() will only be called if configUSE_IDLE_HOOK is set
 | ||||
| __weak void vApplicationIdleHook(void) { | ||||
|     /* vApplicationIdleHook() will only be called if configUSE_IDLE_HOOK is set
 | ||||
|    to 1 in FreeRTOSConfig.h. It will be called on each iteration of the idle | ||||
|    task. It is essential that code added to this hook function never attempts | ||||
|    to block in any way (for example, call xQueueReceive() with a block time | ||||
| @ -82,12 +85,13 @@ __weak void vApplicationIdleHook( void ) | ||||
| static StaticTask_t xIdleTaskTCBBuffer; | ||||
| static StackType_t xIdleStack[configMINIMAL_STACK_SIZE]; | ||||
| 
 | ||||
| void vApplicationGetIdleTaskMemory( StaticTask_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize ) | ||||
| { | ||||
|   *ppxIdleTaskTCBBuffer = &xIdleTaskTCBBuffer; | ||||
|   *ppxIdleTaskStackBuffer = &xIdleStack[0]; | ||||
|   *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE; | ||||
|   /* place for user code */ | ||||
| void vApplicationGetIdleTaskMemory(StaticTask_t** ppxIdleTaskTCBBuffer, | ||||
|                                    StackType_t** ppxIdleTaskStackBuffer, | ||||
|                                    uint32_t* pulIdleTaskStackSize) { | ||||
|     *ppxIdleTaskTCBBuffer = &xIdleTaskTCBBuffer; | ||||
|     *ppxIdleTaskStackBuffer = &xIdleStack[0]; | ||||
|     *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE; | ||||
|     /* place for user code */ | ||||
| } | ||||
| /* USER CODE END GET_IDLE_TASK_MEMORY */ | ||||
| 
 | ||||
| @ -95,12 +99,13 @@ void vApplicationGetIdleTaskMemory( StaticTask_t **ppxIdleTaskTCBBuffer, StackTy | ||||
| static StaticTask_t xTimerTaskTCBBuffer; | ||||
| static StackType_t xTimerStack[configTIMER_TASK_STACK_DEPTH]; | ||||
| 
 | ||||
| void vApplicationGetTimerTaskMemory( StaticTask_t **ppxTimerTaskTCBBuffer, StackType_t **ppxTimerTaskStackBuffer, uint32_t *pulTimerTaskStackSize )   | ||||
| { | ||||
|   *ppxTimerTaskTCBBuffer = &xTimerTaskTCBBuffer; | ||||
|   *ppxTimerTaskStackBuffer = &xTimerStack[0]; | ||||
|   *pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH; | ||||
|   /* place for user code */ | ||||
| void vApplicationGetTimerTaskMemory(StaticTask_t** ppxTimerTaskTCBBuffer, | ||||
|                                     StackType_t** ppxTimerTaskStackBuffer, | ||||
|                                     uint32_t* pulTimerTaskStackSize) { | ||||
|     *ppxTimerTaskTCBBuffer = &xTimerTaskTCBBuffer; | ||||
|     *ppxTimerTaskStackBuffer = &xTimerStack[0]; | ||||
|     *pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH; | ||||
|     /* place for user code */ | ||||
| } | ||||
| /* USER CODE END GET_TIMER_TASK_MEMORY */ | ||||
| 
 | ||||
|  | ||||
							
								
								
									
										1059
									
								
								target_f1/Src/main.c
									
									
									
									
									
								
							
							
						
						
									
										1059
									
								
								target_f1/Src/main.c
									
									
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @ -59,26 +59,25 @@ | ||||
| 
 | ||||
| /* USER CODE END 0 */ | ||||
| 
 | ||||
| void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim); | ||||
|                                         /**
 | ||||
| void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim); | ||||
| /**
 | ||||
|   * Initializes the Global MSP. | ||||
|   */ | ||||
| void HAL_MspInit(void) | ||||
| { | ||||
|   /* USER CODE BEGIN MspInit 0 */ | ||||
| void HAL_MspInit(void) { | ||||
|     /* USER CODE BEGIN MspInit 0 */ | ||||
| 
 | ||||
|   /* USER CODE END MspInit 0 */ | ||||
|     /* USER CODE END MspInit 0 */ | ||||
| 
 | ||||
|   __HAL_RCC_SYSCFG_CLK_ENABLE(); | ||||
|   __HAL_RCC_PWR_CLK_ENABLE(); | ||||
|     __HAL_RCC_SYSCFG_CLK_ENABLE(); | ||||
|     __HAL_RCC_PWR_CLK_ENABLE(); | ||||
| 
 | ||||
|   /* System interrupt init*/ | ||||
|   /* PendSV_IRQn interrupt configuration */ | ||||
|   HAL_NVIC_SetPriority(PendSV_IRQn, 15, 0); | ||||
|     /* System interrupt init*/ | ||||
|     /* PendSV_IRQn interrupt configuration */ | ||||
|     HAL_NVIC_SetPriority(PendSV_IRQn, 15, 0); | ||||
| 
 | ||||
|   /* USER CODE BEGIN MspInit 1 */ | ||||
|     /* USER CODE BEGIN MspInit 1 */ | ||||
| 
 | ||||
|   /* USER CODE END MspInit 1 */ | ||||
|     /* USER CODE END MspInit 1 */ | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -87,38 +86,35 @@ void HAL_MspInit(void) | ||||
| * @param hadc: ADC handle pointer | ||||
| * @retval None | ||||
| */ | ||||
| void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc) | ||||
| { | ||||
|   GPIO_InitTypeDef GPIO_InitStruct = {0}; | ||||
|   if(hadc->Instance==ADC1) | ||||
|   { | ||||
|   /* USER CODE BEGIN ADC1_MspInit 0 */ | ||||
| void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc) { | ||||
|     GPIO_InitTypeDef GPIO_InitStruct = {0}; | ||||
|     if(hadc->Instance == ADC1) { | ||||
|         /* USER CODE BEGIN ADC1_MspInit 0 */ | ||||
| 
 | ||||
|   /* USER CODE END ADC1_MspInit 0 */ | ||||
|     /* Peripheral clock enable */ | ||||
|     __HAL_RCC_ADC_CLK_ENABLE(); | ||||
|         /* USER CODE END ADC1_MspInit 0 */ | ||||
|         /* Peripheral clock enable */ | ||||
|         __HAL_RCC_ADC_CLK_ENABLE(); | ||||
| 
 | ||||
|     __HAL_RCC_GPIOC_CLK_ENABLE(); | ||||
|     __HAL_RCC_GPIOA_CLK_ENABLE(); | ||||
|     /**ADC1 GPIO Configuration    
 | ||||
|         __HAL_RCC_GPIOC_CLK_ENABLE(); | ||||
|         __HAL_RCC_GPIOA_CLK_ENABLE(); | ||||
|         /**ADC1 GPIO Configuration    
 | ||||
|     PC3     ------> ADC1_IN4 | ||||
|     PA0     ------> ADC1_IN5  | ||||
|     */ | ||||
|     GPIO_InitStruct.Pin = BATT_V_Pin; | ||||
|     GPIO_InitStruct.Mode = GPIO_MODE_ANALOG_ADC_CONTROL; | ||||
|     GPIO_InitStruct.Pull = GPIO_NOPULL; | ||||
|     HAL_GPIO_Init(BATT_V_GPIO_Port, &GPIO_InitStruct); | ||||
|         GPIO_InitStruct.Pin = BATT_V_Pin; | ||||
|         GPIO_InitStruct.Mode = GPIO_MODE_ANALOG_ADC_CONTROL; | ||||
|         GPIO_InitStruct.Pull = GPIO_NOPULL; | ||||
|         HAL_GPIO_Init(BATT_V_GPIO_Port, &GPIO_InitStruct); | ||||
| 
 | ||||
|     GPIO_InitStruct.Pin = IR_RX_Pin; | ||||
|     GPIO_InitStruct.Mode = GPIO_MODE_ANALOG_ADC_CONTROL; | ||||
|     GPIO_InitStruct.Pull = GPIO_NOPULL; | ||||
|     HAL_GPIO_Init(IR_RX_GPIO_Port, &GPIO_InitStruct); | ||||
|         GPIO_InitStruct.Pin = IR_RX_Pin; | ||||
|         GPIO_InitStruct.Mode = GPIO_MODE_ANALOG_ADC_CONTROL; | ||||
|         GPIO_InitStruct.Pull = GPIO_NOPULL; | ||||
|         HAL_GPIO_Init(IR_RX_GPIO_Port, &GPIO_InitStruct); | ||||
| 
 | ||||
|   /* USER CODE BEGIN ADC1_MspInit 1 */ | ||||
| 
 | ||||
|   /* USER CODE END ADC1_MspInit 1 */ | ||||
|   } | ||||
|         /* USER CODE BEGIN ADC1_MspInit 1 */ | ||||
| 
 | ||||
|         /* USER CODE END ADC1_MspInit 1 */ | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -127,29 +123,26 @@ void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc) | ||||
| * @param hadc: ADC handle pointer | ||||
| * @retval None | ||||
| */ | ||||
| void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc) | ||||
| { | ||||
|   if(hadc->Instance==ADC1) | ||||
|   { | ||||
|   /* USER CODE BEGIN ADC1_MspDeInit 0 */ | ||||
| void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc) { | ||||
|     if(hadc->Instance == ADC1) { | ||||
|         /* USER CODE BEGIN ADC1_MspDeInit 0 */ | ||||
| 
 | ||||
|   /* USER CODE END ADC1_MspDeInit 0 */ | ||||
|     /* Peripheral clock disable */ | ||||
|     __HAL_RCC_ADC_CLK_DISABLE(); | ||||
|         /* USER CODE END ADC1_MspDeInit 0 */ | ||||
|         /* Peripheral clock disable */ | ||||
|         __HAL_RCC_ADC_CLK_DISABLE(); | ||||
| 
 | ||||
|     /**ADC1 GPIO Configuration    
 | ||||
|         /**ADC1 GPIO Configuration    
 | ||||
|     PC3     ------> ADC1_IN4 | ||||
|     PA0     ------> ADC1_IN5  | ||||
|     */ | ||||
|     HAL_GPIO_DeInit(BATT_V_GPIO_Port, BATT_V_Pin); | ||||
|         HAL_GPIO_DeInit(BATT_V_GPIO_Port, BATT_V_Pin); | ||||
| 
 | ||||
|     HAL_GPIO_DeInit(IR_RX_GPIO_Port, IR_RX_Pin); | ||||
|         HAL_GPIO_DeInit(IR_RX_GPIO_Port, IR_RX_Pin); | ||||
| 
 | ||||
|   /* USER CODE BEGIN ADC1_MspDeInit 1 */ | ||||
| 
 | ||||
|   /* USER CODE END ADC1_MspDeInit 1 */ | ||||
|   } | ||||
|         /* USER CODE BEGIN ADC1_MspDeInit 1 */ | ||||
| 
 | ||||
|         /* USER CODE END ADC1_MspDeInit 1 */ | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -158,29 +151,26 @@ void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc) | ||||
| * @param hcomp: COMP handle pointer | ||||
| * @retval None | ||||
| */ | ||||
| void HAL_COMP_MspInit(COMP_HandleTypeDef* hcomp) | ||||
| { | ||||
|   GPIO_InitTypeDef GPIO_InitStruct = {0}; | ||||
|   if(hcomp->Instance==COMP1) | ||||
|   { | ||||
|   /* USER CODE BEGIN COMP1_MspInit 0 */ | ||||
| void HAL_COMP_MspInit(COMP_HandleTypeDef* hcomp) { | ||||
|     GPIO_InitTypeDef GPIO_InitStruct = {0}; | ||||
|     if(hcomp->Instance == COMP1) { | ||||
|         /* USER CODE BEGIN COMP1_MspInit 0 */ | ||||
| 
 | ||||
|   /* USER CODE END COMP1_MspInit 0 */ | ||||
|         /* USER CODE END COMP1_MspInit 0 */ | ||||
| 
 | ||||
|     __HAL_RCC_GPIOC_CLK_ENABLE(); | ||||
|     /**COMP1 GPIO Configuration    
 | ||||
|         __HAL_RCC_GPIOC_CLK_ENABLE(); | ||||
|         /**COMP1 GPIO Configuration    
 | ||||
|     PC5     ------> COMP1_INP  | ||||
|     */ | ||||
|     GPIO_InitStruct.Pin = RFID_RF_IN_Pin; | ||||
|     GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; | ||||
|     GPIO_InitStruct.Pull = GPIO_NOPULL; | ||||
|     HAL_GPIO_Init(RFID_RF_IN_GPIO_Port, &GPIO_InitStruct); | ||||
|         GPIO_InitStruct.Pin = RFID_RF_IN_Pin; | ||||
|         GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; | ||||
|         GPIO_InitStruct.Pull = GPIO_NOPULL; | ||||
|         HAL_GPIO_Init(RFID_RF_IN_GPIO_Port, &GPIO_InitStruct); | ||||
| 
 | ||||
|   /* USER CODE BEGIN COMP1_MspInit 1 */ | ||||
| 
 | ||||
|   /* USER CODE END COMP1_MspInit 1 */ | ||||
|   } | ||||
|         /* USER CODE BEGIN COMP1_MspInit 1 */ | ||||
| 
 | ||||
|         /* USER CODE END COMP1_MspInit 1 */ | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -189,24 +179,21 @@ void HAL_COMP_MspInit(COMP_HandleTypeDef* hcomp) | ||||
| * @param hcomp: COMP handle pointer | ||||
| * @retval None | ||||
| */ | ||||
| void HAL_COMP_MspDeInit(COMP_HandleTypeDef* hcomp) | ||||
| { | ||||
|   if(hcomp->Instance==COMP1) | ||||
|   { | ||||
|   /* USER CODE BEGIN COMP1_MspDeInit 0 */ | ||||
| void HAL_COMP_MspDeInit(COMP_HandleTypeDef* hcomp) { | ||||
|     if(hcomp->Instance == COMP1) { | ||||
|         /* USER CODE BEGIN COMP1_MspDeInit 0 */ | ||||
| 
 | ||||
|   /* USER CODE END COMP1_MspDeInit 0 */ | ||||
|         /* USER CODE END COMP1_MspDeInit 0 */ | ||||
| 
 | ||||
|     /**COMP1 GPIO Configuration    
 | ||||
|         /**COMP1 GPIO Configuration    
 | ||||
|     PC5     ------> COMP1_INP  | ||||
|     */ | ||||
|     HAL_GPIO_DeInit(RFID_RF_IN_GPIO_Port, RFID_RF_IN_Pin); | ||||
|         HAL_GPIO_DeInit(RFID_RF_IN_GPIO_Port, RFID_RF_IN_Pin); | ||||
| 
 | ||||
|   /* USER CODE BEGIN COMP1_MspDeInit 1 */ | ||||
| 
 | ||||
|   /* USER CODE END COMP1_MspDeInit 1 */ | ||||
|   } | ||||
|         /* USER CODE BEGIN COMP1_MspDeInit 1 */ | ||||
| 
 | ||||
|         /* USER CODE END COMP1_MspDeInit 1 */ | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -215,31 +202,28 @@ void HAL_COMP_MspDeInit(COMP_HandleTypeDef* hcomp) | ||||
| * @param hdac: DAC handle pointer | ||||
| * @retval None | ||||
| */ | ||||
| void HAL_DAC_MspInit(DAC_HandleTypeDef* hdac) | ||||
| { | ||||
|   GPIO_InitTypeDef GPIO_InitStruct = {0}; | ||||
|   if(hdac->Instance==DAC1) | ||||
|   { | ||||
|   /* USER CODE BEGIN DAC1_MspInit 0 */ | ||||
| void HAL_DAC_MspInit(DAC_HandleTypeDef* hdac) { | ||||
|     GPIO_InitTypeDef GPIO_InitStruct = {0}; | ||||
|     if(hdac->Instance == DAC1) { | ||||
|         /* USER CODE BEGIN DAC1_MspInit 0 */ | ||||
| 
 | ||||
|   /* USER CODE END DAC1_MspInit 0 */ | ||||
|     /* Peripheral clock enable */ | ||||
|     __HAL_RCC_DAC1_CLK_ENABLE(); | ||||
|         /* USER CODE END DAC1_MspInit 0 */ | ||||
|         /* Peripheral clock enable */ | ||||
|         __HAL_RCC_DAC1_CLK_ENABLE(); | ||||
| 
 | ||||
|     __HAL_RCC_GPIOA_CLK_ENABLE(); | ||||
|     /**DAC1 GPIO Configuration    
 | ||||
|         __HAL_RCC_GPIOA_CLK_ENABLE(); | ||||
|         /**DAC1 GPIO Configuration    
 | ||||
|     PA4     ------> DAC1_OUT1  | ||||
|     */ | ||||
|     GPIO_InitStruct.Pin = RFID_REF_Pin; | ||||
|     GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; | ||||
|     GPIO_InitStruct.Pull = GPIO_NOPULL; | ||||
|     HAL_GPIO_Init(RFID_REF_GPIO_Port, &GPIO_InitStruct); | ||||
|         GPIO_InitStruct.Pin = RFID_REF_Pin; | ||||
|         GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; | ||||
|         GPIO_InitStruct.Pull = GPIO_NOPULL; | ||||
|         HAL_GPIO_Init(RFID_REF_GPIO_Port, &GPIO_InitStruct); | ||||
| 
 | ||||
|   /* USER CODE BEGIN DAC1_MspInit 1 */ | ||||
| 
 | ||||
|   /* USER CODE END DAC1_MspInit 1 */ | ||||
|   } | ||||
|         /* USER CODE BEGIN DAC1_MspInit 1 */ | ||||
| 
 | ||||
|         /* USER CODE END DAC1_MspInit 1 */ | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -248,26 +232,23 @@ void HAL_DAC_MspInit(DAC_HandleTypeDef* hdac) | ||||
| * @param hdac: DAC handle pointer | ||||
| * @retval None | ||||
| */ | ||||
| void HAL_DAC_MspDeInit(DAC_HandleTypeDef* hdac) | ||||
| { | ||||
|   if(hdac->Instance==DAC1) | ||||
|   { | ||||
|   /* USER CODE BEGIN DAC1_MspDeInit 0 */ | ||||
| void HAL_DAC_MspDeInit(DAC_HandleTypeDef* hdac) { | ||||
|     if(hdac->Instance == DAC1) { | ||||
|         /* USER CODE BEGIN DAC1_MspDeInit 0 */ | ||||
| 
 | ||||
|   /* USER CODE END DAC1_MspDeInit 0 */ | ||||
|     /* Peripheral clock disable */ | ||||
|     __HAL_RCC_DAC1_CLK_DISABLE(); | ||||
|         /* USER CODE END DAC1_MspDeInit 0 */ | ||||
|         /* Peripheral clock disable */ | ||||
|         __HAL_RCC_DAC1_CLK_DISABLE(); | ||||
| 
 | ||||
|     /**DAC1 GPIO Configuration    
 | ||||
|         /**DAC1 GPIO Configuration    
 | ||||
|     PA4     ------> DAC1_OUT1  | ||||
|     */ | ||||
|     HAL_GPIO_DeInit(RFID_REF_GPIO_Port, RFID_REF_Pin); | ||||
|         HAL_GPIO_DeInit(RFID_REF_GPIO_Port, RFID_REF_Pin); | ||||
| 
 | ||||
|   /* USER CODE BEGIN DAC1_MspDeInit 1 */ | ||||
| 
 | ||||
|   /* USER CODE END DAC1_MspDeInit 1 */ | ||||
|   } | ||||
|         /* USER CODE BEGIN DAC1_MspDeInit 1 */ | ||||
| 
 | ||||
|         /* USER CODE END DAC1_MspDeInit 1 */ | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -276,59 +257,54 @@ void HAL_DAC_MspDeInit(DAC_HandleTypeDef* hdac) | ||||
| * @param hspi: SPI handle pointer | ||||
| * @retval None | ||||
| */ | ||||
| void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi) | ||||
| { | ||||
|   GPIO_InitTypeDef GPIO_InitStruct = {0}; | ||||
|   if(hspi->Instance==SPI1) | ||||
|   { | ||||
|   /* USER CODE BEGIN SPI1_MspInit 0 */ | ||||
| void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi) { | ||||
|     GPIO_InitTypeDef GPIO_InitStruct = {0}; | ||||
|     if(hspi->Instance == SPI1) { | ||||
|         /* USER CODE BEGIN SPI1_MspInit 0 */ | ||||
| 
 | ||||
|   /* USER CODE END SPI1_MspInit 0 */ | ||||
|     /* Peripheral clock enable */ | ||||
|     __HAL_RCC_SPI1_CLK_ENABLE(); | ||||
|         /* USER CODE END SPI1_MspInit 0 */ | ||||
|         /* Peripheral clock enable */ | ||||
|         __HAL_RCC_SPI1_CLK_ENABLE(); | ||||
| 
 | ||||
|     __HAL_RCC_GPIOB_CLK_ENABLE(); | ||||
|     /**SPI1 GPIO Configuration    
 | ||||
|         __HAL_RCC_GPIOB_CLK_ENABLE(); | ||||
|         /**SPI1 GPIO Configuration    
 | ||||
|     PB3 (JTDO-TRACESWO)     ------> SPI1_SCK | ||||
|     PB5     ------> SPI1_MOSI  | ||||
|     */ | ||||
|     GPIO_InitStruct.Pin = GPIO_PIN_3|GPIO_PIN_5; | ||||
|     GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; | ||||
|     GPIO_InitStruct.Pull = GPIO_NOPULL; | ||||
|     GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; | ||||
|     GPIO_InitStruct.Alternate = GPIO_AF5_SPI1; | ||||
|     HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); | ||||
|         GPIO_InitStruct.Pin = GPIO_PIN_3 | GPIO_PIN_5; | ||||
|         GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; | ||||
|         GPIO_InitStruct.Pull = GPIO_NOPULL; | ||||
|         GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; | ||||
|         GPIO_InitStruct.Alternate = GPIO_AF5_SPI1; | ||||
|         HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); | ||||
| 
 | ||||
|   /* USER CODE BEGIN SPI1_MspInit 1 */ | ||||
|         /* USER CODE BEGIN SPI1_MspInit 1 */ | ||||
| 
 | ||||
|   /* USER CODE END SPI1_MspInit 1 */ | ||||
|   } | ||||
|   else if(hspi->Instance==SPI3) | ||||
|   { | ||||
|   /* USER CODE BEGIN SPI3_MspInit 0 */ | ||||
|         /* USER CODE END SPI1_MspInit 1 */ | ||||
|     } else if(hspi->Instance == SPI3) { | ||||
|         /* USER CODE BEGIN SPI3_MspInit 0 */ | ||||
| 
 | ||||
|   /* USER CODE END SPI3_MspInit 0 */ | ||||
|     /* Peripheral clock enable */ | ||||
|     __HAL_RCC_SPI3_CLK_ENABLE(); | ||||
|         /* USER CODE END SPI3_MspInit 0 */ | ||||
|         /* Peripheral clock enable */ | ||||
|         __HAL_RCC_SPI3_CLK_ENABLE(); | ||||
| 
 | ||||
|     __HAL_RCC_GPIOC_CLK_ENABLE(); | ||||
|     /**SPI3 GPIO Configuration    
 | ||||
|         __HAL_RCC_GPIOC_CLK_ENABLE(); | ||||
|         /**SPI3 GPIO Configuration    
 | ||||
|     PC10     ------> SPI3_SCK | ||||
|     PC11     ------> SPI3_MISO | ||||
|     PC12     ------> SPI3_MOSI  | ||||
|     */ | ||||
|     GPIO_InitStruct.Pin = GPIO_PIN_10|GPIO_PIN_11|GPIO_PIN_12; | ||||
|     GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; | ||||
|     GPIO_InitStruct.Pull = GPIO_NOPULL; | ||||
|     GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; | ||||
|     GPIO_InitStruct.Alternate = GPIO_AF6_SPI3; | ||||
|     HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); | ||||
|         GPIO_InitStruct.Pin = GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12; | ||||
|         GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; | ||||
|         GPIO_InitStruct.Pull = GPIO_NOPULL; | ||||
|         GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; | ||||
|         GPIO_InitStruct.Alternate = GPIO_AF6_SPI3; | ||||
|         HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); | ||||
| 
 | ||||
|   /* USER CODE BEGIN SPI3_MspInit 1 */ | ||||
| 
 | ||||
|   /* USER CODE END SPI3_MspInit 1 */ | ||||
|   } | ||||
|         /* USER CODE BEGIN SPI3_MspInit 1 */ | ||||
| 
 | ||||
|         /* USER CODE END SPI3_MspInit 1 */ | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -337,46 +313,41 @@ void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi) | ||||
| * @param hspi: SPI handle pointer | ||||
| * @retval None | ||||
| */ | ||||
| void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi) | ||||
| { | ||||
|   if(hspi->Instance==SPI1) | ||||
|   { | ||||
|   /* USER CODE BEGIN SPI1_MspDeInit 0 */ | ||||
| void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi) { | ||||
|     if(hspi->Instance == SPI1) { | ||||
|         /* USER CODE BEGIN SPI1_MspDeInit 0 */ | ||||
| 
 | ||||
|   /* USER CODE END SPI1_MspDeInit 0 */ | ||||
|     /* Peripheral clock disable */ | ||||
|     __HAL_RCC_SPI1_CLK_DISABLE(); | ||||
|         /* USER CODE END SPI1_MspDeInit 0 */ | ||||
|         /* Peripheral clock disable */ | ||||
|         __HAL_RCC_SPI1_CLK_DISABLE(); | ||||
| 
 | ||||
|     /**SPI1 GPIO Configuration    
 | ||||
|         /**SPI1 GPIO Configuration    
 | ||||
|     PB3 (JTDO-TRACESWO)     ------> SPI1_SCK | ||||
|     PB5     ------> SPI1_MOSI  | ||||
|     */ | ||||
|     HAL_GPIO_DeInit(GPIOB, GPIO_PIN_3|GPIO_PIN_5); | ||||
|         HAL_GPIO_DeInit(GPIOB, GPIO_PIN_3 | GPIO_PIN_5); | ||||
| 
 | ||||
|   /* USER CODE BEGIN SPI1_MspDeInit 1 */ | ||||
|         /* USER CODE BEGIN SPI1_MspDeInit 1 */ | ||||
| 
 | ||||
|   /* USER CODE END SPI1_MspDeInit 1 */ | ||||
|   } | ||||
|   else if(hspi->Instance==SPI3) | ||||
|   { | ||||
|   /* USER CODE BEGIN SPI3_MspDeInit 0 */ | ||||
|         /* USER CODE END SPI1_MspDeInit 1 */ | ||||
|     } else if(hspi->Instance == SPI3) { | ||||
|         /* USER CODE BEGIN SPI3_MspDeInit 0 */ | ||||
| 
 | ||||
|   /* USER CODE END SPI3_MspDeInit 0 */ | ||||
|     /* Peripheral clock disable */ | ||||
|     __HAL_RCC_SPI3_CLK_DISABLE(); | ||||
|         /* USER CODE END SPI3_MspDeInit 0 */ | ||||
|         /* Peripheral clock disable */ | ||||
|         __HAL_RCC_SPI3_CLK_DISABLE(); | ||||
| 
 | ||||
|     /**SPI3 GPIO Configuration    
 | ||||
|         /**SPI3 GPIO Configuration    
 | ||||
|     PC10     ------> SPI3_SCK | ||||
|     PC11     ------> SPI3_MISO | ||||
|     PC12     ------> SPI3_MOSI  | ||||
|     */ | ||||
|     HAL_GPIO_DeInit(GPIOC, GPIO_PIN_10|GPIO_PIN_11|GPIO_PIN_12); | ||||
|         HAL_GPIO_DeInit(GPIOC, GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12); | ||||
| 
 | ||||
|   /* USER CODE BEGIN SPI3_MspDeInit 1 */ | ||||
| 
 | ||||
|   /* USER CODE END SPI3_MspDeInit 1 */ | ||||
|   } | ||||
|         /* USER CODE BEGIN SPI3_MspDeInit 1 */ | ||||
| 
 | ||||
|         /* USER CODE END SPI3_MspDeInit 1 */ | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -385,20 +356,17 @@ void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi) | ||||
| * @param htim_pwm: TIM_PWM handle pointer | ||||
| * @retval None | ||||
| */ | ||||
| void HAL_TIM_PWM_MspInit(TIM_HandleTypeDef* htim_pwm) | ||||
| { | ||||
|   if(htim_pwm->Instance==TIM5) | ||||
|   { | ||||
|   /* USER CODE BEGIN TIM5_MspInit 0 */ | ||||
| void HAL_TIM_PWM_MspInit(TIM_HandleTypeDef* htim_pwm) { | ||||
|     if(htim_pwm->Instance == TIM5) { | ||||
|         /* USER CODE BEGIN TIM5_MspInit 0 */ | ||||
| 
 | ||||
|   /* USER CODE END TIM5_MspInit 0 */ | ||||
|     /* Peripheral clock enable */ | ||||
|     __HAL_RCC_TIM5_CLK_ENABLE(); | ||||
|   /* USER CODE BEGIN TIM5_MspInit 1 */ | ||||
| 
 | ||||
|   /* USER CODE END TIM5_MspInit 1 */ | ||||
|   } | ||||
|         /* USER CODE END TIM5_MspInit 0 */ | ||||
|         /* Peripheral clock enable */ | ||||
|         __HAL_RCC_TIM5_CLK_ENABLE(); | ||||
|         /* USER CODE BEGIN TIM5_MspInit 1 */ | ||||
| 
 | ||||
|         /* USER CODE END TIM5_MspInit 1 */ | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -407,36 +375,33 @@ void HAL_TIM_PWM_MspInit(TIM_HandleTypeDef* htim_pwm) | ||||
| * @param htim_base: TIM_Base handle pointer | ||||
| * @retval None | ||||
| */ | ||||
| void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base) | ||||
| { | ||||
|   GPIO_InitTypeDef GPIO_InitStruct = {0}; | ||||
|   if(htim_base->Instance==TIM8) | ||||
|   { | ||||
|   /* USER CODE BEGIN TIM8_MspInit 0 */ | ||||
| void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base) { | ||||
|     GPIO_InitTypeDef GPIO_InitStruct = {0}; | ||||
|     if(htim_base->Instance == TIM8) { | ||||
|         /* USER CODE BEGIN TIM8_MspInit 0 */ | ||||
| 
 | ||||
|   /* USER CODE END TIM8_MspInit 0 */ | ||||
|     /* Peripheral clock enable */ | ||||
|     __HAL_RCC_TIM8_CLK_ENABLE(); | ||||
|         /* USER CODE END TIM8_MspInit 0 */ | ||||
|         /* Peripheral clock enable */ | ||||
|         __HAL_RCC_TIM8_CLK_ENABLE(); | ||||
| 
 | ||||
|     __HAL_RCC_GPIOC_CLK_ENABLE(); | ||||
|     /**TIM8 GPIO Configuration    
 | ||||
|         __HAL_RCC_GPIOC_CLK_ENABLE(); | ||||
|         /**TIM8 GPIO Configuration    
 | ||||
|     PC7     ------> TIM8_CH2  | ||||
|     */ | ||||
|     GPIO_InitStruct.Pin = iButton_Pin; | ||||
|     GPIO_InitStruct.Mode = GPIO_MODE_AF_OD; | ||||
|     GPIO_InitStruct.Pull = GPIO_NOPULL; | ||||
|     GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM; | ||||
|     GPIO_InitStruct.Alternate = GPIO_AF3_TIM8; | ||||
|     HAL_GPIO_Init(iButton_GPIO_Port, &GPIO_InitStruct); | ||||
|         GPIO_InitStruct.Pin = iButton_Pin; | ||||
|         GPIO_InitStruct.Mode = GPIO_MODE_AF_OD; | ||||
|         GPIO_InitStruct.Pull = GPIO_NOPULL; | ||||
|         GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM; | ||||
|         GPIO_InitStruct.Alternate = GPIO_AF3_TIM8; | ||||
|         HAL_GPIO_Init(iButton_GPIO_Port, &GPIO_InitStruct); | ||||
| 
 | ||||
|     /* TIM8 interrupt Init */ | ||||
|     HAL_NVIC_SetPriority(TIM8_CC_IRQn, 5, 0); | ||||
|     HAL_NVIC_EnableIRQ(TIM8_CC_IRQn); | ||||
|   /* USER CODE BEGIN TIM8_MspInit 1 */ | ||||
| 
 | ||||
|   /* USER CODE END TIM8_MspInit 1 */ | ||||
|   } | ||||
|         /* TIM8 interrupt Init */ | ||||
|         HAL_NVIC_SetPriority(TIM8_CC_IRQn, 5, 0); | ||||
|         HAL_NVIC_EnableIRQ(TIM8_CC_IRQn); | ||||
|         /* USER CODE BEGIN TIM8_MspInit 1 */ | ||||
| 
 | ||||
|         /* USER CODE END TIM8_MspInit 1 */ | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -445,68 +410,60 @@ void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base) | ||||
| * @param htim_oc: TIM_OC handle pointer | ||||
| * @retval None | ||||
| */ | ||||
| void HAL_TIM_OC_MspInit(TIM_HandleTypeDef* htim_oc) | ||||
| { | ||||
|   if(htim_oc->Instance==TIM15) | ||||
|   { | ||||
|   /* USER CODE BEGIN TIM15_MspInit 0 */ | ||||
| void HAL_TIM_OC_MspInit(TIM_HandleTypeDef* htim_oc) { | ||||
|     if(htim_oc->Instance == TIM15) { | ||||
|         /* USER CODE BEGIN TIM15_MspInit 0 */ | ||||
| 
 | ||||
|   /* USER CODE END TIM15_MspInit 0 */ | ||||
|     /* Peripheral clock enable */ | ||||
|     __HAL_RCC_TIM15_CLK_ENABLE(); | ||||
|   /* USER CODE BEGIN TIM15_MspInit 1 */ | ||||
| 
 | ||||
|   /* USER CODE END TIM15_MspInit 1 */ | ||||
|   } | ||||
|         /* USER CODE END TIM15_MspInit 0 */ | ||||
|         /* Peripheral clock enable */ | ||||
|         __HAL_RCC_TIM15_CLK_ENABLE(); | ||||
|         /* USER CODE BEGIN TIM15_MspInit 1 */ | ||||
| 
 | ||||
|         /* USER CODE END TIM15_MspInit 1 */ | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim) | ||||
| { | ||||
|   GPIO_InitTypeDef GPIO_InitStruct = {0}; | ||||
|   if(htim->Instance==TIM5) | ||||
|   { | ||||
|   /* USER CODE BEGIN TIM5_MspPostInit 0 */ | ||||
| void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim) { | ||||
|     GPIO_InitTypeDef GPIO_InitStruct = {0}; | ||||
|     if(htim->Instance == TIM5) { | ||||
|         /* USER CODE BEGIN TIM5_MspPostInit 0 */ | ||||
| 
 | ||||
|   /* USER CODE END TIM5_MspPostInit 0 */ | ||||
|     __HAL_RCC_GPIOA_CLK_ENABLE(); | ||||
|     /**TIM5 GPIO Configuration    
 | ||||
|         /* USER CODE END TIM5_MspPostInit 0 */ | ||||
|         __HAL_RCC_GPIOA_CLK_ENABLE(); | ||||
|         /**TIM5 GPIO Configuration    
 | ||||
|     PA3     ------> TIM5_CH4  | ||||
|     */ | ||||
|     GPIO_InitStruct.Pin = SPEAKER_Pin; | ||||
|     GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; | ||||
|     GPIO_InitStruct.Pull = GPIO_NOPULL; | ||||
|     GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; | ||||
|     GPIO_InitStruct.Alternate = GPIO_AF2_TIM5; | ||||
|     HAL_GPIO_Init(SPEAKER_GPIO_Port, &GPIO_InitStruct); | ||||
|         GPIO_InitStruct.Pin = SPEAKER_Pin; | ||||
|         GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; | ||||
|         GPIO_InitStruct.Pull = GPIO_NOPULL; | ||||
|         GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; | ||||
|         GPIO_InitStruct.Alternate = GPIO_AF2_TIM5; | ||||
|         HAL_GPIO_Init(SPEAKER_GPIO_Port, &GPIO_InitStruct); | ||||
| 
 | ||||
|   /* USER CODE BEGIN TIM5_MspPostInit 1 */ | ||||
|         /* USER CODE BEGIN TIM5_MspPostInit 1 */ | ||||
| 
 | ||||
|   /* USER CODE END TIM5_MspPostInit 1 */ | ||||
|   } | ||||
|   else if(htim->Instance==TIM15) | ||||
|   { | ||||
|   /* USER CODE BEGIN TIM15_MspPostInit 0 */ | ||||
|         /* USER CODE END TIM5_MspPostInit 1 */ | ||||
|     } else if(htim->Instance == TIM15) { | ||||
|         /* USER CODE BEGIN TIM15_MspPostInit 0 */ | ||||
| 
 | ||||
|   /* USER CODE END TIM15_MspPostInit 0 */ | ||||
|         /* USER CODE END TIM15_MspPostInit 0 */ | ||||
| 
 | ||||
|     __HAL_RCC_GPIOB_CLK_ENABLE(); | ||||
|     /**TIM15 GPIO Configuration    
 | ||||
|         __HAL_RCC_GPIOB_CLK_ENABLE(); | ||||
|         /**TIM15 GPIO Configuration    
 | ||||
|     PB13     ------> TIM15_CH1N | ||||
|     PB15     ------> TIM15_CH2  | ||||
|     */ | ||||
|     GPIO_InitStruct.Pin = RFID_OUT_Pin|RFID_PULL_Pin; | ||||
|     GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; | ||||
|     GPIO_InitStruct.Pull = GPIO_NOPULL; | ||||
|     GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; | ||||
|     GPIO_InitStruct.Alternate = GPIO_AF14_TIM15; | ||||
|     HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); | ||||
|         GPIO_InitStruct.Pin = RFID_OUT_Pin | RFID_PULL_Pin; | ||||
|         GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; | ||||
|         GPIO_InitStruct.Pull = GPIO_NOPULL; | ||||
|         GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; | ||||
|         GPIO_InitStruct.Alternate = GPIO_AF14_TIM15; | ||||
|         HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); | ||||
| 
 | ||||
|   /* USER CODE BEGIN TIM15_MspPostInit 1 */ | ||||
| 
 | ||||
|   /* USER CODE END TIM15_MspPostInit 1 */ | ||||
|   } | ||||
|         /* USER CODE BEGIN TIM15_MspPostInit 1 */ | ||||
| 
 | ||||
|         /* USER CODE END TIM15_MspPostInit 1 */ | ||||
|     } | ||||
| } | ||||
| /**
 | ||||
| * @brief TIM_PWM MSP De-Initialization | ||||
| @ -514,20 +471,17 @@ void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim) | ||||
| * @param htim_pwm: TIM_PWM handle pointer | ||||
| * @retval None | ||||
| */ | ||||
| void HAL_TIM_PWM_MspDeInit(TIM_HandleTypeDef* htim_pwm) | ||||
| { | ||||
|   if(htim_pwm->Instance==TIM5) | ||||
|   { | ||||
|   /* USER CODE BEGIN TIM5_MspDeInit 0 */ | ||||
| void HAL_TIM_PWM_MspDeInit(TIM_HandleTypeDef* htim_pwm) { | ||||
|     if(htim_pwm->Instance == TIM5) { | ||||
|         /* USER CODE BEGIN TIM5_MspDeInit 0 */ | ||||
| 
 | ||||
|   /* USER CODE END TIM5_MspDeInit 0 */ | ||||
|     /* Peripheral clock disable */ | ||||
|     __HAL_RCC_TIM5_CLK_DISABLE(); | ||||
|   /* USER CODE BEGIN TIM5_MspDeInit 1 */ | ||||
| 
 | ||||
|   /* USER CODE END TIM5_MspDeInit 1 */ | ||||
|   } | ||||
|         /* USER CODE END TIM5_MspDeInit 0 */ | ||||
|         /* Peripheral clock disable */ | ||||
|         __HAL_RCC_TIM5_CLK_DISABLE(); | ||||
|         /* USER CODE BEGIN TIM5_MspDeInit 1 */ | ||||
| 
 | ||||
|         /* USER CODE END TIM5_MspDeInit 1 */ | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -536,28 +490,25 @@ void HAL_TIM_PWM_MspDeInit(TIM_HandleTypeDef* htim_pwm) | ||||
| * @param htim_base: TIM_Base handle pointer | ||||
| * @retval None | ||||
| */ | ||||
| void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* htim_base) | ||||
| { | ||||
|   if(htim_base->Instance==TIM8) | ||||
|   { | ||||
|   /* USER CODE BEGIN TIM8_MspDeInit 0 */ | ||||
| void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* htim_base) { | ||||
|     if(htim_base->Instance == TIM8) { | ||||
|         /* USER CODE BEGIN TIM8_MspDeInit 0 */ | ||||
| 
 | ||||
|   /* USER CODE END TIM8_MspDeInit 0 */ | ||||
|     /* Peripheral clock disable */ | ||||
|     __HAL_RCC_TIM8_CLK_DISABLE(); | ||||
|         /* USER CODE END TIM8_MspDeInit 0 */ | ||||
|         /* Peripheral clock disable */ | ||||
|         __HAL_RCC_TIM8_CLK_DISABLE(); | ||||
| 
 | ||||
|     /**TIM8 GPIO Configuration    
 | ||||
|         /**TIM8 GPIO Configuration    
 | ||||
|     PC7     ------> TIM8_CH2  | ||||
|     */ | ||||
|     HAL_GPIO_DeInit(iButton_GPIO_Port, iButton_Pin); | ||||
|         HAL_GPIO_DeInit(iButton_GPIO_Port, iButton_Pin); | ||||
| 
 | ||||
|     /* TIM8 interrupt DeInit */ | ||||
|     HAL_NVIC_DisableIRQ(TIM8_CC_IRQn); | ||||
|   /* USER CODE BEGIN TIM8_MspDeInit 1 */ | ||||
| 
 | ||||
|   /* USER CODE END TIM8_MspDeInit 1 */ | ||||
|   } | ||||
|         /* TIM8 interrupt DeInit */ | ||||
|         HAL_NVIC_DisableIRQ(TIM8_CC_IRQn); | ||||
|         /* USER CODE BEGIN TIM8_MspDeInit 1 */ | ||||
| 
 | ||||
|         /* USER CODE END TIM8_MspDeInit 1 */ | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -566,20 +517,17 @@ void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* htim_base) | ||||
| * @param htim_oc: TIM_OC handle pointer | ||||
| * @retval None | ||||
| */ | ||||
| void HAL_TIM_OC_MspDeInit(TIM_HandleTypeDef* htim_oc) | ||||
| { | ||||
|   if(htim_oc->Instance==TIM15) | ||||
|   { | ||||
|   /* USER CODE BEGIN TIM15_MspDeInit 0 */ | ||||
| void HAL_TIM_OC_MspDeInit(TIM_HandleTypeDef* htim_oc) { | ||||
|     if(htim_oc->Instance == TIM15) { | ||||
|         /* USER CODE BEGIN TIM15_MspDeInit 0 */ | ||||
| 
 | ||||
|   /* USER CODE END TIM15_MspDeInit 0 */ | ||||
|     /* Peripheral clock disable */ | ||||
|     __HAL_RCC_TIM15_CLK_DISABLE(); | ||||
|   /* USER CODE BEGIN TIM15_MspDeInit 1 */ | ||||
| 
 | ||||
|   /* USER CODE END TIM15_MspDeInit 1 */ | ||||
|   } | ||||
|         /* USER CODE END TIM15_MspDeInit 0 */ | ||||
|         /* Peripheral clock disable */ | ||||
|         __HAL_RCC_TIM15_CLK_DISABLE(); | ||||
|         /* USER CODE BEGIN TIM15_MspDeInit 1 */ | ||||
| 
 | ||||
|         /* USER CODE END TIM15_MspDeInit 1 */ | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -588,34 +536,31 @@ void HAL_TIM_OC_MspDeInit(TIM_HandleTypeDef* htim_oc) | ||||
| * @param huart: UART handle pointer | ||||
| * @retval None | ||||
| */ | ||||
| void HAL_UART_MspInit(UART_HandleTypeDef* huart) | ||||
| { | ||||
|   GPIO_InitTypeDef GPIO_InitStruct = {0}; | ||||
|   if(huart->Instance==USART1) | ||||
|   { | ||||
|   /* USER CODE BEGIN USART1_MspInit 0 */ | ||||
| void HAL_UART_MspInit(UART_HandleTypeDef* huart) { | ||||
|     GPIO_InitTypeDef GPIO_InitStruct = {0}; | ||||
|     if(huart->Instance == USART1) { | ||||
|         /* USER CODE BEGIN USART1_MspInit 0 */ | ||||
| 
 | ||||
|   /* USER CODE END USART1_MspInit 0 */ | ||||
|     /* Peripheral clock enable */ | ||||
|     __HAL_RCC_USART1_CLK_ENABLE(); | ||||
|         /* USER CODE END USART1_MspInit 0 */ | ||||
|         /* Peripheral clock enable */ | ||||
|         __HAL_RCC_USART1_CLK_ENABLE(); | ||||
| 
 | ||||
|     __HAL_RCC_GPIOA_CLK_ENABLE(); | ||||
|     /**USART1 GPIO Configuration    
 | ||||
|         __HAL_RCC_GPIOA_CLK_ENABLE(); | ||||
|         /**USART1 GPIO Configuration    
 | ||||
|     PA9     ------> USART1_TX | ||||
|     PA10     ------> USART1_RX  | ||||
|     */ | ||||
|     GPIO_InitStruct.Pin = GPIO_PIN_9|GPIO_PIN_10; | ||||
|     GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; | ||||
|     GPIO_InitStruct.Pull = GPIO_NOPULL; | ||||
|     GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; | ||||
|     GPIO_InitStruct.Alternate = GPIO_AF7_USART1; | ||||
|     HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); | ||||
|         GPIO_InitStruct.Pin = GPIO_PIN_9 | GPIO_PIN_10; | ||||
|         GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; | ||||
|         GPIO_InitStruct.Pull = GPIO_NOPULL; | ||||
|         GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; | ||||
|         GPIO_InitStruct.Alternate = GPIO_AF7_USART1; | ||||
|         HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); | ||||
| 
 | ||||
|   /* USER CODE BEGIN USART1_MspInit 1 */ | ||||
| 
 | ||||
|   /* USER CODE END USART1_MspInit 1 */ | ||||
|   } | ||||
|         /* USER CODE BEGIN USART1_MspInit 1 */ | ||||
| 
 | ||||
|         /* USER CODE END USART1_MspInit 1 */ | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -624,27 +569,24 @@ void HAL_UART_MspInit(UART_HandleTypeDef* huart) | ||||
| * @param huart: UART handle pointer | ||||
| * @retval None | ||||
| */ | ||||
| void HAL_UART_MspDeInit(UART_HandleTypeDef* huart) | ||||
| { | ||||
|   if(huart->Instance==USART1) | ||||
|   { | ||||
|   /* USER CODE BEGIN USART1_MspDeInit 0 */ | ||||
| void HAL_UART_MspDeInit(UART_HandleTypeDef* huart) { | ||||
|     if(huart->Instance == USART1) { | ||||
|         /* USER CODE BEGIN USART1_MspDeInit 0 */ | ||||
| 
 | ||||
|   /* USER CODE END USART1_MspDeInit 0 */ | ||||
|     /* Peripheral clock disable */ | ||||
|     __HAL_RCC_USART1_CLK_DISABLE(); | ||||
|         /* USER CODE END USART1_MspDeInit 0 */ | ||||
|         /* Peripheral clock disable */ | ||||
|         __HAL_RCC_USART1_CLK_DISABLE(); | ||||
| 
 | ||||
|     /**USART1 GPIO Configuration    
 | ||||
|         /**USART1 GPIO Configuration    
 | ||||
|     PA9     ------> USART1_TX | ||||
|     PA10     ------> USART1_RX  | ||||
|     */ | ||||
|     HAL_GPIO_DeInit(GPIOA, GPIO_PIN_9|GPIO_PIN_10); | ||||
|         HAL_GPIO_DeInit(GPIOA, GPIO_PIN_9 | GPIO_PIN_10); | ||||
| 
 | ||||
|   /* USER CODE BEGIN USART1_MspDeInit 1 */ | ||||
| 
 | ||||
|   /* USER CODE END USART1_MspDeInit 1 */ | ||||
|   } | ||||
|         /* USER CODE BEGIN USART1_MspDeInit 1 */ | ||||
| 
 | ||||
|         /* USER CODE END USART1_MspDeInit 1 */ | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /* USER CODE BEGIN 1 */ | ||||
|  | ||||
| @ -70,109 +70,97 @@ extern TIM_HandleTypeDef htim8; | ||||
| /**
 | ||||
|   * @brief This function handles Non maskable interrupt. | ||||
|   */ | ||||
| void NMI_Handler(void) | ||||
| { | ||||
|   /* USER CODE BEGIN NonMaskableInt_IRQn 0 */ | ||||
| void NMI_Handler(void) { | ||||
|     /* USER CODE BEGIN NonMaskableInt_IRQn 0 */ | ||||
| 
 | ||||
|   /* USER CODE END NonMaskableInt_IRQn 0 */ | ||||
|   /* USER CODE BEGIN NonMaskableInt_IRQn 1 */ | ||||
|     /* USER CODE END NonMaskableInt_IRQn 0 */ | ||||
|     /* USER CODE BEGIN NonMaskableInt_IRQn 1 */ | ||||
| 
 | ||||
|   /* USER CODE END NonMaskableInt_IRQn 1 */ | ||||
|     /* USER CODE END NonMaskableInt_IRQn 1 */ | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
|   * @brief This function handles Hard fault interrupt. | ||||
|   */ | ||||
| void HardFault_Handler(void) | ||||
| { | ||||
|   /* USER CODE BEGIN HardFault_IRQn 0 */ | ||||
| void HardFault_Handler(void) { | ||||
|     /* USER CODE BEGIN HardFault_IRQn 0 */ | ||||
| 
 | ||||
|   /* USER CODE END HardFault_IRQn 0 */ | ||||
|   while (1) | ||||
|   { | ||||
|     /* USER CODE BEGIN W1_HardFault_IRQn 0 */ | ||||
|     /* USER CODE END W1_HardFault_IRQn 0 */ | ||||
|   } | ||||
|     /* USER CODE END HardFault_IRQn 0 */ | ||||
|     while(1) { | ||||
|         /* USER CODE BEGIN W1_HardFault_IRQn 0 */ | ||||
|         /* USER CODE END W1_HardFault_IRQn 0 */ | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
|   * @brief This function handles Memory management fault. | ||||
|   */ | ||||
| void MemManage_Handler(void) | ||||
| { | ||||
|   /* USER CODE BEGIN MemoryManagement_IRQn 0 */ | ||||
| void MemManage_Handler(void) { | ||||
|     /* USER CODE BEGIN MemoryManagement_IRQn 0 */ | ||||
| 
 | ||||
|   /* USER CODE END MemoryManagement_IRQn 0 */ | ||||
|   while (1) | ||||
|   { | ||||
|     /* USER CODE BEGIN W1_MemoryManagement_IRQn 0 */ | ||||
|     /* USER CODE END W1_MemoryManagement_IRQn 0 */ | ||||
|   } | ||||
|     /* USER CODE END MemoryManagement_IRQn 0 */ | ||||
|     while(1) { | ||||
|         /* USER CODE BEGIN W1_MemoryManagement_IRQn 0 */ | ||||
|         /* USER CODE END W1_MemoryManagement_IRQn 0 */ | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
|   * @brief This function handles Prefetch fault, memory access fault. | ||||
|   */ | ||||
| void BusFault_Handler(void) | ||||
| { | ||||
|   /* USER CODE BEGIN BusFault_IRQn 0 */ | ||||
| void BusFault_Handler(void) { | ||||
|     /* USER CODE BEGIN BusFault_IRQn 0 */ | ||||
| 
 | ||||
|   /* USER CODE END BusFault_IRQn 0 */ | ||||
|   while (1) | ||||
|   { | ||||
|     /* USER CODE BEGIN W1_BusFault_IRQn 0 */ | ||||
|     /* USER CODE END W1_BusFault_IRQn 0 */ | ||||
|   } | ||||
|     /* USER CODE END BusFault_IRQn 0 */ | ||||
|     while(1) { | ||||
|         /* USER CODE BEGIN W1_BusFault_IRQn 0 */ | ||||
|         /* USER CODE END W1_BusFault_IRQn 0 */ | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
|   * @brief This function handles Undefined instruction or illegal state. | ||||
|   */ | ||||
| void UsageFault_Handler(void) | ||||
| { | ||||
|   /* USER CODE BEGIN UsageFault_IRQn 0 */ | ||||
| void UsageFault_Handler(void) { | ||||
|     /* USER CODE BEGIN UsageFault_IRQn 0 */ | ||||
| 
 | ||||
|   /* USER CODE END UsageFault_IRQn 0 */ | ||||
|   while (1) | ||||
|   { | ||||
|     /* USER CODE BEGIN W1_UsageFault_IRQn 0 */ | ||||
|     /* USER CODE END W1_UsageFault_IRQn 0 */ | ||||
|   } | ||||
|     /* USER CODE END UsageFault_IRQn 0 */ | ||||
|     while(1) { | ||||
|         /* USER CODE BEGIN W1_UsageFault_IRQn 0 */ | ||||
|         /* USER CODE END W1_UsageFault_IRQn 0 */ | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
|   * @brief This function handles Debug monitor. | ||||
|   */ | ||||
| void DebugMon_Handler(void) | ||||
| { | ||||
|   /* USER CODE BEGIN DebugMonitor_IRQn 0 */ | ||||
| void DebugMon_Handler(void) { | ||||
|     /* USER CODE BEGIN DebugMonitor_IRQn 0 */ | ||||
| 
 | ||||
|   /* USER CODE END DebugMonitor_IRQn 0 */ | ||||
|   /* USER CODE BEGIN DebugMonitor_IRQn 1 */ | ||||
|     /* USER CODE END DebugMonitor_IRQn 0 */ | ||||
|     /* USER CODE BEGIN DebugMonitor_IRQn 1 */ | ||||
| 
 | ||||
|   /* USER CODE END DebugMonitor_IRQn 1 */ | ||||
|     /* USER CODE END DebugMonitor_IRQn 1 */ | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
|   * @brief This function handles System tick timer. | ||||
|   */ | ||||
| void SysTick_Handler(void) | ||||
| { | ||||
|   /* USER CODE BEGIN SysTick_IRQn 0 */ | ||||
| void SysTick_Handler(void) { | ||||
|     /* USER CODE BEGIN SysTick_IRQn 0 */ | ||||
| 
 | ||||
|   /* USER CODE END SysTick_IRQn 0 */ | ||||
|   HAL_IncTick(); | ||||
| #if (INCLUDE_xTaskGetSchedulerState == 1 ) | ||||
|   if (xTaskGetSchedulerState() != taskSCHEDULER_NOT_STARTED) | ||||
|   { | ||||
|     /* USER CODE END SysTick_IRQn 0 */ | ||||
|     HAL_IncTick(); | ||||
| #if(INCLUDE_xTaskGetSchedulerState == 1) | ||||
|     if(xTaskGetSchedulerState() != taskSCHEDULER_NOT_STARTED) { | ||||
| #endif /* INCLUDE_xTaskGetSchedulerState */ | ||||
|   xPortSysTickHandler(); | ||||
| #if (INCLUDE_xTaskGetSchedulerState == 1 ) | ||||
|   } | ||||
|         xPortSysTickHandler(); | ||||
| #if(INCLUDE_xTaskGetSchedulerState == 1) | ||||
|     } | ||||
| #endif /* INCLUDE_xTaskGetSchedulerState */ | ||||
|   /* USER CODE BEGIN SysTick_IRQn 1 */ | ||||
|     /* USER CODE BEGIN SysTick_IRQn 1 */ | ||||
| 
 | ||||
|   /* USER CODE END SysTick_IRQn 1 */ | ||||
|     /* USER CODE END SysTick_IRQn 1 */ | ||||
| } | ||||
| 
 | ||||
| /******************************************************************************/ | ||||
| @ -185,115 +173,105 @@ void SysTick_Handler(void) | ||||
| /**
 | ||||
|   * @brief This function handles EXTI line0 interrupt. | ||||
|   */ | ||||
| void EXTI0_IRQHandler(void) | ||||
| { | ||||
|   /* USER CODE BEGIN EXTI0_IRQn 0 */ | ||||
| void EXTI0_IRQHandler(void) { | ||||
|     /* USER CODE BEGIN EXTI0_IRQn 0 */ | ||||
| 
 | ||||
|   /* USER CODE END EXTI0_IRQn 0 */ | ||||
|   HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_0); | ||||
|   /* USER CODE BEGIN EXTI0_IRQn 1 */ | ||||
|     /* USER CODE END EXTI0_IRQn 0 */ | ||||
|     HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_0); | ||||
|     /* USER CODE BEGIN EXTI0_IRQn 1 */ | ||||
| 
 | ||||
|   /* USER CODE END EXTI0_IRQn 1 */ | ||||
|     /* USER CODE END EXTI0_IRQn 1 */ | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
|   * @brief This function handles EXTI line1 interrupt. | ||||
|   */ | ||||
| void EXTI1_IRQHandler(void) | ||||
| { | ||||
|   /* USER CODE BEGIN EXTI1_IRQn 0 */ | ||||
| void EXTI1_IRQHandler(void) { | ||||
|     /* USER CODE BEGIN EXTI1_IRQn 0 */ | ||||
| 
 | ||||
|   /* USER CODE END EXTI1_IRQn 0 */ | ||||
|   HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_1); | ||||
|   /* USER CODE BEGIN EXTI1_IRQn 1 */ | ||||
|     /* USER CODE END EXTI1_IRQn 0 */ | ||||
|     HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_1); | ||||
|     /* USER CODE BEGIN EXTI1_IRQn 1 */ | ||||
| 
 | ||||
|   /* USER CODE END EXTI1_IRQn 1 */ | ||||
|     /* USER CODE END EXTI1_IRQn 1 */ | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
|   * @brief This function handles EXTI line2 interrupt. | ||||
|   */ | ||||
| void EXTI2_IRQHandler(void) | ||||
| { | ||||
|   /* USER CODE BEGIN EXTI2_IRQn 0 */ | ||||
| void EXTI2_IRQHandler(void) { | ||||
|     /* USER CODE BEGIN EXTI2_IRQn 0 */ | ||||
| 
 | ||||
|   /* USER CODE END EXTI2_IRQn 0 */ | ||||
|   HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_2); | ||||
|   /* USER CODE BEGIN EXTI2_IRQn 1 */ | ||||
|     /* USER CODE END EXTI2_IRQn 0 */ | ||||
|     HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_2); | ||||
|     /* USER CODE BEGIN EXTI2_IRQn 1 */ | ||||
| 
 | ||||
|   /* USER CODE END EXTI2_IRQn 1 */ | ||||
|     /* USER CODE END EXTI2_IRQn 1 */ | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
|   * @brief This function handles EXTI line4 interrupt. | ||||
|   */ | ||||
| void EXTI4_IRQHandler(void) | ||||
| { | ||||
|   /* USER CODE BEGIN EXTI4_IRQn 0 */ | ||||
| void EXTI4_IRQHandler(void) { | ||||
|     /* USER CODE BEGIN EXTI4_IRQn 0 */ | ||||
| 
 | ||||
|   /* USER CODE END EXTI4_IRQn 0 */ | ||||
|   HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_4); | ||||
|   /* USER CODE BEGIN EXTI4_IRQn 1 */ | ||||
|     /* USER CODE END EXTI4_IRQn 0 */ | ||||
|     HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_4); | ||||
|     /* USER CODE BEGIN EXTI4_IRQn 1 */ | ||||
| 
 | ||||
|   /* USER CODE END EXTI4_IRQn 1 */ | ||||
|     /* USER CODE END EXTI4_IRQn 1 */ | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
|   * @brief This function handles EXTI line[9:5] interrupts. | ||||
|   */ | ||||
| void EXTI9_5_IRQHandler(void) | ||||
| { | ||||
|   /* USER CODE BEGIN EXTI9_5_IRQn 0 */ | ||||
| void EXTI9_5_IRQHandler(void) { | ||||
|     /* USER CODE BEGIN EXTI9_5_IRQn 0 */ | ||||
| 
 | ||||
|   /* USER CODE END EXTI9_5_IRQn 0 */ | ||||
|   HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_6); | ||||
|   HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_8); | ||||
|   HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_9); | ||||
|   /* USER CODE BEGIN EXTI9_5_IRQn 1 */ | ||||
|     /* USER CODE END EXTI9_5_IRQn 0 */ | ||||
|     HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_6); | ||||
|     HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_8); | ||||
|     HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_9); | ||||
|     /* USER CODE BEGIN EXTI9_5_IRQn 1 */ | ||||
| 
 | ||||
|   /* USER CODE END EXTI9_5_IRQn 1 */ | ||||
|     /* USER CODE END EXTI9_5_IRQn 1 */ | ||||
| } | ||||
| 
 | ||||
| void(*tim8_callback_ch2)(uint16_t ccr, TimerEvent tim_event); | ||||
| void (*tim8_callback_ch2)(uint16_t ccr, TimerEvent tim_event); | ||||
| 
 | ||||
| void register_tim8_callback_ch2(void(*callback)(uint16_t ccr, TimerEvent tim_event)) { | ||||
|   tim8_callback_ch2 = callback; | ||||
| void register_tim8_callback_ch2(void (*callback)(uint16_t ccr, TimerEvent tim_event)) { | ||||
|     tim8_callback_ch2 = callback; | ||||
| } | ||||
| /**
 | ||||
|   * @brief This function handles TIM8 capture compare interrupt. | ||||
|   */ | ||||
| void TIM8_CC_IRQHandler(void) | ||||
| { | ||||
|   /* USER CODE BEGIN TIM8_CC_IRQn 0 */ | ||||
| void TIM8_CC_IRQHandler(void) { | ||||
|     /* USER CODE BEGIN TIM8_CC_IRQn 0 */ | ||||
| 
 | ||||
|   /* Capture compare 2 event */ | ||||
|   if (__HAL_TIM_GET_FLAG(&htim8, TIM_FLAG_CC2) != RESET) | ||||
|   { | ||||
|     if (__HAL_TIM_GET_IT_SOURCE(&htim8, TIM_IT_CC2) != RESET) | ||||
|     { | ||||
|       __HAL_TIM_CLEAR_IT(&htim8, TIM_IT_CC2); | ||||
|       htim8.Channel = HAL_TIM_ACTIVE_CHANNEL_2; | ||||
|       /* Input capture event */ | ||||
|       if ((htim8.Instance->CCMR1 & TIM_CCMR1_CC2S) != 0x00U) | ||||
|       { | ||||
| /*
 | ||||
|     /* Capture compare 2 event */ | ||||
|     if(__HAL_TIM_GET_FLAG(&htim8, TIM_FLAG_CC2) != RESET) { | ||||
|         if(__HAL_TIM_GET_IT_SOURCE(&htim8, TIM_IT_CC2) != RESET) { | ||||
|             __HAL_TIM_CLEAR_IT(&htim8, TIM_IT_CC2); | ||||
|             htim8.Channel = HAL_TIM_ACTIVE_CHANNEL_2; | ||||
|             /* Input capture event */ | ||||
|             if((htim8.Instance->CCMR1 & TIM_CCMR1_CC2S) != 0x00U) { | ||||
|                 /*
 | ||||
| #if (USE_HAL_TIM_REGISTER_CALLBACKS == 1) | ||||
|         htim->IC_CaptureCallback(htim); | ||||
| #else | ||||
|         HAL_TIM_IC_CaptureCallback(htim); | ||||
| #endif | ||||
| */ | ||||
|         if(tim8_callback_ch2 != NULL) { | ||||
|           tim8_callback_ch2(htim8.Instance->CCR2, TimerEventInputCapture); | ||||
|         } | ||||
|       } | ||||
|       /* Output compare event */ | ||||
|       else | ||||
|       { | ||||
|         if(tim8_callback_ch2 != NULL) { | ||||
|           tim8_callback_ch2(0, TimerEventEndOfPulse); | ||||
|         } | ||||
| /*
 | ||||
|                 if(tim8_callback_ch2 != NULL) { | ||||
|                     tim8_callback_ch2(htim8.Instance->CCR2, TimerEventInputCapture); | ||||
|                 } | ||||
|             } | ||||
|             /* Output compare event */ | ||||
|             else { | ||||
|                 if(tim8_callback_ch2 != NULL) { | ||||
|                     tim8_callback_ch2(0, TimerEventEndOfPulse); | ||||
|                 } | ||||
|                 /*
 | ||||
| #if (USE_HAL_TIM_REGISTER_CALLBACKS == 1) | ||||
|         htim->OC_DelayElapsedCallback(htim); | ||||
|         htim->PWM_PulseFinishedCallback(htim); | ||||
| @ -302,31 +280,29 @@ void TIM8_CC_IRQHandler(void) | ||||
|         HAL_TIM_PWM_PulseFinishedCallback(htim); | ||||
| #endif | ||||
| */ | ||||
|       } | ||||
|       htim8.Channel = HAL_TIM_ACTIVE_CHANNEL_CLEARED; | ||||
|             } | ||||
|             htim8.Channel = HAL_TIM_ACTIVE_CHANNEL_CLEARED; | ||||
|         } | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|     /* USER CODE END TIM8_CC_IRQn 0 */ | ||||
|     // HAL_TIM_IRQHandler(&htim8);
 | ||||
|     /* USER CODE BEGIN TIM8_CC_IRQn 1 */ | ||||
| 
 | ||||
|   /* USER CODE END TIM8_CC_IRQn 0 */ | ||||
|   // HAL_TIM_IRQHandler(&htim8);
 | ||||
|   /* USER CODE BEGIN TIM8_CC_IRQn 1 */ | ||||
| 
 | ||||
|   /* USER CODE END TIM8_CC_IRQn 1 */ | ||||
|     /* USER CODE END TIM8_CC_IRQn 1 */ | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
|   * @brief This function handles USB OTG FS global interrupt. | ||||
|   */ | ||||
| void OTG_FS_IRQHandler(void) | ||||
| { | ||||
|   /* USER CODE BEGIN OTG_FS_IRQn 0 */ | ||||
| void OTG_FS_IRQHandler(void) { | ||||
|     /* USER CODE BEGIN OTG_FS_IRQn 0 */ | ||||
| 
 | ||||
|   /* USER CODE END OTG_FS_IRQn 0 */ | ||||
|   HAL_PCD_IRQHandler(&hpcd_USB_OTG_FS); | ||||
|   /* USER CODE BEGIN OTG_FS_IRQn 1 */ | ||||
|     /* USER CODE END OTG_FS_IRQn 0 */ | ||||
|     HAL_PCD_IRQHandler(&hpcd_USB_OTG_FS); | ||||
|     /* USER CODE BEGIN OTG_FS_IRQn 1 */ | ||||
| 
 | ||||
|   /* USER CODE END OTG_FS_IRQn 1 */ | ||||
|     /* USER CODE END OTG_FS_IRQn 1 */ | ||||
| } | ||||
| 
 | ||||
| /* USER CODE BEGIN 1 */ | ||||
|  | ||||
| @ -91,16 +91,16 @@ | ||||
| 
 | ||||
| #include "stm32l4xx.h" | ||||
| 
 | ||||
| #if !defined  (HSE_VALUE) | ||||
|   #define HSE_VALUE    8000000U  /*!< Value of the External oscillator in Hz */ | ||||
| #if !defined(HSE_VALUE) | ||||
| #define HSE_VALUE 8000000U /*!< Value of the External oscillator in Hz */ | ||||
| #endif /* HSE_VALUE */ | ||||
| 
 | ||||
| #if !defined  (MSI_VALUE) | ||||
|   #define MSI_VALUE    4000000U  /*!< Value of the Internal oscillator in Hz*/ | ||||
| #if !defined(MSI_VALUE) | ||||
| #define MSI_VALUE 4000000U /*!< Value of the Internal oscillator in Hz*/ | ||||
| #endif /* MSI_VALUE */ | ||||
| 
 | ||||
| #if !defined  (HSI_VALUE) | ||||
|   #define HSI_VALUE    16000000U /*!< Value of the Internal oscillator in Hz*/ | ||||
| #if !defined(HSI_VALUE) | ||||
| #define HSI_VALUE 16000000U /*!< Value of the Internal oscillator in Hz*/ | ||||
| #endif /* HSI_VALUE */ | ||||
| 
 | ||||
| /**
 | ||||
| @ -123,7 +123,8 @@ | ||||
| /*!< Uncomment the following line if you need to relocate your vector Table in
 | ||||
|      Internal SRAM. */ | ||||
| /* #define VECT_TAB_SRAM */ | ||||
| #define VECT_TAB_OFFSET  0x00 /*!< Vector Table base offset field. | ||||
| #define VECT_TAB_OFFSET \ | ||||
|     0x00 /*!< Vector Table base offset field.
 | ||||
|                                    This value must be a multiple of 0x200. */ | ||||
| /******************************************************************************/ | ||||
| /**
 | ||||
| @ -141,7 +142,7 @@ | ||||
| /** @addtogroup STM32L4xx_System_Private_Variables
 | ||||
|   * @{ | ||||
|   */ | ||||
|   /* The SystemCoreClock variable is updated in three ways:
 | ||||
| /* The SystemCoreClock variable is updated in three ways:
 | ||||
|       1) by calling CMSIS function SystemCoreClockUpdate() | ||||
|       2) by calling HAL API function HAL_RCC_GetHCLKFreq() | ||||
|       3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency | ||||
| @ -149,12 +150,22 @@ | ||||
|                is no need to call the 2 first functions listed above, since SystemCoreClock | ||||
|                variable is updated automatically. | ||||
|   */ | ||||
|   uint32_t SystemCoreClock = 4000000U; | ||||
| uint32_t SystemCoreClock = 4000000U; | ||||
| 
 | ||||
|   const uint8_t  AHBPrescTable[16] = {0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 1U, 2U, 3U, 4U, 6U, 7U, 8U, 9U}; | ||||
|   const uint8_t  APBPrescTable[8] =  {0U, 0U, 0U, 0U, 1U, 2U, 3U, 4U}; | ||||
|   const uint32_t MSIRangeTable[12] = {100000U,   200000U,   400000U,   800000U,  1000000U,  2000000U, \ | ||||
|                                       4000000U, 8000000U, 16000000U, 24000000U, 32000000U, 48000000U}; | ||||
| const uint8_t AHBPrescTable[16] = {0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 1U, 2U, 3U, 4U, 6U, 7U, 8U, 9U}; | ||||
| const uint8_t APBPrescTable[8] = {0U, 0U, 0U, 0U, 1U, 2U, 3U, 4U}; | ||||
| const uint32_t MSIRangeTable[12] = {100000U, | ||||
|                                     200000U, | ||||
|                                     400000U, | ||||
|                                     800000U, | ||||
|                                     1000000U, | ||||
|                                     2000000U, | ||||
|                                     4000000U, | ||||
|                                     8000000U, | ||||
|                                     16000000U, | ||||
|                                     24000000U, | ||||
|                                     32000000U, | ||||
|                                     48000000U}; | ||||
| /**
 | ||||
|   * @} | ||||
|   */ | ||||
| @ -177,37 +188,36 @@ | ||||
|   * @retval None | ||||
|   */ | ||||
| 
 | ||||
| void SystemInit(void) | ||||
| { | ||||
|   /* FPU settings ------------------------------------------------------------*/ | ||||
|   #if (__FPU_PRESENT == 1) && (__FPU_USED == 1) | ||||
|     SCB->CPACR |= ((3UL << 10*2)|(3UL << 11*2));  /* set CP10 and CP11 Full Access */ | ||||
|   #endif | ||||
| void SystemInit(void) { | ||||
| /* FPU settings ------------------------------------------------------------*/ | ||||
| #if(__FPU_PRESENT == 1) && (__FPU_USED == 1) | ||||
|     SCB->CPACR |= ((3UL << 10 * 2) | (3UL << 11 * 2)); /* set CP10 and CP11 Full Access */ | ||||
| #endif | ||||
| 
 | ||||
|   /* Reset the RCC clock configuration to the default reset state ------------*/ | ||||
|   /* Set MSION bit */ | ||||
|   RCC->CR |= RCC_CR_MSION; | ||||
|     /* Reset the RCC clock configuration to the default reset state ------------*/ | ||||
|     /* Set MSION bit */ | ||||
|     RCC->CR |= RCC_CR_MSION; | ||||
| 
 | ||||
|   /* Reset CFGR register */ | ||||
|   RCC->CFGR = 0x00000000U; | ||||
|     /* Reset CFGR register */ | ||||
|     RCC->CFGR = 0x00000000U; | ||||
| 
 | ||||
|   /* Reset HSEON, CSSON , HSION, and PLLON bits */ | ||||
|   RCC->CR &= 0xEAF6FFFFU; | ||||
|     /* Reset HSEON, CSSON , HSION, and PLLON bits */ | ||||
|     RCC->CR &= 0xEAF6FFFFU; | ||||
| 
 | ||||
|   /* Reset PLLCFGR register */ | ||||
|   RCC->PLLCFGR = 0x00001000U; | ||||
|     /* Reset PLLCFGR register */ | ||||
|     RCC->PLLCFGR = 0x00001000U; | ||||
| 
 | ||||
|   /* Reset HSEBYP bit */ | ||||
|   RCC->CR &= 0xFFFBFFFFU; | ||||
|     /* Reset HSEBYP bit */ | ||||
|     RCC->CR &= 0xFFFBFFFFU; | ||||
| 
 | ||||
|   /* Disable all interrupts */ | ||||
|   RCC->CIER = 0x00000000U; | ||||
|     /* Disable all interrupts */ | ||||
|     RCC->CIER = 0x00000000U; | ||||
| 
 | ||||
|   /* Configure the Vector Table location add offset address ------------------*/ | ||||
|     /* Configure the Vector Table location add offset address ------------------*/ | ||||
| #ifdef VECT_TAB_SRAM | ||||
|   SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */ | ||||
|     SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */ | ||||
| #else | ||||
|   SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */ | ||||
|     SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */ | ||||
| #endif | ||||
| } | ||||
| 
 | ||||
| @ -253,75 +263,68 @@ void SystemInit(void) | ||||
|   * @param  None | ||||
|   * @retval None | ||||
|   */ | ||||
| void SystemCoreClockUpdate(void) | ||||
| { | ||||
|   uint32_t tmp = 0U, msirange = 0U, pllvco = 0U, pllr = 2U, pllsource = 0U, pllm = 2U; | ||||
| void SystemCoreClockUpdate(void) { | ||||
|     uint32_t tmp = 0U, msirange = 0U, pllvco = 0U, pllr = 2U, pllsource = 0U, pllm = 2U; | ||||
| 
 | ||||
|   /* Get MSI Range frequency--------------------------------------------------*/ | ||||
|   if((RCC->CR & RCC_CR_MSIRGSEL) == RESET) | ||||
|   { /* MSISRANGE from RCC_CSR applies */ | ||||
|     msirange = (RCC->CSR & RCC_CSR_MSISRANGE) >> 8U; | ||||
|   } | ||||
|   else | ||||
|   { /* MSIRANGE from RCC_CR applies */ | ||||
|     msirange = (RCC->CR & RCC_CR_MSIRANGE) >> 4U; | ||||
|   } | ||||
|   /*MSI frequency range in HZ*/ | ||||
|   msirange = MSIRangeTable[msirange]; | ||||
|     /* Get MSI Range frequency--------------------------------------------------*/ | ||||
|     if((RCC->CR & RCC_CR_MSIRGSEL) == RESET) { /* MSISRANGE from RCC_CSR applies */ | ||||
|         msirange = (RCC->CSR & RCC_CSR_MSISRANGE) >> 8U; | ||||
|     } else { /* MSIRANGE from RCC_CR applies */ | ||||
|         msirange = (RCC->CR & RCC_CR_MSIRANGE) >> 4U; | ||||
|     } | ||||
|     /*MSI frequency range in HZ*/ | ||||
|     msirange = MSIRangeTable[msirange]; | ||||
| 
 | ||||
|   /* Get SYSCLK source -------------------------------------------------------*/ | ||||
|   switch (RCC->CFGR & RCC_CFGR_SWS) | ||||
|   { | ||||
|     case 0x00:  /* MSI used as system clock source */ | ||||
|       SystemCoreClock = msirange; | ||||
|       break; | ||||
|     /* Get SYSCLK source -------------------------------------------------------*/ | ||||
|     switch(RCC->CFGR & RCC_CFGR_SWS) { | ||||
|     case 0x00: /* MSI used as system clock source */ | ||||
|         SystemCoreClock = msirange; | ||||
|         break; | ||||
| 
 | ||||
|     case 0x04:  /* HSI used as system clock source */ | ||||
|       SystemCoreClock = HSI_VALUE; | ||||
|       break; | ||||
|     case 0x04: /* HSI used as system clock source */ | ||||
|         SystemCoreClock = HSI_VALUE; | ||||
|         break; | ||||
| 
 | ||||
|     case 0x08:  /* HSE used as system clock source */ | ||||
|       SystemCoreClock = HSE_VALUE; | ||||
|       break; | ||||
|     case 0x08: /* HSE used as system clock source */ | ||||
|         SystemCoreClock = HSE_VALUE; | ||||
|         break; | ||||
| 
 | ||||
|     case 0x0C:  /* PLL used as system clock  source */ | ||||
|       /* PLL_VCO = (HSE_VALUE or HSI_VALUE or MSI_VALUE/ PLLM) * PLLN
 | ||||
|     case 0x0C: /* PLL used as system clock  source */ | ||||
|         /* PLL_VCO = (HSE_VALUE or HSI_VALUE or MSI_VALUE/ PLLM) * PLLN
 | ||||
|          SYSCLK = PLL_VCO / PLLR | ||||
|          */ | ||||
|       pllsource = (RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC); | ||||
|       pllm = ((RCC->PLLCFGR & RCC_PLLCFGR_PLLM) >> 4U) + 1U ; | ||||
|         pllsource = (RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC); | ||||
|         pllm = ((RCC->PLLCFGR & RCC_PLLCFGR_PLLM) >> 4U) + 1U; | ||||
| 
 | ||||
|       switch (pllsource) | ||||
|       { | ||||
|         case 0x02:  /* HSI used as PLL clock source */ | ||||
|           pllvco = (HSI_VALUE / pllm); | ||||
|           break; | ||||
|         switch(pllsource) { | ||||
|         case 0x02: /* HSI used as PLL clock source */ | ||||
|             pllvco = (HSI_VALUE / pllm); | ||||
|             break; | ||||
| 
 | ||||
|         case 0x03:  /* HSE used as PLL clock source */ | ||||
|           pllvco = (HSE_VALUE / pllm); | ||||
|           break; | ||||
|         case 0x03: /* HSE used as PLL clock source */ | ||||
|             pllvco = (HSE_VALUE / pllm); | ||||
|             break; | ||||
| 
 | ||||
|         default:    /* MSI used as PLL clock source */ | ||||
|           pllvco = (msirange / pllm); | ||||
|           break; | ||||
|       } | ||||
|       pllvco = pllvco * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 8U); | ||||
|       pllr = (((RCC->PLLCFGR & RCC_PLLCFGR_PLLR) >> 25U) + 1U) * 2U; | ||||
|       SystemCoreClock = pllvco/pllr; | ||||
|       break; | ||||
|         default: /* MSI used as PLL clock source */ | ||||
|             pllvco = (msirange / pllm); | ||||
|             break; | ||||
|         } | ||||
|         pllvco = pllvco * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 8U); | ||||
|         pllr = (((RCC->PLLCFGR & RCC_PLLCFGR_PLLR) >> 25U) + 1U) * 2U; | ||||
|         SystemCoreClock = pllvco / pllr; | ||||
|         break; | ||||
| 
 | ||||
|     default: | ||||
|       SystemCoreClock = msirange; | ||||
|       break; | ||||
|   } | ||||
|   /* Compute HCLK clock frequency --------------------------------------------*/ | ||||
|   /* Get HCLK prescaler */ | ||||
|   tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4U)]; | ||||
|   /* HCLK clock frequency */ | ||||
|   SystemCoreClock >>= tmp; | ||||
|         SystemCoreClock = msirange; | ||||
|         break; | ||||
|     } | ||||
|     /* Compute HCLK clock frequency --------------------------------------------*/ | ||||
|     /* Get HCLK prescaler */ | ||||
|     tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4U)]; | ||||
|     /* HCLK clock frequency */ | ||||
|     SystemCoreClock >>= tmp; | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| /**
 | ||||
|   * @} | ||||
|   */ | ||||
|  | ||||
| @ -63,32 +63,27 @@ extern USBD_DescriptorsTypeDef FS_Desc; | ||||
|   * Init USB device Library, add supported class and start the library | ||||
|   * @retval None | ||||
|   */ | ||||
| void MX_USB_DEVICE_Init(void) | ||||
| { | ||||
|   /* USER CODE BEGIN USB_DEVICE_Init_PreTreatment */ | ||||
| void MX_USB_DEVICE_Init(void) { | ||||
|     /* USER CODE BEGIN USB_DEVICE_Init_PreTreatment */ | ||||
| 
 | ||||
|   /* USER CODE END USB_DEVICE_Init_PreTreatment */ | ||||
|     /* USER CODE END USB_DEVICE_Init_PreTreatment */ | ||||
| 
 | ||||
|   /* Init Device Library, add supported class and start the library. */ | ||||
|   if (USBD_Init(&hUsbDeviceFS, &FS_Desc, DEVICE_FS) != USBD_OK) | ||||
|   { | ||||
|     Error_Handler(); | ||||
|   } | ||||
|   if (USBD_RegisterClass(&hUsbDeviceFS, &USBD_CDC) != USBD_OK) | ||||
|   { | ||||
|     Error_Handler(); | ||||
|   } | ||||
|   if (USBD_CDC_RegisterInterface(&hUsbDeviceFS, &USBD_Interface_fops_FS) != USBD_OK) | ||||
|   { | ||||
|     Error_Handler(); | ||||
|   } | ||||
|   if (USBD_Start(&hUsbDeviceFS) != USBD_OK) | ||||
|   { | ||||
|     Error_Handler(); | ||||
|   } | ||||
|   /* USER CODE BEGIN USB_DEVICE_Init_PostTreatment */ | ||||
|     /* Init Device Library, add supported class and start the library. */ | ||||
|     if(USBD_Init(&hUsbDeviceFS, &FS_Desc, DEVICE_FS) != USBD_OK) { | ||||
|         Error_Handler(); | ||||
|     } | ||||
|     if(USBD_RegisterClass(&hUsbDeviceFS, &USBD_CDC) != USBD_OK) { | ||||
|         Error_Handler(); | ||||
|     } | ||||
|     if(USBD_CDC_RegisterInterface(&hUsbDeviceFS, &USBD_Interface_fops_FS) != USBD_OK) { | ||||
|         Error_Handler(); | ||||
|     } | ||||
|     if(USBD_Start(&hUsbDeviceFS) != USBD_OK) { | ||||
|         Error_Handler(); | ||||
|     } | ||||
|     /* USER CODE BEGIN USB_DEVICE_Init_PostTreatment */ | ||||
| 
 | ||||
|   /* USER CODE END USB_DEVICE_Init_PostTreatment */ | ||||
|     /* USER CODE END USB_DEVICE_Init_PostTreatment */ | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
|  | ||||
| @ -65,8 +65,8 @@ | ||||
| /* USER CODE BEGIN PRIVATE_DEFINES */ | ||||
| /* Define size for the receive and transmit buffer over CDC */ | ||||
| /* It's up to user to redefine and/or remove those define */ | ||||
| #define APP_RX_DATA_SIZE  2048 | ||||
| #define APP_TX_DATA_SIZE  2048 | ||||
| #define APP_RX_DATA_SIZE 2048 | ||||
| #define APP_TX_DATA_SIZE 2048 | ||||
| /* USER CODE END PRIVATE_DEFINES */ | ||||
| 
 | ||||
| /**
 | ||||
| @ -129,7 +129,7 @@ extern USBD_HandleTypeDef hUsbDeviceFS; | ||||
| static int8_t CDC_Init_FS(void); | ||||
| static int8_t CDC_DeInit_FS(void); | ||||
| static int8_t CDC_Control_FS(uint8_t cmd, uint8_t* pbuf, uint16_t length); | ||||
| static int8_t CDC_Receive_FS(uint8_t* pbuf, uint32_t *Len); | ||||
| static int8_t CDC_Receive_FS(uint8_t* pbuf, uint32_t* Len); | ||||
| 
 | ||||
| /* USER CODE BEGIN PRIVATE_FUNCTIONS_DECLARATION */ | ||||
| 
 | ||||
| @ -139,38 +139,33 @@ static int8_t CDC_Receive_FS(uint8_t* pbuf, uint32_t *Len); | ||||
|   * @} | ||||
|   */ | ||||
| 
 | ||||
| USBD_CDC_ItfTypeDef USBD_Interface_fops_FS = | ||||
| { | ||||
|   CDC_Init_FS, | ||||
|   CDC_DeInit_FS, | ||||
|   CDC_Control_FS, | ||||
|   CDC_Receive_FS | ||||
| }; | ||||
| USBD_CDC_ItfTypeDef USBD_Interface_fops_FS = {CDC_Init_FS, | ||||
|                                               CDC_DeInit_FS, | ||||
|                                               CDC_Control_FS, | ||||
|                                               CDC_Receive_FS}; | ||||
| 
 | ||||
| /* Private functions ---------------------------------------------------------*/ | ||||
| /**
 | ||||
|   * @brief  Initializes the CDC media low layer over the FS USB IP | ||||
|   * @retval USBD_OK if all operations are OK else USBD_FAIL | ||||
|   */ | ||||
| static int8_t CDC_Init_FS(void) | ||||
| { | ||||
|   /* USER CODE BEGIN 3 */ | ||||
|   /* Set Application Buffers */ | ||||
|   USBD_CDC_SetTxBuffer(&hUsbDeviceFS, UserTxBufferFS, 0); | ||||
|   USBD_CDC_SetRxBuffer(&hUsbDeviceFS, UserRxBufferFS); | ||||
|   return (USBD_OK); | ||||
|   /* USER CODE END 3 */ | ||||
| static int8_t CDC_Init_FS(void) { | ||||
|     /* USER CODE BEGIN 3 */ | ||||
|     /* Set Application Buffers */ | ||||
|     USBD_CDC_SetTxBuffer(&hUsbDeviceFS, UserTxBufferFS, 0); | ||||
|     USBD_CDC_SetRxBuffer(&hUsbDeviceFS, UserRxBufferFS); | ||||
|     return (USBD_OK); | ||||
|     /* USER CODE END 3 */ | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
|   * @brief  DeInitializes the CDC media low layer | ||||
|   * @retval USBD_OK if all operations are OK else USBD_FAIL | ||||
|   */ | ||||
| static int8_t CDC_DeInit_FS(void) | ||||
| { | ||||
|   /* USER CODE BEGIN 4 */ | ||||
|   return (USBD_OK); | ||||
|   /* USER CODE END 4 */ | ||||
| static int8_t CDC_DeInit_FS(void) { | ||||
|     /* USER CODE BEGIN 4 */ | ||||
|     return (USBD_OK); | ||||
|     /* USER CODE END 4 */ | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -180,70 +175,68 @@ static int8_t CDC_DeInit_FS(void) | ||||
|   * @param  length: Number of data to be sent (in bytes) | ||||
|   * @retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL | ||||
|   */ | ||||
| static int8_t CDC_Control_FS(uint8_t cmd, uint8_t* pbuf, uint16_t length) | ||||
| { | ||||
|   /* USER CODE BEGIN 5 */ | ||||
|   switch(cmd) | ||||
|   { | ||||
| static int8_t CDC_Control_FS(uint8_t cmd, uint8_t* pbuf, uint16_t length) { | ||||
|     /* USER CODE BEGIN 5 */ | ||||
|     switch(cmd) { | ||||
|     case CDC_SEND_ENCAPSULATED_COMMAND: | ||||
| 
 | ||||
|     break; | ||||
|         break; | ||||
| 
 | ||||
|     case CDC_GET_ENCAPSULATED_RESPONSE: | ||||
| 
 | ||||
|     break; | ||||
|         break; | ||||
| 
 | ||||
|     case CDC_SET_COMM_FEATURE: | ||||
| 
 | ||||
|     break; | ||||
|         break; | ||||
| 
 | ||||
|     case CDC_GET_COMM_FEATURE: | ||||
| 
 | ||||
|     break; | ||||
|         break; | ||||
| 
 | ||||
|     case CDC_CLEAR_COMM_FEATURE: | ||||
| 
 | ||||
|     break; | ||||
|         break; | ||||
| 
 | ||||
|   /*******************************************************************************/ | ||||
|   /* Line Coding Structure                                                       */ | ||||
|   /*-----------------------------------------------------------------------------*/ | ||||
|   /* Offset | Field       | Size | Value  | Description                          */ | ||||
|   /* 0      | dwDTERate   |   4  | Number |Data terminal rate, in bits per second*/ | ||||
|   /* 4      | bCharFormat |   1  | Number | Stop bits                            */ | ||||
|   /*                                        0 - 1 Stop bit                       */ | ||||
|   /*                                        1 - 1.5 Stop bits                    */ | ||||
|   /*                                        2 - 2 Stop bits                      */ | ||||
|   /* 5      | bParityType |  1   | Number | Parity                               */ | ||||
|   /*                                        0 - None                             */ | ||||
|   /*                                        1 - Odd                              */ | ||||
|   /*                                        2 - Even                             */ | ||||
|   /*                                        3 - Mark                             */ | ||||
|   /*                                        4 - Space                            */ | ||||
|   /* 6      | bDataBits  |   1   | Number Data bits (5, 6, 7, 8 or 16).          */ | ||||
|   /*******************************************************************************/ | ||||
|         /*******************************************************************************/ | ||||
|         /* Line Coding Structure                                                       */ | ||||
|         /*-----------------------------------------------------------------------------*/ | ||||
|         /* Offset | Field       | Size | Value  | Description                          */ | ||||
|         /* 0      | dwDTERate   |   4  | Number |Data terminal rate, in bits per second*/ | ||||
|         /* 4      | bCharFormat |   1  | Number | Stop bits                            */ | ||||
|         /*                                        0 - 1 Stop bit                       */ | ||||
|         /*                                        1 - 1.5 Stop bits                    */ | ||||
|         /*                                        2 - 2 Stop bits                      */ | ||||
|         /* 5      | bParityType |  1   | Number | Parity                               */ | ||||
|         /*                                        0 - None                             */ | ||||
|         /*                                        1 - Odd                              */ | ||||
|         /*                                        2 - Even                             */ | ||||
|         /*                                        3 - Mark                             */ | ||||
|         /*                                        4 - Space                            */ | ||||
|         /* 6      | bDataBits  |   1   | Number Data bits (5, 6, 7, 8 or 16).          */ | ||||
|         /*******************************************************************************/ | ||||
|     case CDC_SET_LINE_CODING: | ||||
| 
 | ||||
|     break; | ||||
|         break; | ||||
| 
 | ||||
|     case CDC_GET_LINE_CODING: | ||||
| 
 | ||||
|     break; | ||||
|         break; | ||||
| 
 | ||||
|     case CDC_SET_CONTROL_LINE_STATE: | ||||
| 
 | ||||
|     break; | ||||
|         break; | ||||
| 
 | ||||
|     case CDC_SEND_BREAK: | ||||
| 
 | ||||
|     break; | ||||
|         break; | ||||
| 
 | ||||
|   default: | ||||
|     break; | ||||
|   } | ||||
|     default: | ||||
|         break; | ||||
|     } | ||||
| 
 | ||||
|   return (USBD_OK); | ||||
|   /* USER CODE END 5 */ | ||||
|     return (USBD_OK); | ||||
|     /* USER CODE END 5 */ | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -260,13 +253,12 @@ static int8_t CDC_Control_FS(uint8_t cmd, uint8_t* pbuf, uint16_t length) | ||||
|   * @param  Len: Number of data received (in bytes) | ||||
|   * @retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL | ||||
|   */ | ||||
| static int8_t CDC_Receive_FS(uint8_t* Buf, uint32_t *Len) | ||||
| { | ||||
|   /* USER CODE BEGIN 6 */ | ||||
|   USBD_CDC_SetRxBuffer(&hUsbDeviceFS, &Buf[0]); | ||||
|   USBD_CDC_ReceivePacket(&hUsbDeviceFS); | ||||
|   return (USBD_OK); | ||||
|   /* USER CODE END 6 */ | ||||
| static int8_t CDC_Receive_FS(uint8_t* Buf, uint32_t* Len) { | ||||
|     /* USER CODE BEGIN 6 */ | ||||
|     USBD_CDC_SetRxBuffer(&hUsbDeviceFS, &Buf[0]); | ||||
|     USBD_CDC_ReceivePacket(&hUsbDeviceFS); | ||||
|     return (USBD_OK); | ||||
|     /* USER CODE END 6 */ | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -280,18 +272,17 @@ static int8_t CDC_Receive_FS(uint8_t* Buf, uint32_t *Len) | ||||
|   * @param  Len: Number of data to be sent (in bytes) | ||||
|   * @retval USBD_OK if all operations are OK else USBD_FAIL or USBD_BUSY | ||||
|   */ | ||||
| uint8_t CDC_Transmit_FS(uint8_t* Buf, uint16_t Len) | ||||
| { | ||||
|   uint8_t result = USBD_OK; | ||||
|   /* USER CODE BEGIN 7 */ | ||||
|   USBD_CDC_HandleTypeDef *hcdc = (USBD_CDC_HandleTypeDef*)hUsbDeviceFS.pClassData; | ||||
|   if (hcdc->TxState != 0){ | ||||
|     return USBD_BUSY; | ||||
|   } | ||||
|   USBD_CDC_SetTxBuffer(&hUsbDeviceFS, Buf, Len); | ||||
|   result = USBD_CDC_TransmitPacket(&hUsbDeviceFS); | ||||
|   /* USER CODE END 7 */ | ||||
|   return result; | ||||
| uint8_t CDC_Transmit_FS(uint8_t* Buf, uint16_t Len) { | ||||
|     uint8_t result = USBD_OK; | ||||
|     /* USER CODE BEGIN 7 */ | ||||
|     USBD_CDC_HandleTypeDef* hcdc = (USBD_CDC_HandleTypeDef*)hUsbDeviceFS.pClassData; | ||||
|     if(hcdc->TxState != 0) { | ||||
|         return USBD_BUSY; | ||||
|     } | ||||
|     USBD_CDC_SetTxBuffer(&hUsbDeviceFS, Buf, Len); | ||||
|     result = USBD_CDC_TransmitPacket(&hUsbDeviceFS); | ||||
|     /* USER CODE END 7 */ | ||||
|     return result; | ||||
| } | ||||
| 
 | ||||
| /* USER CODE BEGIN PRIVATE_FUNCTIONS_IMPLEMENTATION */ | ||||
|  | ||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @ -63,15 +63,15 @@ | ||||
|   * @{ | ||||
|   */ | ||||
| 
 | ||||
| #define USBD_VID     1155 | ||||
| #define USBD_LANGID_STRING     1033 | ||||
| #define USBD_MANUFACTURER_STRING     "STMicroelectronics" | ||||
| #define USBD_PID_FS     22336 | ||||
| #define USBD_PRODUCT_STRING_FS     "Flipper Zero Virtual ComPort" | ||||
| #define USBD_CONFIGURATION_STRING_FS     "CDC Config" | ||||
| #define USBD_INTERFACE_STRING_FS     "CDC Interface" | ||||
| #define USBD_VID 1155 | ||||
| #define USBD_LANGID_STRING 1033 | ||||
| #define USBD_MANUFACTURER_STRING "STMicroelectronics" | ||||
| #define USBD_PID_FS 22336 | ||||
| #define USBD_PRODUCT_STRING_FS "Flipper Zero Virtual ComPort" | ||||
| #define USBD_CONFIGURATION_STRING_FS "CDC Config" | ||||
| #define USBD_INTERFACE_STRING_FS "CDC Interface" | ||||
| 
 | ||||
| #define USB_SIZ_BOS_DESC            0x0C | ||||
| #define USB_SIZ_BOS_DESC 0x0C | ||||
| 
 | ||||
| /* USER CODE BEGIN PRIVATE_DEFINES */ | ||||
| 
 | ||||
| @ -104,27 +104,26 @@ | ||||
|   */ | ||||
| 
 | ||||
| static void Get_SerialNum(void); | ||||
| static void IntToUnicode(uint32_t value, uint8_t * pbuf, uint8_t len); | ||||
| static void IntToUnicode(uint32_t value, uint8_t* pbuf, uint8_t len); | ||||
| 
 | ||||
| /**
 | ||||
|   * @} | ||||
|   */ | ||||
| 
 | ||||
| 
 | ||||
| /** @defgroup USBD_DESC_Private_FunctionPrototypes USBD_DESC_Private_FunctionPrototypes
 | ||||
|   * @brief Private functions declaration for FS. | ||||
|   * @{ | ||||
|   */ | ||||
| 
 | ||||
| uint8_t * USBD_FS_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); | ||||
| uint8_t * USBD_FS_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); | ||||
| uint8_t * USBD_FS_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); | ||||
| uint8_t * USBD_FS_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); | ||||
| uint8_t * USBD_FS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); | ||||
| uint8_t * USBD_FS_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); | ||||
| uint8_t * USBD_FS_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); | ||||
| #if (USBD_LPM_ENABLED == 1) | ||||
| uint8_t * USBD_FS_USR_BOSDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); | ||||
| uint8_t* USBD_FS_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t* length); | ||||
| uint8_t* USBD_FS_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t* length); | ||||
| uint8_t* USBD_FS_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t* length); | ||||
| uint8_t* USBD_FS_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t* length); | ||||
| uint8_t* USBD_FS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t* length); | ||||
| uint8_t* USBD_FS_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t* length); | ||||
| uint8_t* USBD_FS_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t* length); | ||||
| #if(USBD_LPM_ENABLED == 1) | ||||
| uint8_t* USBD_FS_USR_BOSDescriptor(USBD_SpeedTypeDef speed, uint16_t* length); | ||||
| #endif /* (USBD_LPM_ENABLED == 1) */ | ||||
| 
 | ||||
| /**
 | ||||
| @ -136,74 +135,71 @@ uint8_t * USBD_FS_USR_BOSDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); | ||||
|   * @{ | ||||
|   */ | ||||
| 
 | ||||
| USBD_DescriptorsTypeDef FS_Desc = | ||||
| { | ||||
|   USBD_FS_DeviceDescriptor | ||||
| , USBD_FS_LangIDStrDescriptor | ||||
| , USBD_FS_ManufacturerStrDescriptor | ||||
| , USBD_FS_ProductStrDescriptor | ||||
| , USBD_FS_SerialStrDescriptor | ||||
| , USBD_FS_ConfigStrDescriptor | ||||
| , USBD_FS_InterfaceStrDescriptor | ||||
| #if (USBD_LPM_ENABLED == 1) | ||||
| , USBD_FS_USR_BOSDescriptor | ||||
| USBD_DescriptorsTypeDef FS_Desc = {USBD_FS_DeviceDescriptor, | ||||
|                                    USBD_FS_LangIDStrDescriptor, | ||||
|                                    USBD_FS_ManufacturerStrDescriptor, | ||||
|                                    USBD_FS_ProductStrDescriptor, | ||||
|                                    USBD_FS_SerialStrDescriptor, | ||||
|                                    USBD_FS_ConfigStrDescriptor, | ||||
|                                    USBD_FS_InterfaceStrDescriptor | ||||
| #if(USBD_LPM_ENABLED == 1) | ||||
|                                    , | ||||
|                                    USBD_FS_USR_BOSDescriptor | ||||
| #endif /* (USBD_LPM_ENABLED == 1) */ | ||||
| }; | ||||
| 
 | ||||
| #if defined ( __ICCARM__ ) /* IAR Compiler */ | ||||
|   #pragma data_alignment=4 | ||||
| #if defined(__ICCARM__) /* IAR Compiler */ | ||||
| #pragma data_alignment = 4 | ||||
| #endif /* defined ( __ICCARM__ ) */ | ||||
| /** USB standard device descriptor. */ | ||||
| __ALIGN_BEGIN uint8_t USBD_FS_DeviceDesc[USB_LEN_DEV_DESC] __ALIGN_END = | ||||
| { | ||||
|   0x12,                       /*bLength */ | ||||
|   USB_DESC_TYPE_DEVICE,       /*bDescriptorType*/ | ||||
| #if (USBD_LPM_ENABLED == 1) | ||||
|   0x01,                       /*bcdUSB */ /* changed to USB version 2.01
 | ||||
| __ALIGN_BEGIN uint8_t USBD_FS_DeviceDesc[USB_LEN_DEV_DESC] __ALIGN_END = { | ||||
|     0x12, /*bLength */ | ||||
|     USB_DESC_TYPE_DEVICE, /*bDescriptorType*/ | ||||
| #if(USBD_LPM_ENABLED == 1) | ||||
|     0x01, | ||||
| /*bcdUSB */ /* changed to USB version 2.01
 | ||||
|                                              in order to support LPM L1 suspend | ||||
|                                              resume test of USBCV3.0*/ | ||||
| #else | ||||
|   0x00,                       /*bcdUSB */ | ||||
|     0x00, /*bcdUSB */ | ||||
| #endif /* (USBD_LPM_ENABLED == 1) */ | ||||
|   0x02, | ||||
|   0x02,                       /*bDeviceClass*/ | ||||
|   0x02,                       /*bDeviceSubClass*/ | ||||
|   0x00,                       /*bDeviceProtocol*/ | ||||
|   USB_MAX_EP0_SIZE,           /*bMaxPacketSize*/ | ||||
|   LOBYTE(USBD_VID),           /*idVendor*/ | ||||
|   HIBYTE(USBD_VID),           /*idVendor*/ | ||||
|   LOBYTE(USBD_PID_FS),        /*idProduct*/ | ||||
|   HIBYTE(USBD_PID_FS),        /*idProduct*/ | ||||
|   0x00,                       /*bcdDevice rel. 2.00*/ | ||||
|   0x02, | ||||
|   USBD_IDX_MFC_STR,           /*Index of manufacturer  string*/ | ||||
|   USBD_IDX_PRODUCT_STR,       /*Index of product string*/ | ||||
|   USBD_IDX_SERIAL_STR,        /*Index of serial number string*/ | ||||
|   USBD_MAX_NUM_CONFIGURATION  /*bNumConfigurations*/ | ||||
|     0x02, | ||||
|     0x02, /*bDeviceClass*/ | ||||
|     0x02, /*bDeviceSubClass*/ | ||||
|     0x00, /*bDeviceProtocol*/ | ||||
|     USB_MAX_EP0_SIZE, /*bMaxPacketSize*/ | ||||
|     LOBYTE(USBD_VID), /*idVendor*/ | ||||
|     HIBYTE(USBD_VID), /*idVendor*/ | ||||
|     LOBYTE(USBD_PID_FS), /*idProduct*/ | ||||
|     HIBYTE(USBD_PID_FS), /*idProduct*/ | ||||
|     0x00, /*bcdDevice rel. 2.00*/ | ||||
|     0x02, | ||||
|     USBD_IDX_MFC_STR, /*Index of manufacturer  string*/ | ||||
|     USBD_IDX_PRODUCT_STR, /*Index of product string*/ | ||||
|     USBD_IDX_SERIAL_STR, /*Index of serial number string*/ | ||||
|     USBD_MAX_NUM_CONFIGURATION /*bNumConfigurations*/ | ||||
| }; | ||||
| 
 | ||||
| /* USB_DeviceDescriptor */ | ||||
| /** BOS descriptor. */ | ||||
| #if (USBD_LPM_ENABLED == 1) | ||||
| #if defined ( __ICCARM__ ) /* IAR Compiler */ | ||||
|   #pragma data_alignment=4 | ||||
| #if(USBD_LPM_ENABLED == 1) | ||||
| #if defined(__ICCARM__) /* IAR Compiler */ | ||||
| #pragma data_alignment = 4 | ||||
| #endif /* defined ( __ICCARM__ ) */ | ||||
| __ALIGN_BEGIN uint8_t USBD_FS_BOSDesc[USB_SIZ_BOS_DESC] __ALIGN_END = | ||||
| { | ||||
|   0x5, | ||||
|   USB_DESC_TYPE_BOS, | ||||
|   0xC, | ||||
|   0x0, | ||||
|   0x1,  /* 1 device capability*/ | ||||
|         /* device capability*/ | ||||
|   0x7, | ||||
|   USB_DEVICE_CAPABITY_TYPE, | ||||
|   0x2, | ||||
|   0x2,  /* LPM capability bit set*/ | ||||
|   0x0, | ||||
|   0x0, | ||||
|   0x0 | ||||
| }; | ||||
| __ALIGN_BEGIN uint8_t USBD_FS_BOSDesc[USB_SIZ_BOS_DESC] __ALIGN_END = { | ||||
|     0x5, | ||||
|     USB_DESC_TYPE_BOS, | ||||
|     0xC, | ||||
|     0x0, | ||||
|     0x1, /* 1 device capability*/ | ||||
|     /* device capability*/ | ||||
|     0x7, | ||||
|     USB_DEVICE_CAPABITY_TYPE, | ||||
|     0x2, | ||||
|     0x2, /* LPM capability bit set*/ | ||||
|     0x0, | ||||
|     0x0, | ||||
|     0x0}; | ||||
| #endif /* (USBD_LPM_ENABLED == 1) */ | ||||
| 
 | ||||
| /**
 | ||||
| @ -215,31 +211,29 @@ __ALIGN_BEGIN uint8_t USBD_FS_BOSDesc[USB_SIZ_BOS_DESC] __ALIGN_END = | ||||
|   * @{ | ||||
|   */ | ||||
| 
 | ||||
| #if defined ( __ICCARM__ ) /* IAR Compiler */ | ||||
|   #pragma data_alignment=4 | ||||
| #if defined(__ICCARM__) /* IAR Compiler */ | ||||
| #pragma data_alignment = 4 | ||||
| #endif /* defined ( __ICCARM__ ) */ | ||||
| 
 | ||||
| /** USB lang indentifier descriptor. */ | ||||
| __ALIGN_BEGIN uint8_t USBD_LangIDDesc[USB_LEN_LANGID_STR_DESC] __ALIGN_END = | ||||
| { | ||||
|      USB_LEN_LANGID_STR_DESC, | ||||
|      USB_DESC_TYPE_STRING, | ||||
|      LOBYTE(USBD_LANGID_STRING), | ||||
|      HIBYTE(USBD_LANGID_STRING) | ||||
| }; | ||||
| __ALIGN_BEGIN uint8_t USBD_LangIDDesc[USB_LEN_LANGID_STR_DESC] __ALIGN_END = { | ||||
|     USB_LEN_LANGID_STR_DESC, | ||||
|     USB_DESC_TYPE_STRING, | ||||
|     LOBYTE(USBD_LANGID_STRING), | ||||
|     HIBYTE(USBD_LANGID_STRING)}; | ||||
| 
 | ||||
| #if defined ( __ICCARM__ ) /* IAR Compiler */ | ||||
|   #pragma data_alignment=4 | ||||
| #if defined(__ICCARM__) /* IAR Compiler */ | ||||
| #pragma data_alignment = 4 | ||||
| #endif /* defined ( __ICCARM__ ) */ | ||||
| /* Internal string descriptor. */ | ||||
| __ALIGN_BEGIN uint8_t USBD_StrDesc[USBD_MAX_STR_DESC_SIZ] __ALIGN_END; | ||||
| 
 | ||||
| #if defined ( __ICCARM__ ) /*!< IAR Compiler */ | ||||
|   #pragma data_alignment=4    | ||||
| #if defined(__ICCARM__) /*!< IAR Compiler */ | ||||
| #pragma data_alignment = 4 | ||||
| #endif | ||||
| __ALIGN_BEGIN uint8_t USBD_StringSerial[USB_SIZ_STRING_SERIAL] __ALIGN_END = { | ||||
|   USB_SIZ_STRING_SERIAL, | ||||
|   USB_DESC_TYPE_STRING, | ||||
|     USB_SIZ_STRING_SERIAL, | ||||
|     USB_DESC_TYPE_STRING, | ||||
| }; | ||||
| 
 | ||||
| /**
 | ||||
| @ -257,11 +251,10 @@ __ALIGN_BEGIN uint8_t USBD_StringSerial[USB_SIZ_STRING_SERIAL] __ALIGN_END = { | ||||
|   * @param  length : Pointer to data length variable | ||||
|   * @retval Pointer to descriptor buffer | ||||
|   */ | ||||
| uint8_t * USBD_FS_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) | ||||
| { | ||||
|   UNUSED(speed); | ||||
|   *length = sizeof(USBD_FS_DeviceDesc); | ||||
|   return USBD_FS_DeviceDesc; | ||||
| uint8_t* USBD_FS_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t* length) { | ||||
|     UNUSED(speed); | ||||
|     *length = sizeof(USBD_FS_DeviceDesc); | ||||
|     return USBD_FS_DeviceDesc; | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -270,11 +263,10 @@ uint8_t * USBD_FS_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) | ||||
|   * @param  length : Pointer to data length variable | ||||
|   * @retval Pointer to descriptor buffer | ||||
|   */ | ||||
| uint8_t * USBD_FS_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) | ||||
| { | ||||
|   UNUSED(speed); | ||||
|   *length = sizeof(USBD_LangIDDesc); | ||||
|   return USBD_LangIDDesc; | ||||
| uint8_t* USBD_FS_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t* length) { | ||||
|     UNUSED(speed); | ||||
|     *length = sizeof(USBD_LangIDDesc); | ||||
|     return USBD_LangIDDesc; | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -283,17 +275,13 @@ uint8_t * USBD_FS_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) | ||||
|   * @param  length : Pointer to data length variable | ||||
|   * @retval Pointer to descriptor buffer | ||||
|   */ | ||||
| uint8_t * USBD_FS_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) | ||||
| { | ||||
|   if(speed == 0) | ||||
|   { | ||||
|     USBD_GetString((uint8_t *)USBD_PRODUCT_STRING_FS, USBD_StrDesc, length); | ||||
|   } | ||||
|   else | ||||
|   { | ||||
|     USBD_GetString((uint8_t *)USBD_PRODUCT_STRING_FS, USBD_StrDesc, length); | ||||
|   } | ||||
|   return USBD_StrDesc; | ||||
| uint8_t* USBD_FS_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t* length) { | ||||
|     if(speed == 0) { | ||||
|         USBD_GetString((uint8_t*)USBD_PRODUCT_STRING_FS, USBD_StrDesc, length); | ||||
|     } else { | ||||
|         USBD_GetString((uint8_t*)USBD_PRODUCT_STRING_FS, USBD_StrDesc, length); | ||||
|     } | ||||
|     return USBD_StrDesc; | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -302,11 +290,10 @@ uint8_t * USBD_FS_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length | ||||
|   * @param  length : Pointer to data length variable | ||||
|   * @retval Pointer to descriptor buffer | ||||
|   */ | ||||
| uint8_t * USBD_FS_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) | ||||
| { | ||||
|   UNUSED(speed); | ||||
|   USBD_GetString((uint8_t *)USBD_MANUFACTURER_STRING, USBD_StrDesc, length); | ||||
|   return USBD_StrDesc; | ||||
| uint8_t* USBD_FS_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t* length) { | ||||
|     UNUSED(speed); | ||||
|     USBD_GetString((uint8_t*)USBD_MANUFACTURER_STRING, USBD_StrDesc, length); | ||||
|     return USBD_StrDesc; | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -315,18 +302,17 @@ uint8_t * USBD_FS_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *l | ||||
|   * @param  length : Pointer to data length variable | ||||
|   * @retval Pointer to descriptor buffer | ||||
|   */ | ||||
| uint8_t * USBD_FS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) | ||||
| { | ||||
|   UNUSED(speed); | ||||
|   *length = USB_SIZ_STRING_SERIAL; | ||||
| uint8_t* USBD_FS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t* length) { | ||||
|     UNUSED(speed); | ||||
|     *length = USB_SIZ_STRING_SERIAL; | ||||
| 
 | ||||
|   /* Update the serial number string descriptor with the data from the unique
 | ||||
|     /* Update the serial number string descriptor with the data from the unique
 | ||||
|    * ID */ | ||||
|   Get_SerialNum(); | ||||
|   /* USER CODE BEGIN USBD_FS_SerialStrDescriptor */ | ||||
|     Get_SerialNum(); | ||||
|     /* USER CODE BEGIN USBD_FS_SerialStrDescriptor */ | ||||
| 
 | ||||
|   /* USER CODE END USBD_FS_SerialStrDescriptor */ | ||||
|   return (uint8_t *) USBD_StringSerial; | ||||
|     /* USER CODE END USBD_FS_SerialStrDescriptor */ | ||||
|     return (uint8_t*)USBD_StringSerial; | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -335,17 +321,13 @@ uint8_t * USBD_FS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) | ||||
|   * @param  length : Pointer to data length variable | ||||
|   * @retval Pointer to descriptor buffer | ||||
|   */ | ||||
| uint8_t * USBD_FS_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) | ||||
| { | ||||
|   if(speed == USBD_SPEED_HIGH) | ||||
|   { | ||||
|     USBD_GetString((uint8_t *)USBD_CONFIGURATION_STRING_FS, USBD_StrDesc, length); | ||||
|   } | ||||
|   else | ||||
|   { | ||||
|     USBD_GetString((uint8_t *)USBD_CONFIGURATION_STRING_FS, USBD_StrDesc, length); | ||||
|   } | ||||
|   return USBD_StrDesc; | ||||
| uint8_t* USBD_FS_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t* length) { | ||||
|     if(speed == USBD_SPEED_HIGH) { | ||||
|         USBD_GetString((uint8_t*)USBD_CONFIGURATION_STRING_FS, USBD_StrDesc, length); | ||||
|     } else { | ||||
|         USBD_GetString((uint8_t*)USBD_CONFIGURATION_STRING_FS, USBD_StrDesc, length); | ||||
|     } | ||||
|     return USBD_StrDesc; | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -354,31 +336,26 @@ uint8_t * USBD_FS_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) | ||||
|   * @param  length : Pointer to data length variable | ||||
|   * @retval Pointer to descriptor buffer | ||||
|   */ | ||||
| uint8_t * USBD_FS_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) | ||||
| { | ||||
|   if(speed == 0) | ||||
|   { | ||||
|     USBD_GetString((uint8_t *)USBD_INTERFACE_STRING_FS, USBD_StrDesc, length); | ||||
|   } | ||||
|   else | ||||
|   { | ||||
|     USBD_GetString((uint8_t *)USBD_INTERFACE_STRING_FS, USBD_StrDesc, length); | ||||
|   } | ||||
|   return USBD_StrDesc; | ||||
| uint8_t* USBD_FS_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t* length) { | ||||
|     if(speed == 0) { | ||||
|         USBD_GetString((uint8_t*)USBD_INTERFACE_STRING_FS, USBD_StrDesc, length); | ||||
|     } else { | ||||
|         USBD_GetString((uint8_t*)USBD_INTERFACE_STRING_FS, USBD_StrDesc, length); | ||||
|     } | ||||
|     return USBD_StrDesc; | ||||
| } | ||||
| 
 | ||||
| #if (USBD_LPM_ENABLED == 1) | ||||
| #if(USBD_LPM_ENABLED == 1) | ||||
| /**
 | ||||
|   * @brief  Return the BOS descriptor | ||||
|   * @param  speed : Current device speed | ||||
|   * @param  length : Pointer to data length variable | ||||
|   * @retval Pointer to descriptor buffer | ||||
|   */ | ||||
| uint8_t * USBD_FS_USR_BOSDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) | ||||
| { | ||||
|   UNUSED(speed); | ||||
|   *length = sizeof(USBD_FS_BOSDesc); | ||||
|   return (uint8_t*)USBD_FS_BOSDesc; | ||||
| uint8_t* USBD_FS_USR_BOSDescriptor(USBD_SpeedTypeDef speed, uint16_t* length) { | ||||
|     UNUSED(speed); | ||||
|     *length = sizeof(USBD_FS_BOSDesc); | ||||
|     return (uint8_t*)USBD_FS_BOSDesc; | ||||
| } | ||||
| #endif /* (USBD_LPM_ENABLED == 1) */ | ||||
| 
 | ||||
| @ -387,21 +364,19 @@ uint8_t * USBD_FS_USR_BOSDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) | ||||
|   * @param  None  | ||||
|   * @retval None | ||||
|   */ | ||||
| static void Get_SerialNum(void) | ||||
| { | ||||
|   uint32_t deviceserial0, deviceserial1, deviceserial2; | ||||
| static void Get_SerialNum(void) { | ||||
|     uint32_t deviceserial0, deviceserial1, deviceserial2; | ||||
| 
 | ||||
|   deviceserial0 = *(uint32_t *) DEVICE_ID1; | ||||
|   deviceserial1 = *(uint32_t *) DEVICE_ID2; | ||||
|   deviceserial2 = *(uint32_t *) DEVICE_ID3; | ||||
|     deviceserial0 = *(uint32_t*)DEVICE_ID1; | ||||
|     deviceserial1 = *(uint32_t*)DEVICE_ID2; | ||||
|     deviceserial2 = *(uint32_t*)DEVICE_ID3; | ||||
| 
 | ||||
|   deviceserial0 += deviceserial2; | ||||
|     deviceserial0 += deviceserial2; | ||||
| 
 | ||||
|   if (deviceserial0 != 0) | ||||
|   { | ||||
|     IntToUnicode(deviceserial0, &USBD_StringSerial[2], 8); | ||||
|     IntToUnicode(deviceserial1, &USBD_StringSerial[18], 4); | ||||
|   } | ||||
|     if(deviceserial0 != 0) { | ||||
|         IntToUnicode(deviceserial0, &USBD_StringSerial[2], 8); | ||||
|         IntToUnicode(deviceserial1, &USBD_StringSerial[18], 4); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -411,25 +386,20 @@ static void Get_SerialNum(void) | ||||
|   * @param  len: buffer length | ||||
|   * @retval None | ||||
|   */ | ||||
| static void IntToUnicode(uint32_t value, uint8_t * pbuf, uint8_t len) | ||||
| { | ||||
|   uint8_t idx = 0; | ||||
| static void IntToUnicode(uint32_t value, uint8_t* pbuf, uint8_t len) { | ||||
|     uint8_t idx = 0; | ||||
| 
 | ||||
|   for (idx = 0; idx < len; idx++) | ||||
|   { | ||||
|     if (((value >> 28)) < 0xA) | ||||
|     { | ||||
|       pbuf[2 * idx] = (value >> 28) + '0'; | ||||
|     for(idx = 0; idx < len; idx++) { | ||||
|         if(((value >> 28)) < 0xA) { | ||||
|             pbuf[2 * idx] = (value >> 28) + '0'; | ||||
|         } else { | ||||
|             pbuf[2 * idx] = (value >> 28) + 'A' - 10; | ||||
|         } | ||||
| 
 | ||||
|         value = value << 4; | ||||
| 
 | ||||
|         pbuf[2 * idx + 1] = 0; | ||||
|     } | ||||
|     else | ||||
|     { | ||||
|       pbuf[2 * idx] = (value >> 28) + 'A' - 10; | ||||
|     } | ||||
| 
 | ||||
|     value = value << 4; | ||||
| 
 | ||||
|     pbuf[2 * idx + 1] = 0; | ||||
|   } | ||||
| } | ||||
| /**
 | ||||
|   * @} | ||||
|  | ||||
| @ -25,7 +25,7 @@ | ||||
|  * | ||||
|  * 1 tab == 4 spaces! | ||||
|  */ | ||||
|  /* USER CODE END Header */ | ||||
| /* USER CODE END Header */ | ||||
| 
 | ||||
| #ifndef FREERTOS_CONFIG_H | ||||
| #define FREERTOS_CONFIG_H | ||||
| @ -48,9 +48,9 @@ | ||||
| 
 | ||||
| /* Ensure definitions are only used by the compiler, and not by the assembler. */ | ||||
| #if defined(__ICCARM__) || defined(__CC_ARM) || defined(__GNUC__) | ||||
|   #include <stdint.h> | ||||
|   extern uint32_t SystemCoreClock; | ||||
|   void xPortSysTickHandler(void); | ||||
| #include <stdint.h> | ||||
| extern uint32_t SystemCoreClock; | ||||
| void xPortSysTickHandler(void); | ||||
| #endif | ||||
| #define configUSE_PREEMPTION                     1 | ||||
| #define configSUPPORT_STATIC_ALLOCATION          1 | ||||
| @ -71,37 +71,37 @@ | ||||
| #define configNUM_THREAD_LOCAL_STORAGE_POINTERS  1 | ||||
| 
 | ||||
| /* Co-routine definitions. */ | ||||
| #define configUSE_CO_ROUTINES                    0 | ||||
| #define configMAX_CO_ROUTINE_PRIORITIES          ( 2 ) | ||||
| #define configUSE_CO_ROUTINES 0 | ||||
| #define configMAX_CO_ROUTINE_PRIORITIES (2) | ||||
| 
 | ||||
| /* Software timer definitions. */ | ||||
| #define configUSE_TIMERS                         1 | ||||
| #define configTIMER_TASK_PRIORITY                ( 2 ) | ||||
| #define configTIMER_QUEUE_LENGTH                 10 | ||||
| #define configTIMER_TASK_STACK_DEPTH             256 | ||||
| #define configUSE_TIMERS 1 | ||||
| #define configTIMER_TASK_PRIORITY (2) | ||||
| #define configTIMER_QUEUE_LENGTH 10 | ||||
| #define configTIMER_TASK_STACK_DEPTH 256 | ||||
| 
 | ||||
| /* Set the following definitions to 1 to include the API function, or zero
 | ||||
| to exclude the API function. */ | ||||
| #define INCLUDE_vTaskPrioritySet            1 | ||||
| #define INCLUDE_uxTaskPriorityGet           1 | ||||
| #define INCLUDE_vTaskDelete                 1 | ||||
| #define INCLUDE_vTaskCleanUpResources       0 | ||||
| #define INCLUDE_vTaskSuspend                1 | ||||
| #define INCLUDE_vTaskDelayUntil             0 | ||||
| #define INCLUDE_vTaskDelay                  1 | ||||
| #define INCLUDE_xTaskGetSchedulerState      1 | ||||
| #define INCLUDE_vTaskPrioritySet 1 | ||||
| #define INCLUDE_uxTaskPriorityGet 1 | ||||
| #define INCLUDE_vTaskDelete 1 | ||||
| #define INCLUDE_vTaskCleanUpResources 0 | ||||
| #define INCLUDE_vTaskSuspend 1 | ||||
| #define INCLUDE_vTaskDelayUntil 0 | ||||
| #define INCLUDE_vTaskDelay 1 | ||||
| #define INCLUDE_xTaskGetSchedulerState 1 | ||||
| 
 | ||||
| /* Cortex-M specific definitions. */ | ||||
| #ifdef __NVIC_PRIO_BITS | ||||
|  /* __BVIC_PRIO_BITS will be specified when CMSIS is being used. */ | ||||
|  #define configPRIO_BITS         __NVIC_PRIO_BITS | ||||
| /* __BVIC_PRIO_BITS will be specified when CMSIS is being used. */ | ||||
| #define configPRIO_BITS __NVIC_PRIO_BITS | ||||
| #else | ||||
|  #define configPRIO_BITS         4 | ||||
| #define configPRIO_BITS 4 | ||||
| #endif | ||||
| 
 | ||||
| /* The lowest interrupt priority that can be used in a call to a "set priority"
 | ||||
| function. */ | ||||
| #define configLIBRARY_LOWEST_INTERRUPT_PRIORITY   15 | ||||
| #define configLIBRARY_LOWEST_INTERRUPT_PRIORITY 15 | ||||
| 
 | ||||
| /* The highest interrupt priority that can be used by any interrupt service
 | ||||
| routine that makes calls to interrupt safe FreeRTOS API functions.  DO NOT CALL | ||||
| @ -111,20 +111,27 @@ PRIORITY THAN THIS! (higher priorities are lower numeric values. */ | ||||
| 
 | ||||
| /* Interrupt priorities used by the kernel port layer itself.  These are generic
 | ||||
| to all Cortex-M ports, and do not rely on any particular library functions. */ | ||||
| #define configKERNEL_INTERRUPT_PRIORITY 		( configLIBRARY_LOWEST_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) ) | ||||
| #define configKERNEL_INTERRUPT_PRIORITY \ | ||||
|     (configLIBRARY_LOWEST_INTERRUPT_PRIORITY << (8 - configPRIO_BITS)) | ||||
| /* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!!
 | ||||
| See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */
 | ||||
| #define configMAX_SYSCALL_INTERRUPT_PRIORITY 	( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) ) | ||||
| #define configMAX_SYSCALL_INTERRUPT_PRIORITY \ | ||||
|     (configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS)) | ||||
| 
 | ||||
| /* Normal assert() semantics without relying on the provision of an assert.h
 | ||||
| header file. */ | ||||
| /* USER CODE BEGIN 1 */ | ||||
| #define configASSERT( x ) if ((x) == 0) {taskDISABLE_INTERRUPTS(); for( ;; );}  | ||||
| #define configASSERT(x)           \ | ||||
|     if((x) == 0) {                \ | ||||
|         taskDISABLE_INTERRUPTS(); \ | ||||
|         for(;;)                   \ | ||||
|             ;                     \ | ||||
|     } | ||||
| /* USER CODE END 1 */ | ||||
| 
 | ||||
| /* Definitions that map the FreeRTOS port interrupt handlers to their CMSIS
 | ||||
| standard names. */ | ||||
| #define vPortSVCHandler    SVC_Handler | ||||
| #define vPortSVCHandler SVC_Handler | ||||
| #define xPortPendSVHandler PendSV_Handler | ||||
| 
 | ||||
| /* IMPORTANT: This define is commented when used with STM32Cube firmware, when the timebase source is SysTick,
 | ||||
|  | ||||
| @ -9,11 +9,7 @@ GPIO and HAL implementations | ||||
| #include <stdbool.h> | ||||
| #include "main.h" | ||||
| 
 | ||||
| typedef enum { | ||||
|     GpioModeInput, | ||||
|     GpioModeOutput, | ||||
|     GpioModeOpenDrain | ||||
| } GpioMode; | ||||
| typedef enum { GpioModeInput, GpioModeOutput, GpioModeOpenDrain } GpioMode; | ||||
| 
 | ||||
| typedef struct { | ||||
|     GPIO_TypeDef* port; | ||||
| @ -50,7 +46,8 @@ inline void app_tim_ic_init(bool both) { | ||||
|     HAL_TIM_OC_Stop(&htim8, TIM_CHANNEL_2); | ||||
| 
 | ||||
|     TIM_IC_InitTypeDef sConfigIC = {0}; | ||||
|     sConfigIC.ICPolarity = both ? TIM_INPUTCHANNELPOLARITY_BOTHEDGE : TIM_INPUTCHANNELPOLARITY_FALLING; | ||||
|     sConfigIC.ICPolarity = both ? TIM_INPUTCHANNELPOLARITY_BOTHEDGE : | ||||
|                                   TIM_INPUTCHANNELPOLARITY_FALLING; | ||||
|     sConfigIC.ICSelection = TIM_ICSELECTION_DIRECTTI; | ||||
|     sConfigIC.ICPrescaler = TIM_ICPSC_DIV1; | ||||
|     sConfigIC.ICFilter = 0; | ||||
|  | ||||
| @ -38,10 +38,7 @@ extern "C" { | ||||
| /* Exported types ------------------------------------------------------------*/ | ||||
| /* USER CODE BEGIN ET */ | ||||
| 
 | ||||
| typedef enum { | ||||
|   TimerEventInputCapture, | ||||
|   TimerEventEndOfPulse | ||||
| } TimerEvent; | ||||
| typedef enum { TimerEventInputCapture, TimerEventEndOfPulse } TimerEvent; | ||||
| 
 | ||||
| /* USER CODE END ET */ | ||||
| 
 | ||||
| @ -55,14 +52,14 @@ typedef enum { | ||||
| 
 | ||||
| /* USER CODE END EM */ | ||||
| 
 | ||||
| void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim); | ||||
| void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim); | ||||
| 
 | ||||
| /* Exported functions prototypes ---------------------------------------------*/ | ||||
| void Error_Handler(void); | ||||
| 
 | ||||
| /* USER CODE BEGIN EFP */ | ||||
| 
 | ||||
| void register_tim8_callback_ch2(void(*callback)(uint16_t ccr, TimerEvent tim_event)); | ||||
| void register_tim8_callback_ch2(void (*callback)(uint16_t ccr, TimerEvent tim_event)); | ||||
| 
 | ||||
| /* USER CODE END EFP */ | ||||
| 
 | ||||
| @ -139,12 +136,24 @@ void register_tim8_callback_ch2(void(*callback)(uint16_t ccr, TimerEvent tim_eve | ||||
| #define EM_PIN_GPIO_Port RFID_OUT_GPIO_Port | ||||
| #define EM_PIN_Pin RFID_OUT_Pin | ||||
| 
 | ||||
| #define MISO_PIN GpioPin{.port = GPIOC, .pin = GPIO_PIN_11} | ||||
| #define MISO_PIN                          \ | ||||
|     GpioPin {                             \ | ||||
|         .port = GPIOC, .pin = GPIO_PIN_11 \ | ||||
|     } | ||||
| // #define MOSI_PIN 11
 | ||||
| #define SS_PIN   GpioPin{.port = CC1101_CS_GPIO_Port, .pin = CC1101_CS_Pin} | ||||
| #define SS_PIN                                            \ | ||||
|     GpioPin {                                             \ | ||||
|         .port = CC1101_CS_GPIO_Port, .pin = CC1101_CS_Pin \ | ||||
|     } | ||||
| //2 main, 5 remote, 3 M16
 | ||||
| #define GDO2     GpioPin{.port = NULL, .pin = 0} | ||||
| #define GDO0     GpioPin{.port = CC1101_G0_GPIO_Port, .pin = CC1101_G0_Pin} | ||||
| #define GDO2                   \ | ||||
|     GpioPin {                  \ | ||||
|         .port = NULL, .pin = 0 \ | ||||
|     } | ||||
| #define GDO0                                              \ | ||||
|     GpioPin {                                             \ | ||||
|         .port = CC1101_G0_GPIO_Port, .pin = CC1101_G0_Pin \ | ||||
|     } | ||||
| 
 | ||||
| /* USER CODE END Private defines */ | ||||
| 
 | ||||
|  | ||||
| @ -37,7 +37,7 @@ | ||||
| #define __STM32L4xx_HAL_CONF_H | ||||
| 
 | ||||
| #ifdef __cplusplus | ||||
|  extern "C" { | ||||
| extern "C" { | ||||
| #endif | ||||
| 
 | ||||
| /* Exported types ------------------------------------------------------------*/ | ||||
| @ -109,28 +109,28 @@ | ||||
|   *        This value is used by the RCC HAL module to compute the system frequency | ||||
|   *        (when HSE is used as system clock source, directly or through the PLL).   | ||||
|   */ | ||||
| #if !defined  (HSE_VALUE)  | ||||
|   #define HSE_VALUE    ((uint32_t)16000000U) /*!< Value of the External oscillator in Hz */ | ||||
| #if !defined(HSE_VALUE) | ||||
| #define HSE_VALUE ((uint32_t)16000000U) /*!< Value of the External oscillator in Hz */ | ||||
| #endif /* HSE_VALUE */ | ||||
| 
 | ||||
| #if !defined  (HSE_STARTUP_TIMEOUT) | ||||
|   #define HSE_STARTUP_TIMEOUT    ((uint32_t)100U)   /*!< Time out for HSE start up, in ms */ | ||||
| #if !defined(HSE_STARTUP_TIMEOUT) | ||||
| #define HSE_STARTUP_TIMEOUT ((uint32_t)100U) /*!< Time out for HSE start up, in ms */ | ||||
| #endif /* HSE_STARTUP_TIMEOUT */ | ||||
| 
 | ||||
| /**
 | ||||
|   * @brief Internal Multiple Speed oscillator (MSI) default value. | ||||
|   *        This value is the default MSI range value after Reset. | ||||
|   */ | ||||
| #if !defined  (MSI_VALUE) | ||||
|   #define MSI_VALUE    ((uint32_t)4000000U) /*!< Value of the Internal oscillator in Hz*/ | ||||
| #if !defined(MSI_VALUE) | ||||
| #define MSI_VALUE ((uint32_t)4000000U) /*!< Value of the Internal oscillator in Hz*/ | ||||
| #endif /* MSI_VALUE */ | ||||
| /**
 | ||||
|   * @brief Internal High Speed oscillator (HSI) value. | ||||
|   *        This value is used by the RCC HAL module to compute the system frequency | ||||
|   *        (when HSI is used as system clock source, directly or through the PLL).  | ||||
|   */ | ||||
| #if !defined  (HSI_VALUE) | ||||
|   #define HSI_VALUE    ((uint32_t)16000000U) /*!< Value of the Internal oscillator in Hz*/ | ||||
| #if !defined(HSI_VALUE) | ||||
| #define HSI_VALUE ((uint32_t)16000000U) /*!< Value of the Internal oscillator in Hz*/ | ||||
| #endif /* HSI_VALUE */ | ||||
| 
 | ||||
| /**
 | ||||
| @ -140,17 +140,18 @@ | ||||
|   *        When the CRS is not used, the HSI48 RC oscillator runs on it default frequency | ||||
|   *        which is subject to manufacturing process variations. | ||||
|   */ | ||||
| #if !defined  (HSI48_VALUE)  | ||||
|  #define HSI48_VALUE   ((uint32_t)48000000U) /*!< Value of the Internal High Speed oscillator for USB FS/SDMMC/RNG in Hz. | ||||
| #if !defined(HSI48_VALUE) | ||||
| #define HSI48_VALUE \ | ||||
|     ((uint32_t)48000000U) /*!< Value of the Internal High Speed oscillator for USB FS/SDMMC/RNG in Hz.
 | ||||
|                                               The real value my vary depending on manufacturing process variations.*/ | ||||
| #endif /* HSI48_VALUE */ | ||||
| 
 | ||||
| /**
 | ||||
|   * @brief Internal Low Speed oscillator (LSI) value. | ||||
|   */ | ||||
| #if !defined  (LSI_VALUE)  | ||||
|  #define LSI_VALUE  ((uint32_t)32000U)       /*!< LSI Typical Value in Hz*/ | ||||
| #endif /* LSI_VALUE */                      /*!< Value of the Internal Low Speed oscillator in Hz | ||||
| #if !defined(LSI_VALUE) | ||||
| #define LSI_VALUE ((uint32_t)32000U) /*!< LSI Typical Value in Hz*/ | ||||
| #endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz | ||||
|                                              The real value may vary depending on the variations | ||||
|                                              in voltage and temperature.*/ | ||||
| 
 | ||||
| @ -158,12 +159,12 @@ | ||||
|   * @brief External Low Speed oscillator (LSE) value. | ||||
|   *        This value is used by the UART, RTC HAL module to compute the system frequency | ||||
|   */ | ||||
| #if !defined  (LSE_VALUE) | ||||
|   #define LSE_VALUE    ((uint32_t)32768U) /*!< Value of the External oscillator in Hz*/ | ||||
| #if !defined(LSE_VALUE) | ||||
| #define LSE_VALUE ((uint32_t)32768U) /*!< Value of the External oscillator in Hz*/ | ||||
| #endif /* LSE_VALUE */ | ||||
| 
 | ||||
| #if !defined  (LSE_STARTUP_TIMEOUT) | ||||
|   #define LSE_STARTUP_TIMEOUT    ((uint32_t)5000U)   /*!< Time out for LSE start up, in ms */ | ||||
| #if !defined(LSE_STARTUP_TIMEOUT) | ||||
| #define LSE_STARTUP_TIMEOUT ((uint32_t)5000U) /*!< Time out for LSE start up, in ms */ | ||||
| #endif /* HSE_STARTUP_TIMEOUT */ | ||||
| 
 | ||||
| /**
 | ||||
| @ -171,8 +172,9 @@ | ||||
|   *        This value is used by the RCC HAL module to compute the SAI1 & SAI2 clock source  | ||||
|   *        frequency. | ||||
|   */ | ||||
| #if !defined  (EXTERNAL_SAI1_CLOCK_VALUE) | ||||
|   #define EXTERNAL_SAI1_CLOCK_VALUE    ((uint32_t)2097000U) /*!< Value of the SAI1 External clock source in Hz*/ | ||||
| #if !defined(EXTERNAL_SAI1_CLOCK_VALUE) | ||||
| #define EXTERNAL_SAI1_CLOCK_VALUE \ | ||||
|     ((uint32_t)2097000U) /*!< Value of the SAI1 External clock source in Hz*/ | ||||
| #endif /* EXTERNAL_SAI1_CLOCK_VALUE */ | ||||
| 
 | ||||
| /**
 | ||||
| @ -180,8 +182,9 @@ | ||||
|   *        This value is used by the RCC HAL module to compute the SAI1 & SAI2 clock source  | ||||
|   *        frequency. | ||||
|   */ | ||||
| #if !defined  (EXTERNAL_SAI2_CLOCK_VALUE) | ||||
|   #define EXTERNAL_SAI2_CLOCK_VALUE    ((uint32_t)2097000U) /*!< Value of the SAI2 External clock source in Hz*/ | ||||
| #if !defined(EXTERNAL_SAI2_CLOCK_VALUE) | ||||
| #define EXTERNAL_SAI2_CLOCK_VALUE \ | ||||
|     ((uint32_t)2097000U) /*!< Value of the SAI2 External clock source in Hz*/ | ||||
| #endif /* EXTERNAL_SAI2_CLOCK_VALUE */ | ||||
| 
 | ||||
| /* Tip: To avoid modifying this file each time you need to use different HSE,
 | ||||
| @ -192,12 +195,12 @@ | ||||
|   * @brief This is the HAL system configuration section | ||||
|   */ | ||||
| 
 | ||||
| #define  VDD_VALUE					  ((uint32_t)3300U) /*!< Value of VDD in mv */            | ||||
| #define  TICK_INT_PRIORITY            ((uint32_t)15U)    /*!< tick interrupt priority */             | ||||
| #define  USE_RTOS                     0U      | ||||
| #define  PREFETCH_ENABLE              1U | ||||
| #define  INSTRUCTION_CACHE_ENABLE     1U | ||||
| #define  DATA_CACHE_ENABLE            1U | ||||
| #define VDD_VALUE ((uint32_t)3300U) /*!< Value of VDD in mv */ | ||||
| #define TICK_INT_PRIORITY ((uint32_t)15U) /*!< tick interrupt priority */ | ||||
| #define USE_RTOS 0U | ||||
| #define PREFETCH_ENABLE 1U | ||||
| #define INSTRUCTION_CACHE_ENABLE 1U | ||||
| #define DATA_CACHE_ENABLE 1U | ||||
| 
 | ||||
| /* ########################## Assert Selection ############################## */ | ||||
| /**
 | ||||
| @ -213,7 +216,7 @@ | ||||
|  * Deactivated: CRC code cleaned from driver | ||||
|  */ | ||||
| 
 | ||||
| #define USE_SPI_CRC                   0U | ||||
| #define USE_SPI_CRC 0U | ||||
| 
 | ||||
| /* Includes ------------------------------------------------------------------*/ | ||||
| /**
 | ||||
| @ -221,201 +224,201 @@ | ||||
|   */ | ||||
| 
 | ||||
| #ifdef HAL_RCC_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_rcc.h" | ||||
|   #include "stm32l4xx_hal_rcc_ex.h" | ||||
| #include "stm32l4xx_hal_rcc.h" | ||||
| #include "stm32l4xx_hal_rcc_ex.h" | ||||
| #endif /* HAL_RCC_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_EXTI_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_exti.h" | ||||
| #include "stm32l4xx_hal_exti.h" | ||||
| #endif /* HAL_EXTI_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_GPIO_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_gpio.h" | ||||
| #include "stm32l4xx_hal_gpio.h" | ||||
| #endif /* HAL_GPIO_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_DMA_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_dma.h" | ||||
|   #include "stm32l4xx_hal_dma_ex.h" | ||||
| #include "stm32l4xx_hal_dma.h" | ||||
| #include "stm32l4xx_hal_dma_ex.h" | ||||
| #endif /* HAL_DMA_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_DFSDM_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_dfsdm.h" | ||||
| #include "stm32l4xx_hal_dfsdm.h" | ||||
| #endif /* HAL_DFSDM_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_CORTEX_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_cortex.h" | ||||
| #include "stm32l4xx_hal_cortex.h" | ||||
| #endif /* HAL_CORTEX_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_ADC_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_adc.h" | ||||
| #include "stm32l4xx_hal_adc.h" | ||||
| #endif /* HAL_ADC_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_CAN_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_can.h" | ||||
| #include "stm32l4xx_hal_can.h" | ||||
| #endif /* HAL_CAN_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_COMP_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_comp.h" | ||||
| #include "stm32l4xx_hal_comp.h" | ||||
| #endif /* HAL_COMP_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_CRC_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_crc.h" | ||||
| #include "stm32l4xx_hal_crc.h" | ||||
| #endif /* HAL_CRC_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_CRYP_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_cryp.h" | ||||
| #include "stm32l4xx_hal_cryp.h" | ||||
| #endif /* HAL_CRYP_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_DAC_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_dac.h" | ||||
| #include "stm32l4xx_hal_dac.h" | ||||
| #endif /* HAL_DAC_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_DCMI_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_dcmi.h" | ||||
| #include "stm32l4xx_hal_dcmi.h" | ||||
| #endif /* HAL_DCMI_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_DMA2D_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_dma2d.h" | ||||
| #include "stm32l4xx_hal_dma2d.h" | ||||
| #endif /* HAL_DMA2D_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_DSI_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_dsi.h" | ||||
| #include "stm32l4xx_hal_dsi.h" | ||||
| #endif /* HAL_DSI_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_FIREWALL_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_firewall.h" | ||||
| #include "stm32l4xx_hal_firewall.h" | ||||
| #endif /* HAL_FIREWALL_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_FLASH_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_flash.h" | ||||
| #include "stm32l4xx_hal_flash.h" | ||||
| #endif /* HAL_FLASH_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_HASH_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_hash.h" | ||||
| #include "stm32l4xx_hal_hash.h" | ||||
| #endif /* HAL_HASH_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_SRAM_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_sram.h" | ||||
| #include "stm32l4xx_hal_sram.h" | ||||
| #endif /* HAL_SRAM_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_MMC_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_mmc.h" | ||||
| #include "stm32l4xx_hal_mmc.h" | ||||
| #endif /* HAL_MMC_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_NOR_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_nor.h" | ||||
| #include "stm32l4xx_hal_nor.h" | ||||
| #endif /* HAL_NOR_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_NAND_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_nand.h" | ||||
| #include "stm32l4xx_hal_nand.h" | ||||
| #endif /* HAL_NAND_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_I2C_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_i2c.h" | ||||
| #include "stm32l4xx_hal_i2c.h" | ||||
| #endif /* HAL_I2C_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_IWDG_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_iwdg.h" | ||||
| #include "stm32l4xx_hal_iwdg.h" | ||||
| #endif /* HAL_IWDG_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_LCD_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_lcd.h" | ||||
| #include "stm32l4xx_hal_lcd.h" | ||||
| #endif /* HAL_LCD_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_LPTIM_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_lptim.h" | ||||
| #include "stm32l4xx_hal_lptim.h" | ||||
| #endif /* HAL_LPTIM_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_LTDC_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_ltdc.h" | ||||
| #include "stm32l4xx_hal_ltdc.h" | ||||
| #endif /* HAL_LTDC_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_OPAMP_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_opamp.h" | ||||
| #include "stm32l4xx_hal_opamp.h" | ||||
| #endif /* HAL_OPAMP_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_OSPI_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_ospi.h" | ||||
| #include "stm32l4xx_hal_ospi.h" | ||||
| #endif /* HAL_OSPI_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_PWR_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_pwr.h" | ||||
| #include "stm32l4xx_hal_pwr.h" | ||||
| #endif /* HAL_PWR_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_QSPI_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_qspi.h" | ||||
| #include "stm32l4xx_hal_qspi.h" | ||||
| #endif /* HAL_QSPI_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_RNG_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_rng.h" | ||||
| #include "stm32l4xx_hal_rng.h" | ||||
| #endif /* HAL_RNG_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_RTC_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_rtc.h" | ||||
| #include "stm32l4xx_hal_rtc.h" | ||||
| #endif /* HAL_RTC_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_SAI_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_sai.h" | ||||
| #include "stm32l4xx_hal_sai.h" | ||||
| #endif /* HAL_SAI_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_SD_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_sd.h" | ||||
| #include "stm32l4xx_hal_sd.h" | ||||
| #endif /* HAL_SD_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_SMBUS_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_smbus.h" | ||||
| #include "stm32l4xx_hal_smbus.h" | ||||
| #endif /* HAL_SMBUS_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_SPI_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_spi.h" | ||||
| #include "stm32l4xx_hal_spi.h" | ||||
| #endif /* HAL_SPI_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_SWPMI_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_swpmi.h" | ||||
| #include "stm32l4xx_hal_swpmi.h" | ||||
| #endif /* HAL_SWPMI_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_TIM_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_tim.h" | ||||
| #include "stm32l4xx_hal_tim.h" | ||||
| #endif /* HAL_TIM_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_TSC_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_tsc.h" | ||||
| #include "stm32l4xx_hal_tsc.h" | ||||
| #endif /* HAL_TSC_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_UART_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_uart.h" | ||||
| #include "stm32l4xx_hal_uart.h" | ||||
| #endif /* HAL_UART_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_USART_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_usart.h" | ||||
| #include "stm32l4xx_hal_usart.h" | ||||
| #endif /* HAL_USART_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_IRDA_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_irda.h" | ||||
| #include "stm32l4xx_hal_irda.h" | ||||
| #endif /* HAL_IRDA_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_SMARTCARD_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_smartcard.h" | ||||
| #include "stm32l4xx_hal_smartcard.h" | ||||
| #endif /* HAL_SMARTCARD_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_WWDG_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_wwdg.h" | ||||
| #include "stm32l4xx_hal_wwdg.h" | ||||
| #endif /* HAL_WWDG_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_PCD_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_pcd.h" | ||||
| #include "stm32l4xx_hal_pcd.h" | ||||
| #endif /* HAL_PCD_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_HCD_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_hcd.h" | ||||
| #include "stm32l4xx_hal_hcd.h" | ||||
| #endif /* HAL_HCD_MODULE_ENABLED */ | ||||
| 
 | ||||
| #ifdef HAL_GFXMMU_MODULE_ENABLED | ||||
|   #include "stm32l4xx_hal_gfxmmu.h" | ||||
| #include "stm32l4xx_hal_gfxmmu.h" | ||||
| #endif /* HAL_GFXMMU_MODULE_ENABLED */ | ||||
| 
 | ||||
| /* Exported macro ------------------------------------------------------------*/ | ||||
| #ifdef  USE_FULL_ASSERT | ||||
| #ifdef USE_FULL_ASSERT | ||||
| /**
 | ||||
|   * @brief  The assert_param macro is used for function's parameters check. | ||||
|   * @param  expr: If expr is false, it calls assert_failed function | ||||
| @ -424,11 +427,11 @@ | ||||
|   *         If expr is true, it returns no value. | ||||
|   * @retval None | ||||
|   */ | ||||
|   #define assert_param(expr) ((expr) ? (void)0U : assert_failed((char *)__FILE__, __LINE__)) | ||||
| #define assert_param(expr) ((expr) ? (void)0U : assert_failed((char*)__FILE__, __LINE__)) | ||||
| /* Exported functions ------------------------------------------------------- */ | ||||
|   void assert_failed(char *file, uint32_t line); | ||||
| void assert_failed(char* file, uint32_t line); | ||||
| #else | ||||
|   #define assert_param(expr) ((void)0U) | ||||
| #define assert_param(expr) ((void)0U) | ||||
| #endif /* USE_FULL_ASSERT */ | ||||
| 
 | ||||
| #ifdef __cplusplus | ||||
|  | ||||
| @ -23,7 +23,7 @@ | ||||
| #define __STM32L4xx_IT_H | ||||
| 
 | ||||
| #ifdef __cplusplus | ||||
|  extern "C" { | ||||
| extern "C" { | ||||
| #endif | ||||
| 
 | ||||
| /* Private includes ----------------------------------------------------------*/ | ||||
|  | ||||
| @ -24,7 +24,7 @@ | ||||
| #define __USB_DEVICE__H__ | ||||
| 
 | ||||
| #ifdef __cplusplus | ||||
|  extern "C" { | ||||
| extern "C" { | ||||
| #endif | ||||
| 
 | ||||
| /* Includes ------------------------------------------------------------------*/ | ||||
|  | ||||
| @ -24,7 +24,7 @@ | ||||
| #define __USBD_CDC_IF_H__ | ||||
| 
 | ||||
| #ifdef __cplusplus | ||||
|  extern "C" { | ||||
| extern "C" { | ||||
| #endif | ||||
| 
 | ||||
| /* Includes ------------------------------------------------------------------*/ | ||||
|  | ||||
| @ -24,7 +24,7 @@ | ||||
| #define __USBD_CONF__H__ | ||||
| 
 | ||||
| #ifdef __cplusplus | ||||
|  extern "C" { | ||||
| extern "C" { | ||||
| #endif | ||||
| 
 | ||||
| /* Includes ------------------------------------------------------------------*/ | ||||
| @ -64,21 +64,21 @@ | ||||
|   */ | ||||
| 
 | ||||
| /*---------- -----------*/ | ||||
| #define USBD_MAX_NUM_INTERFACES     1U | ||||
| #define USBD_MAX_NUM_INTERFACES 1U | ||||
| /*---------- -----------*/ | ||||
| #define USBD_MAX_NUM_CONFIGURATION     1U | ||||
| #define USBD_MAX_NUM_CONFIGURATION 1U | ||||
| /*---------- -----------*/ | ||||
| #define USBD_MAX_STR_DESC_SIZ     512U | ||||
| #define USBD_MAX_STR_DESC_SIZ 512U | ||||
| /*---------- -----------*/ | ||||
| #define USBD_DEBUG_LEVEL     0U | ||||
| #define USBD_DEBUG_LEVEL 0U | ||||
| /*---------- -----------*/ | ||||
| #define USBD_LPM_ENABLED     1U | ||||
| #define USBD_LPM_ENABLED 1U | ||||
| /*---------- -----------*/ | ||||
| #define USBD_SELF_POWERED     1U | ||||
| #define USBD_SELF_POWERED 1U | ||||
| 
 | ||||
| /****************************************/ | ||||
| /* #define for FS and HS identification */ | ||||
| #define DEVICE_FS 		0 | ||||
| #define DEVICE_FS 0 | ||||
| 
 | ||||
| /**
 | ||||
|   * @} | ||||
| @ -92,42 +92,45 @@ | ||||
| /* Memory management macros */ | ||||
| 
 | ||||
| /** Alias for memory allocation. */ | ||||
| #define USBD_malloc         (uint32_t *)USBD_static_malloc | ||||
| #define USBD_malloc (uint32_t*)USBD_static_malloc | ||||
| 
 | ||||
| /** Alias for memory release. */ | ||||
| #define USBD_free           USBD_static_free | ||||
| #define USBD_free USBD_static_free | ||||
| 
 | ||||
| /** Alias for memory set. */ | ||||
| #define USBD_memset         /* Not used */ | ||||
| #define USBD_memset /* Not used */ | ||||
| 
 | ||||
| /** Alias for memory copy. */ | ||||
| #define USBD_memcpy         /* Not used */ | ||||
| #define USBD_memcpy /* Not used */ | ||||
| 
 | ||||
| /** Alias for delay. */ | ||||
| #define USBD_Delay          HAL_Delay | ||||
| #define USBD_Delay HAL_Delay | ||||
| 
 | ||||
| /* DEBUG macros */ | ||||
| 
 | ||||
| #if (USBD_DEBUG_LEVEL > 0) | ||||
| #define USBD_UsrLog(...)    printf(__VA_ARGS__);\ | ||||
|                             printf("\n"); | ||||
| #if(USBD_DEBUG_LEVEL > 0) | ||||
| #define USBD_UsrLog(...) \ | ||||
|     printf(__VA_ARGS__); \ | ||||
|     printf("\n"); | ||||
| #else | ||||
| #define USBD_UsrLog(...) | ||||
| #endif | ||||
| 
 | ||||
| #if (USBD_DEBUG_LEVEL > 1) | ||||
| #if(USBD_DEBUG_LEVEL > 1) | ||||
| 
 | ||||
| #define USBD_ErrLog(...)    printf("ERROR: ") ;\ | ||||
|                             printf(__VA_ARGS__);\ | ||||
|                             printf("\n"); | ||||
| #define USBD_ErrLog(...) \ | ||||
|     printf("ERROR: ");   \ | ||||
|     printf(__VA_ARGS__); \ | ||||
|     printf("\n"); | ||||
| #else | ||||
| #define USBD_ErrLog(...) | ||||
| #endif | ||||
| 
 | ||||
| #if (USBD_DEBUG_LEVEL > 2) | ||||
| #define USBD_DbgLog(...)    printf("DEBUG : ") ;\ | ||||
|                             printf(__VA_ARGS__);\ | ||||
|                             printf("\n"); | ||||
| #if(USBD_DEBUG_LEVEL > 2) | ||||
| #define USBD_DbgLog(...) \ | ||||
|     printf("DEBUG : ");  \ | ||||
|     printf(__VA_ARGS__); \ | ||||
|     printf("\n"); | ||||
| #else | ||||
| #define USBD_DbgLog(...) | ||||
| #endif | ||||
| @ -151,8 +154,8 @@ | ||||
|   */ | ||||
| 
 | ||||
| /* Exported functions -------------------------------------------------------*/ | ||||
| void *USBD_static_malloc(uint32_t size); | ||||
| void USBD_static_free(void *p); | ||||
| void* USBD_static_malloc(uint32_t size); | ||||
| void USBD_static_free(void* p); | ||||
| 
 | ||||
| /**
 | ||||
|   * @} | ||||
|  | ||||
| @ -23,7 +23,7 @@ | ||||
| #define __USBD_DESC__C__ | ||||
| 
 | ||||
| #ifdef __cplusplus | ||||
|  extern "C" { | ||||
| extern "C" { | ||||
| #endif | ||||
| 
 | ||||
| /* Includes ------------------------------------------------------------------*/ | ||||
| @ -46,11 +46,11 @@ | ||||
|   * @brief Constants. | ||||
|   * @{ | ||||
|   */ | ||||
| #define         DEVICE_ID1          (UID_BASE) | ||||
| #define         DEVICE_ID2          (UID_BASE + 0x4) | ||||
| #define         DEVICE_ID3          (UID_BASE + 0x8) | ||||
| #define DEVICE_ID1 (UID_BASE) | ||||
| #define DEVICE_ID2 (UID_BASE + 0x4) | ||||
| #define DEVICE_ID3 (UID_BASE + 0x8) | ||||
| 
 | ||||
| #define  USB_SIZ_STRING_SERIAL       0x1A | ||||
| #define USB_SIZ_STRING_SERIAL 0x1A | ||||
| 
 | ||||
| /* USER CODE BEGIN EXPORTED_CONSTANTS */ | ||||
| 
 | ||||
|  | ||||
| @ -15,18 +15,18 @@ void app_gpio_init(GpioPin gpio, GpioMode mode) { | ||||
|         GPIO_InitStruct.Pull = GPIO_NOPULL; | ||||
| 
 | ||||
|         switch(mode) { | ||||
|             case GpioModeInput: | ||||
|                 GPIO_InitStruct.Mode = GPIO_MODE_INPUT; | ||||
|         case GpioModeInput: | ||||
|             GPIO_InitStruct.Mode = GPIO_MODE_INPUT; | ||||
|             break; | ||||
| 
 | ||||
|             case GpioModeOutput:  | ||||
|                 GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; | ||||
|                 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM; | ||||
|         case GpioModeOutput: | ||||
|             GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; | ||||
|             GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM; | ||||
|             break; | ||||
| 
 | ||||
|             case GpioModeOpenDrain: | ||||
|                 GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_OD; | ||||
|                 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM; | ||||
|         case GpioModeOpenDrain: | ||||
|             GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_OD; | ||||
|             GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM; | ||||
|             break; | ||||
|         } | ||||
| 
 | ||||
| @ -36,14 +36,15 @@ void app_gpio_init(GpioPin gpio, GpioMode mode) { | ||||
| 
 | ||||
| // TODO delay from timer
 | ||||
| void delay_us(uint32_t time) { | ||||
|   time *= 11.8; | ||||
|     time *= 11.8; | ||||
| 
 | ||||
|   while(time--) {} | ||||
|     while(time--) { | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void pwm_set(float value, float freq, TIM_HandleTypeDef* tim, uint32_t channel) { | ||||
|     tim->Init.CounterMode = TIM_COUNTERMODE_UP; | ||||
|     tim->Init.Period = (uint32_t)((SystemCoreClock/tim->Init.Prescaler)/freq); | ||||
|     tim->Init.Period = (uint32_t)((SystemCoreClock / tim->Init.Prescaler) / freq); | ||||
|     tim->Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; | ||||
|     tim->Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; | ||||
|     HAL_TIM_PWM_Init(tim); | ||||
|  | ||||
| @ -55,18 +55,21 @@ | ||||
| /* USER CODE END FunctionPrototypes */ | ||||
| 
 | ||||
| /* GetIdleTaskMemory prototype (linked to static allocation support) */ | ||||
| void vApplicationGetIdleTaskMemory( StaticTask_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize ); | ||||
| void vApplicationGetIdleTaskMemory(StaticTask_t** ppxIdleTaskTCBBuffer, | ||||
|                                    StackType_t** ppxIdleTaskStackBuffer, | ||||
|                                    uint32_t* pulIdleTaskStackSize); | ||||
| 
 | ||||
| /* GetTimerTaskMemory prototype (linked to static allocation support) */ | ||||
| void vApplicationGetTimerTaskMemory( StaticTask_t **ppxTimerTaskTCBBuffer, StackType_t **ppxTimerTaskStackBuffer, uint32_t *pulTimerTaskStackSize ); | ||||
| void vApplicationGetTimerTaskMemory(StaticTask_t** ppxTimerTaskTCBBuffer, | ||||
|                                     StackType_t** ppxTimerTaskStackBuffer, | ||||
|                                     uint32_t* pulTimerTaskStackSize); | ||||
| 
 | ||||
| /* Hook prototypes */ | ||||
| void vApplicationIdleHook(void); | ||||
| 
 | ||||
| /* USER CODE BEGIN 2 */ | ||||
| __weak void vApplicationIdleHook( void ) | ||||
| { | ||||
|    /* vApplicationIdleHook() will only be called if configUSE_IDLE_HOOK is set
 | ||||
| __weak void vApplicationIdleHook(void) { | ||||
|     /* vApplicationIdleHook() will only be called if configUSE_IDLE_HOOK is set
 | ||||
|    to 1 in FreeRTOSConfig.h. It will be called on each iteration of the idle | ||||
|    task. It is essential that code added to this hook function never attempts | ||||
|    to block in any way (for example, call xQueueReceive() with a block time | ||||
| @ -82,12 +85,13 @@ __weak void vApplicationIdleHook( void ) | ||||
| static StaticTask_t xIdleTaskTCBBuffer; | ||||
| static StackType_t xIdleStack[configMINIMAL_STACK_SIZE]; | ||||
| 
 | ||||
| void vApplicationGetIdleTaskMemory( StaticTask_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize ) | ||||
| { | ||||
|   *ppxIdleTaskTCBBuffer = &xIdleTaskTCBBuffer; | ||||
|   *ppxIdleTaskStackBuffer = &xIdleStack[0]; | ||||
|   *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE; | ||||
|   /* place for user code */ | ||||
| void vApplicationGetIdleTaskMemory(StaticTask_t** ppxIdleTaskTCBBuffer, | ||||
|                                    StackType_t** ppxIdleTaskStackBuffer, | ||||
|                                    uint32_t* pulIdleTaskStackSize) { | ||||
|     *ppxIdleTaskTCBBuffer = &xIdleTaskTCBBuffer; | ||||
|     *ppxIdleTaskStackBuffer = &xIdleStack[0]; | ||||
|     *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE; | ||||
|     /* place for user code */ | ||||
| } | ||||
| /* USER CODE END GET_IDLE_TASK_MEMORY */ | ||||
| 
 | ||||
| @ -95,12 +99,13 @@ void vApplicationGetIdleTaskMemory( StaticTask_t **ppxIdleTaskTCBBuffer, StackTy | ||||
| static StaticTask_t xTimerTaskTCBBuffer; | ||||
| static StackType_t xTimerStack[configTIMER_TASK_STACK_DEPTH]; | ||||
| 
 | ||||
| void vApplicationGetTimerTaskMemory( StaticTask_t **ppxTimerTaskTCBBuffer, StackType_t **ppxTimerTaskStackBuffer, uint32_t *pulTimerTaskStackSize )   | ||||
| { | ||||
|   *ppxTimerTaskTCBBuffer = &xTimerTaskTCBBuffer; | ||||
|   *ppxTimerTaskStackBuffer = &xTimerStack[0]; | ||||
|   *pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH; | ||||
|   /* place for user code */ | ||||
| void vApplicationGetTimerTaskMemory(StaticTask_t** ppxTimerTaskTCBBuffer, | ||||
|                                     StackType_t** ppxTimerTaskStackBuffer, | ||||
|                                     uint32_t* pulTimerTaskStackSize) { | ||||
|     *ppxTimerTaskTCBBuffer = &xTimerTaskTCBBuffer; | ||||
|     *ppxTimerTaskStackBuffer = &xTimerStack[0]; | ||||
|     *pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH; | ||||
|     /* place for user code */ | ||||
| } | ||||
| /* USER CODE END GET_TIMER_TASK_MEMORY */ | ||||
| 
 | ||||
|  | ||||
							
								
								
									
										1018
									
								
								target_f2/Src/main.c
									
									
									
									
									
								
							
							
						
						
									
										1018
									
								
								target_f2/Src/main.c
									
									
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @ -59,26 +59,25 @@ | ||||
| 
 | ||||
| /* USER CODE END 0 */ | ||||
| 
 | ||||
| void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim); | ||||
|                                         /**
 | ||||
| void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim); | ||||
| /**
 | ||||
|   * Initializes the Global MSP. | ||||
|   */ | ||||
| void HAL_MspInit(void) | ||||
| { | ||||
|   /* USER CODE BEGIN MspInit 0 */ | ||||
| void HAL_MspInit(void) { | ||||
|     /* USER CODE BEGIN MspInit 0 */ | ||||
| 
 | ||||
|   /* USER CODE END MspInit 0 */ | ||||
|     /* USER CODE END MspInit 0 */ | ||||
| 
 | ||||
|   __HAL_RCC_SYSCFG_CLK_ENABLE(); | ||||
|   __HAL_RCC_PWR_CLK_ENABLE(); | ||||
|     __HAL_RCC_SYSCFG_CLK_ENABLE(); | ||||
|     __HAL_RCC_PWR_CLK_ENABLE(); | ||||
| 
 | ||||
|   /* System interrupt init*/ | ||||
|   /* PendSV_IRQn interrupt configuration */ | ||||
|   HAL_NVIC_SetPriority(PendSV_IRQn, 15, 0); | ||||
|     /* System interrupt init*/ | ||||
|     /* PendSV_IRQn interrupt configuration */ | ||||
|     HAL_NVIC_SetPriority(PendSV_IRQn, 15, 0); | ||||
| 
 | ||||
|   /* USER CODE BEGIN MspInit 1 */ | ||||
|     /* USER CODE BEGIN MspInit 1 */ | ||||
| 
 | ||||
|   /* USER CODE END MspInit 1 */ | ||||
|     /* USER CODE END MspInit 1 */ | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -87,38 +86,35 @@ void HAL_MspInit(void) | ||||
| * @param hadc: ADC handle pointer | ||||
| * @retval None | ||||
| */ | ||||
| void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc) | ||||
| { | ||||
|   GPIO_InitTypeDef GPIO_InitStruct = {0}; | ||||
|   if(hadc->Instance==ADC1) | ||||
|   { | ||||
|   /* USER CODE BEGIN ADC1_MspInit 0 */ | ||||
| void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc) { | ||||
|     GPIO_InitTypeDef GPIO_InitStruct = {0}; | ||||
|     if(hadc->Instance == ADC1) { | ||||
|         /* USER CODE BEGIN ADC1_MspInit 0 */ | ||||
| 
 | ||||
|   /* USER CODE END ADC1_MspInit 0 */ | ||||
|     /* Peripheral clock enable */ | ||||
|     __HAL_RCC_ADC_CLK_ENABLE(); | ||||
|         /* USER CODE END ADC1_MspInit 0 */ | ||||
|         /* Peripheral clock enable */ | ||||
|         __HAL_RCC_ADC_CLK_ENABLE(); | ||||
| 
 | ||||
|     __HAL_RCC_GPIOC_CLK_ENABLE(); | ||||
|     __HAL_RCC_GPIOA_CLK_ENABLE(); | ||||
|     /**ADC1 GPIO Configuration    
 | ||||
|         __HAL_RCC_GPIOC_CLK_ENABLE(); | ||||
|         __HAL_RCC_GPIOA_CLK_ENABLE(); | ||||
|         /**ADC1 GPIO Configuration    
 | ||||
|     PC3     ------> ADC1_IN4 | ||||
|     PA0     ------> ADC1_IN5  | ||||
|     */ | ||||
|     GPIO_InitStruct.Pin = BATT_V_Pin; | ||||
|     GPIO_InitStruct.Mode = GPIO_MODE_ANALOG_ADC_CONTROL; | ||||
|     GPIO_InitStruct.Pull = GPIO_NOPULL; | ||||
|     HAL_GPIO_Init(BATT_V_GPIO_Port, &GPIO_InitStruct); | ||||
|         GPIO_InitStruct.Pin = BATT_V_Pin; | ||||
|         GPIO_InitStruct.Mode = GPIO_MODE_ANALOG_ADC_CONTROL; | ||||
|         GPIO_InitStruct.Pull = GPIO_NOPULL; | ||||
|         HAL_GPIO_Init(BATT_V_GPIO_Port, &GPIO_InitStruct); | ||||
| 
 | ||||
|     GPIO_InitStruct.Pin = IR_RX_Pin; | ||||
|     GPIO_InitStruct.Mode = GPIO_MODE_ANALOG_ADC_CONTROL; | ||||
|     GPIO_InitStruct.Pull = GPIO_NOPULL; | ||||
|     HAL_GPIO_Init(IR_RX_GPIO_Port, &GPIO_InitStruct); | ||||
|         GPIO_InitStruct.Pin = IR_RX_Pin; | ||||
|         GPIO_InitStruct.Mode = GPIO_MODE_ANALOG_ADC_CONTROL; | ||||
|         GPIO_InitStruct.Pull = GPIO_NOPULL; | ||||
|         HAL_GPIO_Init(IR_RX_GPIO_Port, &GPIO_InitStruct); | ||||
| 
 | ||||
|   /* USER CODE BEGIN ADC1_MspInit 1 */ | ||||
| 
 | ||||
|   /* USER CODE END ADC1_MspInit 1 */ | ||||
|   } | ||||
|         /* USER CODE BEGIN ADC1_MspInit 1 */ | ||||
| 
 | ||||
|         /* USER CODE END ADC1_MspInit 1 */ | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -127,29 +123,26 @@ void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc) | ||||
| * @param hadc: ADC handle pointer | ||||
| * @retval None | ||||
| */ | ||||
| void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc) | ||||
| { | ||||
|   if(hadc->Instance==ADC1) | ||||
|   { | ||||
|   /* USER CODE BEGIN ADC1_MspDeInit 0 */ | ||||
| void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc) { | ||||
|     if(hadc->Instance == ADC1) { | ||||
|         /* USER CODE BEGIN ADC1_MspDeInit 0 */ | ||||
| 
 | ||||
|   /* USER CODE END ADC1_MspDeInit 0 */ | ||||
|     /* Peripheral clock disable */ | ||||
|     __HAL_RCC_ADC_CLK_DISABLE(); | ||||
|         /* USER CODE END ADC1_MspDeInit 0 */ | ||||
|         /* Peripheral clock disable */ | ||||
|         __HAL_RCC_ADC_CLK_DISABLE(); | ||||
| 
 | ||||
|     /**ADC1 GPIO Configuration    
 | ||||
|         /**ADC1 GPIO Configuration    
 | ||||
|     PC3     ------> ADC1_IN4 | ||||
|     PA0     ------> ADC1_IN5  | ||||
|     */ | ||||
|     HAL_GPIO_DeInit(BATT_V_GPIO_Port, BATT_V_Pin); | ||||
|         HAL_GPIO_DeInit(BATT_V_GPIO_Port, BATT_V_Pin); | ||||
| 
 | ||||
|     HAL_GPIO_DeInit(IR_RX_GPIO_Port, IR_RX_Pin); | ||||
|         HAL_GPIO_DeInit(IR_RX_GPIO_Port, IR_RX_Pin); | ||||
| 
 | ||||
|   /* USER CODE BEGIN ADC1_MspDeInit 1 */ | ||||
| 
 | ||||
|   /* USER CODE END ADC1_MspDeInit 1 */ | ||||
|   } | ||||
|         /* USER CODE BEGIN ADC1_MspDeInit 1 */ | ||||
| 
 | ||||
|         /* USER CODE END ADC1_MspDeInit 1 */ | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -158,29 +151,26 @@ void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc) | ||||
| * @param hcomp: COMP handle pointer | ||||
| * @retval None | ||||
| */ | ||||
| void HAL_COMP_MspInit(COMP_HandleTypeDef* hcomp) | ||||
| { | ||||
|   GPIO_InitTypeDef GPIO_InitStruct = {0}; | ||||
|   if(hcomp->Instance==COMP1) | ||||
|   { | ||||
|   /* USER CODE BEGIN COMP1_MspInit 0 */ | ||||
| void HAL_COMP_MspInit(COMP_HandleTypeDef* hcomp) { | ||||
|     GPIO_InitTypeDef GPIO_InitStruct = {0}; | ||||
|     if(hcomp->Instance == COMP1) { | ||||
|         /* USER CODE BEGIN COMP1_MspInit 0 */ | ||||
| 
 | ||||
|   /* USER CODE END COMP1_MspInit 0 */ | ||||
|         /* USER CODE END COMP1_MspInit 0 */ | ||||
| 
 | ||||
|     __HAL_RCC_GPIOC_CLK_ENABLE(); | ||||
|     /**COMP1 GPIO Configuration    
 | ||||
|         __HAL_RCC_GPIOC_CLK_ENABLE(); | ||||
|         /**COMP1 GPIO Configuration    
 | ||||
|     PC5     ------> COMP1_INP  | ||||
|     */ | ||||
|     GPIO_InitStruct.Pin = RFID_RF_IN_Pin; | ||||
|     GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; | ||||
|     GPIO_InitStruct.Pull = GPIO_NOPULL; | ||||
|     HAL_GPIO_Init(RFID_RF_IN_GPIO_Port, &GPIO_InitStruct); | ||||
|         GPIO_InitStruct.Pin = RFID_RF_IN_Pin; | ||||
|         GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; | ||||
|         GPIO_InitStruct.Pull = GPIO_NOPULL; | ||||
|         HAL_GPIO_Init(RFID_RF_IN_GPIO_Port, &GPIO_InitStruct); | ||||
| 
 | ||||
|   /* USER CODE BEGIN COMP1_MspInit 1 */ | ||||
| 
 | ||||
|   /* USER CODE END COMP1_MspInit 1 */ | ||||
|   } | ||||
|         /* USER CODE BEGIN COMP1_MspInit 1 */ | ||||
| 
 | ||||
|         /* USER CODE END COMP1_MspInit 1 */ | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -189,24 +179,21 @@ void HAL_COMP_MspInit(COMP_HandleTypeDef* hcomp) | ||||
| * @param hcomp: COMP handle pointer | ||||
| * @retval None | ||||
| */ | ||||
| void HAL_COMP_MspDeInit(COMP_HandleTypeDef* hcomp) | ||||
| { | ||||
|   if(hcomp->Instance==COMP1) | ||||
|   { | ||||
|   /* USER CODE BEGIN COMP1_MspDeInit 0 */ | ||||
| void HAL_COMP_MspDeInit(COMP_HandleTypeDef* hcomp) { | ||||
|     if(hcomp->Instance == COMP1) { | ||||
|         /* USER CODE BEGIN COMP1_MspDeInit 0 */ | ||||
| 
 | ||||
|   /* USER CODE END COMP1_MspDeInit 0 */ | ||||
|         /* USER CODE END COMP1_MspDeInit 0 */ | ||||
| 
 | ||||
|     /**COMP1 GPIO Configuration    
 | ||||
|         /**COMP1 GPIO Configuration    
 | ||||
|     PC5     ------> COMP1_INP  | ||||
|     */ | ||||
|     HAL_GPIO_DeInit(RFID_RF_IN_GPIO_Port, RFID_RF_IN_Pin); | ||||
|         HAL_GPIO_DeInit(RFID_RF_IN_GPIO_Port, RFID_RF_IN_Pin); | ||||
| 
 | ||||
|   /* USER CODE BEGIN COMP1_MspDeInit 1 */ | ||||
| 
 | ||||
|   /* USER CODE END COMP1_MspDeInit 1 */ | ||||
|   } | ||||
|         /* USER CODE BEGIN COMP1_MspDeInit 1 */ | ||||
| 
 | ||||
|         /* USER CODE END COMP1_MspDeInit 1 */ | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -215,59 +202,54 @@ void HAL_COMP_MspDeInit(COMP_HandleTypeDef* hcomp) | ||||
| * @param hspi: SPI handle pointer | ||||
| * @retval None | ||||
| */ | ||||
| void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi) | ||||
| { | ||||
|   GPIO_InitTypeDef GPIO_InitStruct = {0}; | ||||
|   if(hspi->Instance==SPI1) | ||||
|   { | ||||
|   /* USER CODE BEGIN SPI1_MspInit 0 */ | ||||
| void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi) { | ||||
|     GPIO_InitTypeDef GPIO_InitStruct = {0}; | ||||
|     if(hspi->Instance == SPI1) { | ||||
|         /* USER CODE BEGIN SPI1_MspInit 0 */ | ||||
| 
 | ||||
|   /* USER CODE END SPI1_MspInit 0 */ | ||||
|     /* Peripheral clock enable */ | ||||
|     __HAL_RCC_SPI1_CLK_ENABLE(); | ||||
|         /* USER CODE END SPI1_MspInit 0 */ | ||||
|         /* Peripheral clock enable */ | ||||
|         __HAL_RCC_SPI1_CLK_ENABLE(); | ||||
| 
 | ||||
|     __HAL_RCC_GPIOB_CLK_ENABLE(); | ||||
|     /**SPI1 GPIO Configuration    
 | ||||
|         __HAL_RCC_GPIOB_CLK_ENABLE(); | ||||
|         /**SPI1 GPIO Configuration    
 | ||||
|     PB3 (JTDO-TRACESWO)     ------> SPI1_SCK | ||||
|     PB5     ------> SPI1_MOSI  | ||||
|     */ | ||||
|     GPIO_InitStruct.Pin = GPIO_PIN_3|GPIO_PIN_5; | ||||
|     GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; | ||||
|     GPIO_InitStruct.Pull = GPIO_NOPULL; | ||||
|     GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; | ||||
|     GPIO_InitStruct.Alternate = GPIO_AF5_SPI1; | ||||
|     HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); | ||||
|         GPIO_InitStruct.Pin = GPIO_PIN_3 | GPIO_PIN_5; | ||||
|         GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; | ||||
|         GPIO_InitStruct.Pull = GPIO_NOPULL; | ||||
|         GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; | ||||
|         GPIO_InitStruct.Alternate = GPIO_AF5_SPI1; | ||||
|         HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); | ||||
| 
 | ||||
|   /* USER CODE BEGIN SPI1_MspInit 1 */ | ||||
|         /* USER CODE BEGIN SPI1_MspInit 1 */ | ||||
| 
 | ||||
|   /* USER CODE END SPI1_MspInit 1 */ | ||||
|   } | ||||
|   else if(hspi->Instance==SPI3) | ||||
|   { | ||||
|   /* USER CODE BEGIN SPI3_MspInit 0 */ | ||||
|         /* USER CODE END SPI1_MspInit 1 */ | ||||
|     } else if(hspi->Instance == SPI3) { | ||||
|         /* USER CODE BEGIN SPI3_MspInit 0 */ | ||||
| 
 | ||||
|   /* USER CODE END SPI3_MspInit 0 */ | ||||
|     /* Peripheral clock enable */ | ||||
|     __HAL_RCC_SPI3_CLK_ENABLE(); | ||||
|         /* USER CODE END SPI3_MspInit 0 */ | ||||
|         /* Peripheral clock enable */ | ||||
|         __HAL_RCC_SPI3_CLK_ENABLE(); | ||||
| 
 | ||||
|     __HAL_RCC_GPIOC_CLK_ENABLE(); | ||||
|     /**SPI3 GPIO Configuration    
 | ||||
|         __HAL_RCC_GPIOC_CLK_ENABLE(); | ||||
|         /**SPI3 GPIO Configuration    
 | ||||
|     PC10     ------> SPI3_SCK | ||||
|     PC11     ------> SPI3_MISO | ||||
|     PC12     ------> SPI3_MOSI  | ||||
|     */ | ||||
|     GPIO_InitStruct.Pin = GPIO_PIN_10|GPIO_PIN_11|GPIO_PIN_12; | ||||
|     GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; | ||||
|     GPIO_InitStruct.Pull = GPIO_NOPULL; | ||||
|     GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; | ||||
|     GPIO_InitStruct.Alternate = GPIO_AF6_SPI3; | ||||
|     HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); | ||||
|         GPIO_InitStruct.Pin = GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12; | ||||
|         GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; | ||||
|         GPIO_InitStruct.Pull = GPIO_NOPULL; | ||||
|         GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; | ||||
|         GPIO_InitStruct.Alternate = GPIO_AF6_SPI3; | ||||
|         HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); | ||||
| 
 | ||||
|   /* USER CODE BEGIN SPI3_MspInit 1 */ | ||||
| 
 | ||||
|   /* USER CODE END SPI3_MspInit 1 */ | ||||
|   } | ||||
|         /* USER CODE BEGIN SPI3_MspInit 1 */ | ||||
| 
 | ||||
|         /* USER CODE END SPI3_MspInit 1 */ | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -276,46 +258,41 @@ void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi) | ||||
| * @param hspi: SPI handle pointer | ||||
| * @retval None | ||||
| */ | ||||
| void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi) | ||||
| { | ||||
|   if(hspi->Instance==SPI1) | ||||
|   { | ||||
|   /* USER CODE BEGIN SPI1_MspDeInit 0 */ | ||||
| void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi) { | ||||
|     if(hspi->Instance == SPI1) { | ||||
|         /* USER CODE BEGIN SPI1_MspDeInit 0 */ | ||||
| 
 | ||||
|   /* USER CODE END SPI1_MspDeInit 0 */ | ||||
|     /* Peripheral clock disable */ | ||||
|     __HAL_RCC_SPI1_CLK_DISABLE(); | ||||
|         /* USER CODE END SPI1_MspDeInit 0 */ | ||||
|         /* Peripheral clock disable */ | ||||
|         __HAL_RCC_SPI1_CLK_DISABLE(); | ||||
| 
 | ||||
|     /**SPI1 GPIO Configuration    
 | ||||
|         /**SPI1 GPIO Configuration    
 | ||||
|     PB3 (JTDO-TRACESWO)     ------> SPI1_SCK | ||||
|     PB5     ------> SPI1_MOSI  | ||||
|     */ | ||||
|     HAL_GPIO_DeInit(GPIOB, GPIO_PIN_3|GPIO_PIN_5); | ||||
|         HAL_GPIO_DeInit(GPIOB, GPIO_PIN_3 | GPIO_PIN_5); | ||||
| 
 | ||||
|   /* USER CODE BEGIN SPI1_MspDeInit 1 */ | ||||
|         /* USER CODE BEGIN SPI1_MspDeInit 1 */ | ||||
| 
 | ||||
|   /* USER CODE END SPI1_MspDeInit 1 */ | ||||
|   } | ||||
|   else if(hspi->Instance==SPI3) | ||||
|   { | ||||
|   /* USER CODE BEGIN SPI3_MspDeInit 0 */ | ||||
|         /* USER CODE END SPI1_MspDeInit 1 */ | ||||
|     } else if(hspi->Instance == SPI3) { | ||||
|         /* USER CODE BEGIN SPI3_MspDeInit 0 */ | ||||
| 
 | ||||
|   /* USER CODE END SPI3_MspDeInit 0 */ | ||||
|     /* Peripheral clock disable */ | ||||
|     __HAL_RCC_SPI3_CLK_DISABLE(); | ||||
|         /* USER CODE END SPI3_MspDeInit 0 */ | ||||
|         /* Peripheral clock disable */ | ||||
|         __HAL_RCC_SPI3_CLK_DISABLE(); | ||||
| 
 | ||||
|     /**SPI3 GPIO Configuration    
 | ||||
|         /**SPI3 GPIO Configuration    
 | ||||
|     PC10     ------> SPI3_SCK | ||||
|     PC11     ------> SPI3_MISO | ||||
|     PC12     ------> SPI3_MOSI  | ||||
|     */ | ||||
|     HAL_GPIO_DeInit(GPIOC, GPIO_PIN_10|GPIO_PIN_11|GPIO_PIN_12); | ||||
|         HAL_GPIO_DeInit(GPIOC, GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12); | ||||
| 
 | ||||
|   /* USER CODE BEGIN SPI3_MspDeInit 1 */ | ||||
| 
 | ||||
|   /* USER CODE END SPI3_MspDeInit 1 */ | ||||
|   } | ||||
|         /* USER CODE BEGIN SPI3_MspDeInit 1 */ | ||||
| 
 | ||||
|         /* USER CODE END SPI3_MspDeInit 1 */ | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -324,20 +301,17 @@ void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi) | ||||
| * @param htim_pwm: TIM_PWM handle pointer | ||||
| * @retval None | ||||
| */ | ||||
| void HAL_TIM_PWM_MspInit(TIM_HandleTypeDef* htim_pwm) | ||||
| { | ||||
|   if(htim_pwm->Instance==TIM5) | ||||
|   { | ||||
|   /* USER CODE BEGIN TIM5_MspInit 0 */ | ||||
| void HAL_TIM_PWM_MspInit(TIM_HandleTypeDef* htim_pwm) { | ||||
|     if(htim_pwm->Instance == TIM5) { | ||||
|         /* USER CODE BEGIN TIM5_MspInit 0 */ | ||||
| 
 | ||||
|   /* USER CODE END TIM5_MspInit 0 */ | ||||
|     /* Peripheral clock enable */ | ||||
|     __HAL_RCC_TIM5_CLK_ENABLE(); | ||||
|   /* USER CODE BEGIN TIM5_MspInit 1 */ | ||||
| 
 | ||||
|   /* USER CODE END TIM5_MspInit 1 */ | ||||
|   } | ||||
|         /* USER CODE END TIM5_MspInit 0 */ | ||||
|         /* Peripheral clock enable */ | ||||
|         __HAL_RCC_TIM5_CLK_ENABLE(); | ||||
|         /* USER CODE BEGIN TIM5_MspInit 1 */ | ||||
| 
 | ||||
|         /* USER CODE END TIM5_MspInit 1 */ | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -346,36 +320,33 @@ void HAL_TIM_PWM_MspInit(TIM_HandleTypeDef* htim_pwm) | ||||
| * @param htim_base: TIM_Base handle pointer | ||||
| * @retval None | ||||
| */ | ||||
| void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base) | ||||
| { | ||||
|   GPIO_InitTypeDef GPIO_InitStruct = {0}; | ||||
|   if(htim_base->Instance==TIM8) | ||||
|   { | ||||
|   /* USER CODE BEGIN TIM8_MspInit 0 */ | ||||
| void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base) { | ||||
|     GPIO_InitTypeDef GPIO_InitStruct = {0}; | ||||
|     if(htim_base->Instance == TIM8) { | ||||
|         /* USER CODE BEGIN TIM8_MspInit 0 */ | ||||
| 
 | ||||
|   /* USER CODE END TIM8_MspInit 0 */ | ||||
|     /* Peripheral clock enable */ | ||||
|     __HAL_RCC_TIM8_CLK_ENABLE(); | ||||
|         /* USER CODE END TIM8_MspInit 0 */ | ||||
|         /* Peripheral clock enable */ | ||||
|         __HAL_RCC_TIM8_CLK_ENABLE(); | ||||
| 
 | ||||
|     __HAL_RCC_GPIOC_CLK_ENABLE(); | ||||
|     /**TIM8 GPIO Configuration    
 | ||||
|         __HAL_RCC_GPIOC_CLK_ENABLE(); | ||||
|         /**TIM8 GPIO Configuration    
 | ||||
|     PC7     ------> TIM8_CH2  | ||||
|     */ | ||||
|     GPIO_InitStruct.Pin = iButton_Pin; | ||||
|     GPIO_InitStruct.Mode = GPIO_MODE_AF_OD; | ||||
|     GPIO_InitStruct.Pull = GPIO_NOPULL; | ||||
|     GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM; | ||||
|     GPIO_InitStruct.Alternate = GPIO_AF3_TIM8; | ||||
|     HAL_GPIO_Init(iButton_GPIO_Port, &GPIO_InitStruct); | ||||
|         GPIO_InitStruct.Pin = iButton_Pin; | ||||
|         GPIO_InitStruct.Mode = GPIO_MODE_AF_OD; | ||||
|         GPIO_InitStruct.Pull = GPIO_NOPULL; | ||||
|         GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM; | ||||
|         GPIO_InitStruct.Alternate = GPIO_AF3_TIM8; | ||||
|         HAL_GPIO_Init(iButton_GPIO_Port, &GPIO_InitStruct); | ||||
| 
 | ||||
|     /* TIM8 interrupt Init */ | ||||
|     HAL_NVIC_SetPriority(TIM8_CC_IRQn, 5, 0); | ||||
|     HAL_NVIC_EnableIRQ(TIM8_CC_IRQn); | ||||
|   /* USER CODE BEGIN TIM8_MspInit 1 */ | ||||
| 
 | ||||
|   /* USER CODE END TIM8_MspInit 1 */ | ||||
|   } | ||||
|         /* TIM8 interrupt Init */ | ||||
|         HAL_NVIC_SetPriority(TIM8_CC_IRQn, 5, 0); | ||||
|         HAL_NVIC_EnableIRQ(TIM8_CC_IRQn); | ||||
|         /* USER CODE BEGIN TIM8_MspInit 1 */ | ||||
| 
 | ||||
|         /* USER CODE END TIM8_MspInit 1 */ | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -384,68 +355,60 @@ void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base) | ||||
| * @param htim_oc: TIM_OC handle pointer | ||||
| * @retval None | ||||
| */ | ||||
| void HAL_TIM_OC_MspInit(TIM_HandleTypeDef* htim_oc) | ||||
| { | ||||
|   if(htim_oc->Instance==TIM15) | ||||
|   { | ||||
|   /* USER CODE BEGIN TIM15_MspInit 0 */ | ||||
| void HAL_TIM_OC_MspInit(TIM_HandleTypeDef* htim_oc) { | ||||
|     if(htim_oc->Instance == TIM15) { | ||||
|         /* USER CODE BEGIN TIM15_MspInit 0 */ | ||||
| 
 | ||||
|   /* USER CODE END TIM15_MspInit 0 */ | ||||
|     /* Peripheral clock enable */ | ||||
|     __HAL_RCC_TIM15_CLK_ENABLE(); | ||||
|   /* USER CODE BEGIN TIM15_MspInit 1 */ | ||||
| 
 | ||||
|   /* USER CODE END TIM15_MspInit 1 */ | ||||
|   } | ||||
|         /* USER CODE END TIM15_MspInit 0 */ | ||||
|         /* Peripheral clock enable */ | ||||
|         __HAL_RCC_TIM15_CLK_ENABLE(); | ||||
|         /* USER CODE BEGIN TIM15_MspInit 1 */ | ||||
| 
 | ||||
|         /* USER CODE END TIM15_MspInit 1 */ | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim) | ||||
| { | ||||
|   GPIO_InitTypeDef GPIO_InitStruct = {0}; | ||||
|   if(htim->Instance==TIM5) | ||||
|   { | ||||
|   /* USER CODE BEGIN TIM5_MspPostInit 0 */ | ||||
| void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim) { | ||||
|     GPIO_InitTypeDef GPIO_InitStruct = {0}; | ||||
|     if(htim->Instance == TIM5) { | ||||
|         /* USER CODE BEGIN TIM5_MspPostInit 0 */ | ||||
| 
 | ||||
|   /* USER CODE END TIM5_MspPostInit 0 */ | ||||
|     __HAL_RCC_GPIOA_CLK_ENABLE(); | ||||
|     /**TIM5 GPIO Configuration    
 | ||||
|         /* USER CODE END TIM5_MspPostInit 0 */ | ||||
|         __HAL_RCC_GPIOA_CLK_ENABLE(); | ||||
|         /**TIM5 GPIO Configuration    
 | ||||
|     PA3     ------> TIM5_CH4  | ||||
|     */ | ||||
|     GPIO_InitStruct.Pin = SPEAKER_Pin; | ||||
|     GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; | ||||
|     GPIO_InitStruct.Pull = GPIO_NOPULL; | ||||
|     GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; | ||||
|     GPIO_InitStruct.Alternate = GPIO_AF2_TIM5; | ||||
|     HAL_GPIO_Init(SPEAKER_GPIO_Port, &GPIO_InitStruct); | ||||
|         GPIO_InitStruct.Pin = SPEAKER_Pin; | ||||
|         GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; | ||||
|         GPIO_InitStruct.Pull = GPIO_NOPULL; | ||||
|         GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; | ||||
|         GPIO_InitStruct.Alternate = GPIO_AF2_TIM5; | ||||
|         HAL_GPIO_Init(SPEAKER_GPIO_Port, &GPIO_InitStruct); | ||||
| 
 | ||||
|   /* USER CODE BEGIN TIM5_MspPostInit 1 */ | ||||
|         /* USER CODE BEGIN TIM5_MspPostInit 1 */ | ||||
| 
 | ||||
|   /* USER CODE END TIM5_MspPostInit 1 */ | ||||
|   } | ||||
|   else if(htim->Instance==TIM15) | ||||
|   { | ||||
|   /* USER CODE BEGIN TIM15_MspPostInit 0 */ | ||||
|         /* USER CODE END TIM5_MspPostInit 1 */ | ||||
|     } else if(htim->Instance == TIM15) { | ||||
|         /* USER CODE BEGIN TIM15_MspPostInit 0 */ | ||||
| 
 | ||||
|   /* USER CODE END TIM15_MspPostInit 0 */ | ||||
|         /* USER CODE END TIM15_MspPostInit 0 */ | ||||
| 
 | ||||
|     __HAL_RCC_GPIOB_CLK_ENABLE(); | ||||
|     /**TIM15 GPIO Configuration    
 | ||||
|         __HAL_RCC_GPIOB_CLK_ENABLE(); | ||||
|         /**TIM15 GPIO Configuration    
 | ||||
|     PB13     ------> TIM15_CH1N | ||||
|     PB15     ------> TIM15_CH2  | ||||
|     */ | ||||
|     GPIO_InitStruct.Pin = RFID_OUT_Pin|RFID_PULL_Pin; | ||||
|     GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; | ||||
|     GPIO_InitStruct.Pull = GPIO_NOPULL; | ||||
|     GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; | ||||
|     GPIO_InitStruct.Alternate = GPIO_AF14_TIM15; | ||||
|     HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); | ||||
|         GPIO_InitStruct.Pin = RFID_OUT_Pin | RFID_PULL_Pin; | ||||
|         GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; | ||||
|         GPIO_InitStruct.Pull = GPIO_NOPULL; | ||||
|         GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; | ||||
|         GPIO_InitStruct.Alternate = GPIO_AF14_TIM15; | ||||
|         HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); | ||||
| 
 | ||||
|   /* USER CODE BEGIN TIM15_MspPostInit 1 */ | ||||
| 
 | ||||
|   /* USER CODE END TIM15_MspPostInit 1 */ | ||||
|   } | ||||
|         /* USER CODE BEGIN TIM15_MspPostInit 1 */ | ||||
| 
 | ||||
|         /* USER CODE END TIM15_MspPostInit 1 */ | ||||
|     } | ||||
| } | ||||
| /**
 | ||||
| * @brief TIM_PWM MSP De-Initialization | ||||
| @ -453,20 +416,17 @@ void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim) | ||||
| * @param htim_pwm: TIM_PWM handle pointer | ||||
| * @retval None | ||||
| */ | ||||
| void HAL_TIM_PWM_MspDeInit(TIM_HandleTypeDef* htim_pwm) | ||||
| { | ||||
|   if(htim_pwm->Instance==TIM5) | ||||
|   { | ||||
|   /* USER CODE BEGIN TIM5_MspDeInit 0 */ | ||||
| void HAL_TIM_PWM_MspDeInit(TIM_HandleTypeDef* htim_pwm) { | ||||
|     if(htim_pwm->Instance == TIM5) { | ||||
|         /* USER CODE BEGIN TIM5_MspDeInit 0 */ | ||||
| 
 | ||||
|   /* USER CODE END TIM5_MspDeInit 0 */ | ||||
|     /* Peripheral clock disable */ | ||||
|     __HAL_RCC_TIM5_CLK_DISABLE(); | ||||
|   /* USER CODE BEGIN TIM5_MspDeInit 1 */ | ||||
| 
 | ||||
|   /* USER CODE END TIM5_MspDeInit 1 */ | ||||
|   } | ||||
|         /* USER CODE END TIM5_MspDeInit 0 */ | ||||
|         /* Peripheral clock disable */ | ||||
|         __HAL_RCC_TIM5_CLK_DISABLE(); | ||||
|         /* USER CODE BEGIN TIM5_MspDeInit 1 */ | ||||
| 
 | ||||
|         /* USER CODE END TIM5_MspDeInit 1 */ | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -475,28 +435,25 @@ void HAL_TIM_PWM_MspDeInit(TIM_HandleTypeDef* htim_pwm) | ||||
| * @param htim_base: TIM_Base handle pointer | ||||
| * @retval None | ||||
| */ | ||||
| void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* htim_base) | ||||
| { | ||||
|   if(htim_base->Instance==TIM8) | ||||
|   { | ||||
|   /* USER CODE BEGIN TIM8_MspDeInit 0 */ | ||||
| void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* htim_base) { | ||||
|     if(htim_base->Instance == TIM8) { | ||||
|         /* USER CODE BEGIN TIM8_MspDeInit 0 */ | ||||
| 
 | ||||
|   /* USER CODE END TIM8_MspDeInit 0 */ | ||||
|     /* Peripheral clock disable */ | ||||
|     __HAL_RCC_TIM8_CLK_DISABLE(); | ||||
|         /* USER CODE END TIM8_MspDeInit 0 */ | ||||
|         /* Peripheral clock disable */ | ||||
|         __HAL_RCC_TIM8_CLK_DISABLE(); | ||||
| 
 | ||||
|     /**TIM8 GPIO Configuration    
 | ||||
|         /**TIM8 GPIO Configuration    
 | ||||
|     PC7     ------> TIM8_CH2  | ||||
|     */ | ||||
|     HAL_GPIO_DeInit(iButton_GPIO_Port, iButton_Pin); | ||||
|         HAL_GPIO_DeInit(iButton_GPIO_Port, iButton_Pin); | ||||
| 
 | ||||
|     /* TIM8 interrupt DeInit */ | ||||
|     HAL_NVIC_DisableIRQ(TIM8_CC_IRQn); | ||||
|   /* USER CODE BEGIN TIM8_MspDeInit 1 */ | ||||
| 
 | ||||
|   /* USER CODE END TIM8_MspDeInit 1 */ | ||||
|   } | ||||
|         /* TIM8 interrupt DeInit */ | ||||
|         HAL_NVIC_DisableIRQ(TIM8_CC_IRQn); | ||||
|         /* USER CODE BEGIN TIM8_MspDeInit 1 */ | ||||
| 
 | ||||
|         /* USER CODE END TIM8_MspDeInit 1 */ | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -505,20 +462,17 @@ void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* htim_base) | ||||
| * @param htim_oc: TIM_OC handle pointer | ||||
| * @retval None | ||||
| */ | ||||
| void HAL_TIM_OC_MspDeInit(TIM_HandleTypeDef* htim_oc) | ||||
| { | ||||
|   if(htim_oc->Instance==TIM15) | ||||
|   { | ||||
|   /* USER CODE BEGIN TIM15_MspDeInit 0 */ | ||||
| void HAL_TIM_OC_MspDeInit(TIM_HandleTypeDef* htim_oc) { | ||||
|     if(htim_oc->Instance == TIM15) { | ||||
|         /* USER CODE BEGIN TIM15_MspDeInit 0 */ | ||||
| 
 | ||||
|   /* USER CODE END TIM15_MspDeInit 0 */ | ||||
|     /* Peripheral clock disable */ | ||||
|     __HAL_RCC_TIM15_CLK_DISABLE(); | ||||
|   /* USER CODE BEGIN TIM15_MspDeInit 1 */ | ||||
| 
 | ||||
|   /* USER CODE END TIM15_MspDeInit 1 */ | ||||
|   } | ||||
|         /* USER CODE END TIM15_MspDeInit 0 */ | ||||
|         /* Peripheral clock disable */ | ||||
|         __HAL_RCC_TIM15_CLK_DISABLE(); | ||||
|         /* USER CODE BEGIN TIM15_MspDeInit 1 */ | ||||
| 
 | ||||
|         /* USER CODE END TIM15_MspDeInit 1 */ | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -527,34 +481,31 @@ void HAL_TIM_OC_MspDeInit(TIM_HandleTypeDef* htim_oc) | ||||
| * @param huart: UART handle pointer | ||||
| * @retval None | ||||
| */ | ||||
| void HAL_UART_MspInit(UART_HandleTypeDef* huart) | ||||
| { | ||||
|   GPIO_InitTypeDef GPIO_InitStruct = {0}; | ||||
|   if(huart->Instance==USART1) | ||||
|   { | ||||
|   /* USER CODE BEGIN USART1_MspInit 0 */ | ||||
| void HAL_UART_MspInit(UART_HandleTypeDef* huart) { | ||||
|     GPIO_InitTypeDef GPIO_InitStruct = {0}; | ||||
|     if(huart->Instance == USART1) { | ||||
|         /* USER CODE BEGIN USART1_MspInit 0 */ | ||||
| 
 | ||||
|   /* USER CODE END USART1_MspInit 0 */ | ||||
|     /* Peripheral clock enable */ | ||||
|     __HAL_RCC_USART1_CLK_ENABLE(); | ||||
|         /* USER CODE END USART1_MspInit 0 */ | ||||
|         /* Peripheral clock enable */ | ||||
|         __HAL_RCC_USART1_CLK_ENABLE(); | ||||
| 
 | ||||
|     __HAL_RCC_GPIOA_CLK_ENABLE(); | ||||
|     /**USART1 GPIO Configuration    
 | ||||
|         __HAL_RCC_GPIOA_CLK_ENABLE(); | ||||
|         /**USART1 GPIO Configuration    
 | ||||
|     PA9     ------> USART1_TX | ||||
|     PA10     ------> USART1_RX  | ||||
|     */ | ||||
|     GPIO_InitStruct.Pin = GPIO_PIN_9|GPIO_PIN_10; | ||||
|     GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; | ||||
|     GPIO_InitStruct.Pull = GPIO_NOPULL; | ||||
|     GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; | ||||
|     GPIO_InitStruct.Alternate = GPIO_AF7_USART1; | ||||
|     HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); | ||||
|         GPIO_InitStruct.Pin = GPIO_PIN_9 | GPIO_PIN_10; | ||||
|         GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; | ||||
|         GPIO_InitStruct.Pull = GPIO_NOPULL; | ||||
|         GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; | ||||
|         GPIO_InitStruct.Alternate = GPIO_AF7_USART1; | ||||
|         HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); | ||||
| 
 | ||||
|   /* USER CODE BEGIN USART1_MspInit 1 */ | ||||
| 
 | ||||
|   /* USER CODE END USART1_MspInit 1 */ | ||||
|   } | ||||
|         /* USER CODE BEGIN USART1_MspInit 1 */ | ||||
| 
 | ||||
|         /* USER CODE END USART1_MspInit 1 */ | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -563,27 +514,24 @@ void HAL_UART_MspInit(UART_HandleTypeDef* huart) | ||||
| * @param huart: UART handle pointer | ||||
| * @retval None | ||||
| */ | ||||
| void HAL_UART_MspDeInit(UART_HandleTypeDef* huart) | ||||
| { | ||||
|   if(huart->Instance==USART1) | ||||
|   { | ||||
|   /* USER CODE BEGIN USART1_MspDeInit 0 */ | ||||
| void HAL_UART_MspDeInit(UART_HandleTypeDef* huart) { | ||||
|     if(huart->Instance == USART1) { | ||||
|         /* USER CODE BEGIN USART1_MspDeInit 0 */ | ||||
| 
 | ||||
|   /* USER CODE END USART1_MspDeInit 0 */ | ||||
|     /* Peripheral clock disable */ | ||||
|     __HAL_RCC_USART1_CLK_DISABLE(); | ||||
|         /* USER CODE END USART1_MspDeInit 0 */ | ||||
|         /* Peripheral clock disable */ | ||||
|         __HAL_RCC_USART1_CLK_DISABLE(); | ||||
| 
 | ||||
|     /**USART1 GPIO Configuration    
 | ||||
|         /**USART1 GPIO Configuration    
 | ||||
|     PA9     ------> USART1_TX | ||||
|     PA10     ------> USART1_RX  | ||||
|     */ | ||||
|     HAL_GPIO_DeInit(GPIOA, GPIO_PIN_9|GPIO_PIN_10); | ||||
|         HAL_GPIO_DeInit(GPIOA, GPIO_PIN_9 | GPIO_PIN_10); | ||||
| 
 | ||||
|   /* USER CODE BEGIN USART1_MspDeInit 1 */ | ||||
| 
 | ||||
|   /* USER CODE END USART1_MspDeInit 1 */ | ||||
|   } | ||||
|         /* USER CODE BEGIN USART1_MspDeInit 1 */ | ||||
| 
 | ||||
|         /* USER CODE END USART1_MspDeInit 1 */ | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /* USER CODE BEGIN 1 */ | ||||
|  | ||||
| @ -70,109 +70,97 @@ extern TIM_HandleTypeDef htim8; | ||||
| /**
 | ||||
|   * @brief This function handles Non maskable interrupt. | ||||
|   */ | ||||
| void NMI_Handler(void) | ||||
| { | ||||
|   /* USER CODE BEGIN NonMaskableInt_IRQn 0 */ | ||||
| void NMI_Handler(void) { | ||||
|     /* USER CODE BEGIN NonMaskableInt_IRQn 0 */ | ||||
| 
 | ||||
|   /* USER CODE END NonMaskableInt_IRQn 0 */ | ||||
|   /* USER CODE BEGIN NonMaskableInt_IRQn 1 */ | ||||
|     /* USER CODE END NonMaskableInt_IRQn 0 */ | ||||
|     /* USER CODE BEGIN NonMaskableInt_IRQn 1 */ | ||||
| 
 | ||||
|   /* USER CODE END NonMaskableInt_IRQn 1 */ | ||||
|     /* USER CODE END NonMaskableInt_IRQn 1 */ | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
|   * @brief This function handles Hard fault interrupt. | ||||
|   */ | ||||
| void HardFault_Handler(void) | ||||
| { | ||||
|   /* USER CODE BEGIN HardFault_IRQn 0 */ | ||||
| void HardFault_Handler(void) { | ||||
|     /* USER CODE BEGIN HardFault_IRQn 0 */ | ||||
| 
 | ||||
|   /* USER CODE END HardFault_IRQn 0 */ | ||||
|   while (1) | ||||
|   { | ||||
|     /* USER CODE BEGIN W1_HardFault_IRQn 0 */ | ||||
|     /* USER CODE END W1_HardFault_IRQn 0 */ | ||||
|   } | ||||
|     /* USER CODE END HardFault_IRQn 0 */ | ||||
|     while(1) { | ||||
|         /* USER CODE BEGIN W1_HardFault_IRQn 0 */ | ||||
|         /* USER CODE END W1_HardFault_IRQn 0 */ | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
|   * @brief This function handles Memory management fault. | ||||
|   */ | ||||
| void MemManage_Handler(void) | ||||
| { | ||||
|   /* USER CODE BEGIN MemoryManagement_IRQn 0 */ | ||||
| void MemManage_Handler(void) { | ||||
|     /* USER CODE BEGIN MemoryManagement_IRQn 0 */ | ||||
| 
 | ||||
|   /* USER CODE END MemoryManagement_IRQn 0 */ | ||||
|   while (1) | ||||
|   { | ||||
|     /* USER CODE BEGIN W1_MemoryManagement_IRQn 0 */ | ||||
|     /* USER CODE END W1_MemoryManagement_IRQn 0 */ | ||||
|   } | ||||
|     /* USER CODE END MemoryManagement_IRQn 0 */ | ||||
|     while(1) { | ||||
|         /* USER CODE BEGIN W1_MemoryManagement_IRQn 0 */ | ||||
|         /* USER CODE END W1_MemoryManagement_IRQn 0 */ | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
|   * @brief This function handles Prefetch fault, memory access fault. | ||||
|   */ | ||||
| void BusFault_Handler(void) | ||||
| { | ||||
|   /* USER CODE BEGIN BusFault_IRQn 0 */ | ||||
| void BusFault_Handler(void) { | ||||
|     /* USER CODE BEGIN BusFault_IRQn 0 */ | ||||
| 
 | ||||
|   /* USER CODE END BusFault_IRQn 0 */ | ||||
|   while (1) | ||||
|   { | ||||
|     /* USER CODE BEGIN W1_BusFault_IRQn 0 */ | ||||
|     /* USER CODE END W1_BusFault_IRQn 0 */ | ||||
|   } | ||||
|     /* USER CODE END BusFault_IRQn 0 */ | ||||
|     while(1) { | ||||
|         /* USER CODE BEGIN W1_BusFault_IRQn 0 */ | ||||
|         /* USER CODE END W1_BusFault_IRQn 0 */ | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
|   * @brief This function handles Undefined instruction or illegal state. | ||||
|   */ | ||||
| void UsageFault_Handler(void) | ||||
| { | ||||
|   /* USER CODE BEGIN UsageFault_IRQn 0 */ | ||||
| void UsageFault_Handler(void) { | ||||
|     /* USER CODE BEGIN UsageFault_IRQn 0 */ | ||||
| 
 | ||||
|   /* USER CODE END UsageFault_IRQn 0 */ | ||||
|   while (1) | ||||
|   { | ||||
|     /* USER CODE BEGIN W1_UsageFault_IRQn 0 */ | ||||
|     /* USER CODE END W1_UsageFault_IRQn 0 */ | ||||
|   } | ||||
|     /* USER CODE END UsageFault_IRQn 0 */ | ||||
|     while(1) { | ||||
|         /* USER CODE BEGIN W1_UsageFault_IRQn 0 */ | ||||
|         /* USER CODE END W1_UsageFault_IRQn 0 */ | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
|   * @brief This function handles Debug monitor. | ||||
|   */ | ||||
| void DebugMon_Handler(void) | ||||
| { | ||||
|   /* USER CODE BEGIN DebugMonitor_IRQn 0 */ | ||||
| void DebugMon_Handler(void) { | ||||
|     /* USER CODE BEGIN DebugMonitor_IRQn 0 */ | ||||
| 
 | ||||
|   /* USER CODE END DebugMonitor_IRQn 0 */ | ||||
|   /* USER CODE BEGIN DebugMonitor_IRQn 1 */ | ||||
|     /* USER CODE END DebugMonitor_IRQn 0 */ | ||||
|     /* USER CODE BEGIN DebugMonitor_IRQn 1 */ | ||||
| 
 | ||||
|   /* USER CODE END DebugMonitor_IRQn 1 */ | ||||
|     /* USER CODE END DebugMonitor_IRQn 1 */ | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
|   * @brief This function handles System tick timer. | ||||
|   */ | ||||
| void SysTick_Handler(void) | ||||
| { | ||||
|   /* USER CODE BEGIN SysTick_IRQn 0 */ | ||||
| void SysTick_Handler(void) { | ||||
|     /* USER CODE BEGIN SysTick_IRQn 0 */ | ||||
| 
 | ||||
|   /* USER CODE END SysTick_IRQn 0 */ | ||||
|   HAL_IncTick(); | ||||
| #if (INCLUDE_xTaskGetSchedulerState == 1 ) | ||||
|   if (xTaskGetSchedulerState() != taskSCHEDULER_NOT_STARTED) | ||||
|   { | ||||
|     /* USER CODE END SysTick_IRQn 0 */ | ||||
|     HAL_IncTick(); | ||||
| #if(INCLUDE_xTaskGetSchedulerState == 1) | ||||
|     if(xTaskGetSchedulerState() != taskSCHEDULER_NOT_STARTED) { | ||||
| #endif /* INCLUDE_xTaskGetSchedulerState */ | ||||
|   xPortSysTickHandler(); | ||||
| #if (INCLUDE_xTaskGetSchedulerState == 1 ) | ||||
|   } | ||||
|         xPortSysTickHandler(); | ||||
| #if(INCLUDE_xTaskGetSchedulerState == 1) | ||||
|     } | ||||
| #endif /* INCLUDE_xTaskGetSchedulerState */ | ||||
|   /* USER CODE BEGIN SysTick_IRQn 1 */ | ||||
|     /* USER CODE BEGIN SysTick_IRQn 1 */ | ||||
| 
 | ||||
|   /* USER CODE END SysTick_IRQn 1 */ | ||||
|     /* USER CODE END SysTick_IRQn 1 */ | ||||
| } | ||||
| 
 | ||||
| /******************************************************************************/ | ||||
| @ -185,115 +173,105 @@ void SysTick_Handler(void) | ||||
| /**
 | ||||
|   * @brief This function handles EXTI line0 interrupt. | ||||
|   */ | ||||
| void EXTI0_IRQHandler(void) | ||||
| { | ||||
|   /* USER CODE BEGIN EXTI0_IRQn 0 */ | ||||
| void EXTI0_IRQHandler(void) { | ||||
|     /* USER CODE BEGIN EXTI0_IRQn 0 */ | ||||
| 
 | ||||
|   /* USER CODE END EXTI0_IRQn 0 */ | ||||
|   HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_0); | ||||
|   /* USER CODE BEGIN EXTI0_IRQn 1 */ | ||||
|     /* USER CODE END EXTI0_IRQn 0 */ | ||||
|     HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_0); | ||||
|     /* USER CODE BEGIN EXTI0_IRQn 1 */ | ||||
| 
 | ||||
|   /* USER CODE END EXTI0_IRQn 1 */ | ||||
|     /* USER CODE END EXTI0_IRQn 1 */ | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
|   * @brief This function handles EXTI line1 interrupt. | ||||
|   */ | ||||
| void EXTI1_IRQHandler(void) | ||||
| { | ||||
|   /* USER CODE BEGIN EXTI1_IRQn 0 */ | ||||
| void EXTI1_IRQHandler(void) { | ||||
|     /* USER CODE BEGIN EXTI1_IRQn 0 */ | ||||
| 
 | ||||
|   /* USER CODE END EXTI1_IRQn 0 */ | ||||
|   HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_1); | ||||
|   /* USER CODE BEGIN EXTI1_IRQn 1 */ | ||||
|     /* USER CODE END EXTI1_IRQn 0 */ | ||||
|     HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_1); | ||||
|     /* USER CODE BEGIN EXTI1_IRQn 1 */ | ||||
| 
 | ||||
|   /* USER CODE END EXTI1_IRQn 1 */ | ||||
|     /* USER CODE END EXTI1_IRQn 1 */ | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
|   * @brief This function handles EXTI line2 interrupt. | ||||
|   */ | ||||
| void EXTI2_IRQHandler(void) | ||||
| { | ||||
|   /* USER CODE BEGIN EXTI2_IRQn 0 */ | ||||
| void EXTI2_IRQHandler(void) { | ||||
|     /* USER CODE BEGIN EXTI2_IRQn 0 */ | ||||
| 
 | ||||
|   /* USER CODE END EXTI2_IRQn 0 */ | ||||
|   HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_2); | ||||
|   /* USER CODE BEGIN EXTI2_IRQn 1 */ | ||||
|     /* USER CODE END EXTI2_IRQn 0 */ | ||||
|     HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_2); | ||||
|     /* USER CODE BEGIN EXTI2_IRQn 1 */ | ||||
| 
 | ||||
|   /* USER CODE END EXTI2_IRQn 1 */ | ||||
|     /* USER CODE END EXTI2_IRQn 1 */ | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
|   * @brief This function handles EXTI line4 interrupt. | ||||
|   */ | ||||
| void EXTI4_IRQHandler(void) | ||||
| { | ||||
|   /* USER CODE BEGIN EXTI4_IRQn 0 */ | ||||
| void EXTI4_IRQHandler(void) { | ||||
|     /* USER CODE BEGIN EXTI4_IRQn 0 */ | ||||
| 
 | ||||
|   /* USER CODE END EXTI4_IRQn 0 */ | ||||
|   HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_4); | ||||
|   /* USER CODE BEGIN EXTI4_IRQn 1 */ | ||||
|     /* USER CODE END EXTI4_IRQn 0 */ | ||||
|     HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_4); | ||||
|     /* USER CODE BEGIN EXTI4_IRQn 1 */ | ||||
| 
 | ||||
|   /* USER CODE END EXTI4_IRQn 1 */ | ||||
|     /* USER CODE END EXTI4_IRQn 1 */ | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
|   * @brief This function handles EXTI line[9:5] interrupts. | ||||
|   */ | ||||
| void EXTI9_5_IRQHandler(void) | ||||
| { | ||||
|   /* USER CODE BEGIN EXTI9_5_IRQn 0 */ | ||||
| void EXTI9_5_IRQHandler(void) { | ||||
|     /* USER CODE BEGIN EXTI9_5_IRQn 0 */ | ||||
| 
 | ||||
|   /* USER CODE END EXTI9_5_IRQn 0 */ | ||||
|   HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_6); | ||||
|   HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_8); | ||||
|   HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_9); | ||||
|   /* USER CODE BEGIN EXTI9_5_IRQn 1 */ | ||||
|     /* USER CODE END EXTI9_5_IRQn 0 */ | ||||
|     HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_6); | ||||
|     HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_8); | ||||
|     HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_9); | ||||
|     /* USER CODE BEGIN EXTI9_5_IRQn 1 */ | ||||
| 
 | ||||
|   /* USER CODE END EXTI9_5_IRQn 1 */ | ||||
|     /* USER CODE END EXTI9_5_IRQn 1 */ | ||||
| } | ||||
| 
 | ||||
| void(*tim8_callback_ch2)(uint16_t ccr, TimerEvent tim_event); | ||||
| void (*tim8_callback_ch2)(uint16_t ccr, TimerEvent tim_event); | ||||
| 
 | ||||
| void register_tim8_callback_ch2(void(*callback)(uint16_t ccr, TimerEvent tim_event)) { | ||||
|   tim8_callback_ch2 = callback; | ||||
| void register_tim8_callback_ch2(void (*callback)(uint16_t ccr, TimerEvent tim_event)) { | ||||
|     tim8_callback_ch2 = callback; | ||||
| } | ||||
| /**
 | ||||
|   * @brief This function handles TIM8 capture compare interrupt. | ||||
|   */ | ||||
| void TIM8_CC_IRQHandler(void) | ||||
| { | ||||
|   /* USER CODE BEGIN TIM8_CC_IRQn 0 */ | ||||
| void TIM8_CC_IRQHandler(void) { | ||||
|     /* USER CODE BEGIN TIM8_CC_IRQn 0 */ | ||||
| 
 | ||||
|   /* Capture compare 2 event */ | ||||
|   if (__HAL_TIM_GET_FLAG(&htim8, TIM_FLAG_CC2) != RESET) | ||||
|   { | ||||
|     if (__HAL_TIM_GET_IT_SOURCE(&htim8, TIM_IT_CC2) != RESET) | ||||
|     { | ||||
|       __HAL_TIM_CLEAR_IT(&htim8, TIM_IT_CC2); | ||||
|       htim8.Channel = HAL_TIM_ACTIVE_CHANNEL_2; | ||||
|       /* Input capture event */ | ||||
|       if ((htim8.Instance->CCMR1 & TIM_CCMR1_CC2S) != 0x00U) | ||||
|       { | ||||
| /*
 | ||||
|     /* Capture compare 2 event */ | ||||
|     if(__HAL_TIM_GET_FLAG(&htim8, TIM_FLAG_CC2) != RESET) { | ||||
|         if(__HAL_TIM_GET_IT_SOURCE(&htim8, TIM_IT_CC2) != RESET) { | ||||
|             __HAL_TIM_CLEAR_IT(&htim8, TIM_IT_CC2); | ||||
|             htim8.Channel = HAL_TIM_ACTIVE_CHANNEL_2; | ||||
|             /* Input capture event */ | ||||
|             if((htim8.Instance->CCMR1 & TIM_CCMR1_CC2S) != 0x00U) { | ||||
|                 /*
 | ||||
| #if (USE_HAL_TIM_REGISTER_CALLBACKS == 1) | ||||
|         htim->IC_CaptureCallback(htim); | ||||
| #else | ||||
|         HAL_TIM_IC_CaptureCallback(htim); | ||||
| #endif | ||||
| */ | ||||
|         if(tim8_callback_ch2 != NULL) { | ||||
|           tim8_callback_ch2(htim8.Instance->CCR2, TimerEventInputCapture); | ||||
|         } | ||||
|       } | ||||
|       /* Output compare event */ | ||||
|       else | ||||
|       { | ||||
|         if(tim8_callback_ch2 != NULL) { | ||||
|           tim8_callback_ch2(0, TimerEventEndOfPulse); | ||||
|         } | ||||
| /*
 | ||||
|                 if(tim8_callback_ch2 != NULL) { | ||||
|                     tim8_callback_ch2(htim8.Instance->CCR2, TimerEventInputCapture); | ||||
|                 } | ||||
|             } | ||||
|             /* Output compare event */ | ||||
|             else { | ||||
|                 if(tim8_callback_ch2 != NULL) { | ||||
|                     tim8_callback_ch2(0, TimerEventEndOfPulse); | ||||
|                 } | ||||
|                 /*
 | ||||
| #if (USE_HAL_TIM_REGISTER_CALLBACKS == 1) | ||||
|         htim->OC_DelayElapsedCallback(htim); | ||||
|         htim->PWM_PulseFinishedCallback(htim); | ||||
| @ -302,31 +280,29 @@ void TIM8_CC_IRQHandler(void) | ||||
|         HAL_TIM_PWM_PulseFinishedCallback(htim); | ||||
| #endif | ||||
| */ | ||||
|       } | ||||
|       htim8.Channel = HAL_TIM_ACTIVE_CHANNEL_CLEARED; | ||||
|             } | ||||
|             htim8.Channel = HAL_TIM_ACTIVE_CHANNEL_CLEARED; | ||||
|         } | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|     /* USER CODE END TIM8_CC_IRQn 0 */ | ||||
|     // HAL_TIM_IRQHandler(&htim8);
 | ||||
|     /* USER CODE BEGIN TIM8_CC_IRQn 1 */ | ||||
| 
 | ||||
|   /* USER CODE END TIM8_CC_IRQn 0 */ | ||||
|   // HAL_TIM_IRQHandler(&htim8);
 | ||||
|   /* USER CODE BEGIN TIM8_CC_IRQn 1 */ | ||||
| 
 | ||||
|   /* USER CODE END TIM8_CC_IRQn 1 */ | ||||
|     /* USER CODE END TIM8_CC_IRQn 1 */ | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
|   * @brief This function handles USB OTG FS global interrupt. | ||||
|   */ | ||||
| void OTG_FS_IRQHandler(void) | ||||
| { | ||||
|   /* USER CODE BEGIN OTG_FS_IRQn 0 */ | ||||
| void OTG_FS_IRQHandler(void) { | ||||
|     /* USER CODE BEGIN OTG_FS_IRQn 0 */ | ||||
| 
 | ||||
|   /* USER CODE END OTG_FS_IRQn 0 */ | ||||
|   HAL_PCD_IRQHandler(&hpcd_USB_OTG_FS); | ||||
|   /* USER CODE BEGIN OTG_FS_IRQn 1 */ | ||||
|     /* USER CODE END OTG_FS_IRQn 0 */ | ||||
|     HAL_PCD_IRQHandler(&hpcd_USB_OTG_FS); | ||||
|     /* USER CODE BEGIN OTG_FS_IRQn 1 */ | ||||
| 
 | ||||
|   /* USER CODE END OTG_FS_IRQn 1 */ | ||||
|     /* USER CODE END OTG_FS_IRQn 1 */ | ||||
| } | ||||
| 
 | ||||
| /* USER CODE BEGIN 1 */ | ||||
|  | ||||
| @ -91,16 +91,16 @@ | ||||
| 
 | ||||
| #include "stm32l4xx.h" | ||||
| 
 | ||||
| #if !defined  (HSE_VALUE) | ||||
|   #define HSE_VALUE    8000000U  /*!< Value of the External oscillator in Hz */ | ||||
| #if !defined(HSE_VALUE) | ||||
| #define HSE_VALUE 8000000U /*!< Value of the External oscillator in Hz */ | ||||
| #endif /* HSE_VALUE */ | ||||
| 
 | ||||
| #if !defined  (MSI_VALUE) | ||||
|   #define MSI_VALUE    4000000U  /*!< Value of the Internal oscillator in Hz*/ | ||||
| #if !defined(MSI_VALUE) | ||||
| #define MSI_VALUE 4000000U /*!< Value of the Internal oscillator in Hz*/ | ||||
| #endif /* MSI_VALUE */ | ||||
| 
 | ||||
| #if !defined  (HSI_VALUE) | ||||
|   #define HSI_VALUE    16000000U /*!< Value of the Internal oscillator in Hz*/ | ||||
| #if !defined(HSI_VALUE) | ||||
| #define HSI_VALUE 16000000U /*!< Value of the Internal oscillator in Hz*/ | ||||
| #endif /* HSI_VALUE */ | ||||
| 
 | ||||
| /**
 | ||||
| @ -123,7 +123,8 @@ | ||||
| /*!< Uncomment the following line if you need to relocate your vector Table in
 | ||||
|      Internal SRAM. */ | ||||
| /* #define VECT_TAB_SRAM */ | ||||
| #define VECT_TAB_OFFSET  0x00 /*!< Vector Table base offset field. | ||||
| #define VECT_TAB_OFFSET \ | ||||
|     0x00 /*!< Vector Table base offset field.
 | ||||
|                                    This value must be a multiple of 0x200. */ | ||||
| /******************************************************************************/ | ||||
| /**
 | ||||
| @ -141,7 +142,7 @@ | ||||
| /** @addtogroup STM32L4xx_System_Private_Variables
 | ||||
|   * @{ | ||||
|   */ | ||||
|   /* The SystemCoreClock variable is updated in three ways:
 | ||||
| /* The SystemCoreClock variable is updated in three ways:
 | ||||
|       1) by calling CMSIS function SystemCoreClockUpdate() | ||||
|       2) by calling HAL API function HAL_RCC_GetHCLKFreq() | ||||
|       3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency | ||||
| @ -149,12 +150,22 @@ | ||||
|                is no need to call the 2 first functions listed above, since SystemCoreClock | ||||
|                variable is updated automatically. | ||||
|   */ | ||||
|   uint32_t SystemCoreClock = 4000000U; | ||||
| uint32_t SystemCoreClock = 4000000U; | ||||
| 
 | ||||
|   const uint8_t  AHBPrescTable[16] = {0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 1U, 2U, 3U, 4U, 6U, 7U, 8U, 9U}; | ||||
|   const uint8_t  APBPrescTable[8] =  {0U, 0U, 0U, 0U, 1U, 2U, 3U, 4U}; | ||||
|   const uint32_t MSIRangeTable[12] = {100000U,   200000U,   400000U,   800000U,  1000000U,  2000000U, \ | ||||
|                                       4000000U, 8000000U, 16000000U, 24000000U, 32000000U, 48000000U}; | ||||
| const uint8_t AHBPrescTable[16] = {0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 1U, 2U, 3U, 4U, 6U, 7U, 8U, 9U}; | ||||
| const uint8_t APBPrescTable[8] = {0U, 0U, 0U, 0U, 1U, 2U, 3U, 4U}; | ||||
| const uint32_t MSIRangeTable[12] = {100000U, | ||||
|                                     200000U, | ||||
|                                     400000U, | ||||
|                                     800000U, | ||||
|                                     1000000U, | ||||
|                                     2000000U, | ||||
|                                     4000000U, | ||||
|                                     8000000U, | ||||
|                                     16000000U, | ||||
|                                     24000000U, | ||||
|                                     32000000U, | ||||
|                                     48000000U}; | ||||
| /**
 | ||||
|   * @} | ||||
|   */ | ||||
| @ -177,37 +188,36 @@ | ||||
|   * @retval None | ||||
|   */ | ||||
| 
 | ||||
| void SystemInit(void) | ||||
| { | ||||
|   /* FPU settings ------------------------------------------------------------*/ | ||||
|   #if (__FPU_PRESENT == 1) && (__FPU_USED == 1) | ||||
|     SCB->CPACR |= ((3UL << 10*2)|(3UL << 11*2));  /* set CP10 and CP11 Full Access */ | ||||
|   #endif | ||||
| void SystemInit(void) { | ||||
| /* FPU settings ------------------------------------------------------------*/ | ||||
| #if(__FPU_PRESENT == 1) && (__FPU_USED == 1) | ||||
|     SCB->CPACR |= ((3UL << 10 * 2) | (3UL << 11 * 2)); /* set CP10 and CP11 Full Access */ | ||||
| #endif | ||||
| 
 | ||||
|   /* Reset the RCC clock configuration to the default reset state ------------*/ | ||||
|   /* Set MSION bit */ | ||||
|   RCC->CR |= RCC_CR_MSION; | ||||
|     /* Reset the RCC clock configuration to the default reset state ------------*/ | ||||
|     /* Set MSION bit */ | ||||
|     RCC->CR |= RCC_CR_MSION; | ||||
| 
 | ||||
|   /* Reset CFGR register */ | ||||
|   RCC->CFGR = 0x00000000U; | ||||
|     /* Reset CFGR register */ | ||||
|     RCC->CFGR = 0x00000000U; | ||||
| 
 | ||||
|   /* Reset HSEON, CSSON , HSION, and PLLON bits */ | ||||
|   RCC->CR &= 0xEAF6FFFFU; | ||||
|     /* Reset HSEON, CSSON , HSION, and PLLON bits */ | ||||
|     RCC->CR &= 0xEAF6FFFFU; | ||||
| 
 | ||||
|   /* Reset PLLCFGR register */ | ||||
|   RCC->PLLCFGR = 0x00001000U; | ||||
|     /* Reset PLLCFGR register */ | ||||
|     RCC->PLLCFGR = 0x00001000U; | ||||
| 
 | ||||
|   /* Reset HSEBYP bit */ | ||||
|   RCC->CR &= 0xFFFBFFFFU; | ||||
|     /* Reset HSEBYP bit */ | ||||
|     RCC->CR &= 0xFFFBFFFFU; | ||||
| 
 | ||||
|   /* Disable all interrupts */ | ||||
|   RCC->CIER = 0x00000000U; | ||||
|     /* Disable all interrupts */ | ||||
|     RCC->CIER = 0x00000000U; | ||||
| 
 | ||||
|   /* Configure the Vector Table location add offset address ------------------*/ | ||||
|     /* Configure the Vector Table location add offset address ------------------*/ | ||||
| #ifdef VECT_TAB_SRAM | ||||
|   SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */ | ||||
|     SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */ | ||||
| #else | ||||
|   SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */ | ||||
|     SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */ | ||||
| #endif | ||||
| } | ||||
| 
 | ||||
| @ -253,75 +263,68 @@ void SystemInit(void) | ||||
|   * @param  None | ||||
|   * @retval None | ||||
|   */ | ||||
| void SystemCoreClockUpdate(void) | ||||
| { | ||||
|   uint32_t tmp = 0U, msirange = 0U, pllvco = 0U, pllr = 2U, pllsource = 0U, pllm = 2U; | ||||
| void SystemCoreClockUpdate(void) { | ||||
|     uint32_t tmp = 0U, msirange = 0U, pllvco = 0U, pllr = 2U, pllsource = 0U, pllm = 2U; | ||||
| 
 | ||||
|   /* Get MSI Range frequency--------------------------------------------------*/ | ||||
|   if((RCC->CR & RCC_CR_MSIRGSEL) == RESET) | ||||
|   { /* MSISRANGE from RCC_CSR applies */ | ||||
|     msirange = (RCC->CSR & RCC_CSR_MSISRANGE) >> 8U; | ||||
|   } | ||||
|   else | ||||
|   { /* MSIRANGE from RCC_CR applies */ | ||||
|     msirange = (RCC->CR & RCC_CR_MSIRANGE) >> 4U; | ||||
|   } | ||||
|   /*MSI frequency range in HZ*/ | ||||
|   msirange = MSIRangeTable[msirange]; | ||||
|     /* Get MSI Range frequency--------------------------------------------------*/ | ||||
|     if((RCC->CR & RCC_CR_MSIRGSEL) == RESET) { /* MSISRANGE from RCC_CSR applies */ | ||||
|         msirange = (RCC->CSR & RCC_CSR_MSISRANGE) >> 8U; | ||||
|     } else { /* MSIRANGE from RCC_CR applies */ | ||||
|         msirange = (RCC->CR & RCC_CR_MSIRANGE) >> 4U; | ||||
|     } | ||||
|     /*MSI frequency range in HZ*/ | ||||
|     msirange = MSIRangeTable[msirange]; | ||||
| 
 | ||||
|   /* Get SYSCLK source -------------------------------------------------------*/ | ||||
|   switch (RCC->CFGR & RCC_CFGR_SWS) | ||||
|   { | ||||
|     case 0x00:  /* MSI used as system clock source */ | ||||
|       SystemCoreClock = msirange; | ||||
|       break; | ||||
|     /* Get SYSCLK source -------------------------------------------------------*/ | ||||
|     switch(RCC->CFGR & RCC_CFGR_SWS) { | ||||
|     case 0x00: /* MSI used as system clock source */ | ||||
|         SystemCoreClock = msirange; | ||||
|         break; | ||||
| 
 | ||||
|     case 0x04:  /* HSI used as system clock source */ | ||||
|       SystemCoreClock = HSI_VALUE; | ||||
|       break; | ||||
|     case 0x04: /* HSI used as system clock source */ | ||||
|         SystemCoreClock = HSI_VALUE; | ||||
|         break; | ||||
| 
 | ||||
|     case 0x08:  /* HSE used as system clock source */ | ||||
|       SystemCoreClock = HSE_VALUE; | ||||
|       break; | ||||
|     case 0x08: /* HSE used as system clock source */ | ||||
|         SystemCoreClock = HSE_VALUE; | ||||
|         break; | ||||
| 
 | ||||
|     case 0x0C:  /* PLL used as system clock  source */ | ||||
|       /* PLL_VCO = (HSE_VALUE or HSI_VALUE or MSI_VALUE/ PLLM) * PLLN
 | ||||
|     case 0x0C: /* PLL used as system clock  source */ | ||||
|         /* PLL_VCO = (HSE_VALUE or HSI_VALUE or MSI_VALUE/ PLLM) * PLLN
 | ||||
|          SYSCLK = PLL_VCO / PLLR | ||||
|          */ | ||||
|       pllsource = (RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC); | ||||
|       pllm = ((RCC->PLLCFGR & RCC_PLLCFGR_PLLM) >> 4U) + 1U ; | ||||
|         pllsource = (RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC); | ||||
|         pllm = ((RCC->PLLCFGR & RCC_PLLCFGR_PLLM) >> 4U) + 1U; | ||||
| 
 | ||||
|       switch (pllsource) | ||||
|       { | ||||
|         case 0x02:  /* HSI used as PLL clock source */ | ||||
|           pllvco = (HSI_VALUE / pllm); | ||||
|           break; | ||||
|         switch(pllsource) { | ||||
|         case 0x02: /* HSI used as PLL clock source */ | ||||
|             pllvco = (HSI_VALUE / pllm); | ||||
|             break; | ||||
| 
 | ||||
|         case 0x03:  /* HSE used as PLL clock source */ | ||||
|           pllvco = (HSE_VALUE / pllm); | ||||
|           break; | ||||
|         case 0x03: /* HSE used as PLL clock source */ | ||||
|             pllvco = (HSE_VALUE / pllm); | ||||
|             break; | ||||
| 
 | ||||
|         default:    /* MSI used as PLL clock source */ | ||||
|           pllvco = (msirange / pllm); | ||||
|           break; | ||||
|       } | ||||
|       pllvco = pllvco * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 8U); | ||||
|       pllr = (((RCC->PLLCFGR & RCC_PLLCFGR_PLLR) >> 25U) + 1U) * 2U; | ||||
|       SystemCoreClock = pllvco/pllr; | ||||
|       break; | ||||
|         default: /* MSI used as PLL clock source */ | ||||
|             pllvco = (msirange / pllm); | ||||
|             break; | ||||
|         } | ||||
|         pllvco = pllvco * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 8U); | ||||
|         pllr = (((RCC->PLLCFGR & RCC_PLLCFGR_PLLR) >> 25U) + 1U) * 2U; | ||||
|         SystemCoreClock = pllvco / pllr; | ||||
|         break; | ||||
| 
 | ||||
|     default: | ||||
|       SystemCoreClock = msirange; | ||||
|       break; | ||||
|   } | ||||
|   /* Compute HCLK clock frequency --------------------------------------------*/ | ||||
|   /* Get HCLK prescaler */ | ||||
|   tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4U)]; | ||||
|   /* HCLK clock frequency */ | ||||
|   SystemCoreClock >>= tmp; | ||||
|         SystemCoreClock = msirange; | ||||
|         break; | ||||
|     } | ||||
|     /* Compute HCLK clock frequency --------------------------------------------*/ | ||||
|     /* Get HCLK prescaler */ | ||||
|     tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4U)]; | ||||
|     /* HCLK clock frequency */ | ||||
|     SystemCoreClock >>= tmp; | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| /**
 | ||||
|   * @} | ||||
|   */ | ||||
|  | ||||
| @ -63,32 +63,27 @@ extern USBD_DescriptorsTypeDef FS_Desc; | ||||
|   * Init USB device Library, add supported class and start the library | ||||
|   * @retval None | ||||
|   */ | ||||
| void MX_USB_DEVICE_Init(void) | ||||
| { | ||||
|   /* USER CODE BEGIN USB_DEVICE_Init_PreTreatment */ | ||||
| void MX_USB_DEVICE_Init(void) { | ||||
|     /* USER CODE BEGIN USB_DEVICE_Init_PreTreatment */ | ||||
| 
 | ||||
|   /* USER CODE END USB_DEVICE_Init_PreTreatment */ | ||||
|     /* USER CODE END USB_DEVICE_Init_PreTreatment */ | ||||
| 
 | ||||
|   /* Init Device Library, add supported class and start the library. */ | ||||
|   if (USBD_Init(&hUsbDeviceFS, &FS_Desc, DEVICE_FS) != USBD_OK) | ||||
|   { | ||||
|     Error_Handler(); | ||||
|   } | ||||
|   if (USBD_RegisterClass(&hUsbDeviceFS, &USBD_CDC) != USBD_OK) | ||||
|   { | ||||
|     Error_Handler(); | ||||
|   } | ||||
|   if (USBD_CDC_RegisterInterface(&hUsbDeviceFS, &USBD_Interface_fops_FS) != USBD_OK) | ||||
|   { | ||||
|     Error_Handler(); | ||||
|   } | ||||
|   if (USBD_Start(&hUsbDeviceFS) != USBD_OK) | ||||
|   { | ||||
|     Error_Handler(); | ||||
|   } | ||||
|   /* USER CODE BEGIN USB_DEVICE_Init_PostTreatment */ | ||||
|     /* Init Device Library, add supported class and start the library. */ | ||||
|     if(USBD_Init(&hUsbDeviceFS, &FS_Desc, DEVICE_FS) != USBD_OK) { | ||||
|         Error_Handler(); | ||||
|     } | ||||
|     if(USBD_RegisterClass(&hUsbDeviceFS, &USBD_CDC) != USBD_OK) { | ||||
|         Error_Handler(); | ||||
|     } | ||||
|     if(USBD_CDC_RegisterInterface(&hUsbDeviceFS, &USBD_Interface_fops_FS) != USBD_OK) { | ||||
|         Error_Handler(); | ||||
|     } | ||||
|     if(USBD_Start(&hUsbDeviceFS) != USBD_OK) { | ||||
|         Error_Handler(); | ||||
|     } | ||||
|     /* USER CODE BEGIN USB_DEVICE_Init_PostTreatment */ | ||||
| 
 | ||||
|   /* USER CODE END USB_DEVICE_Init_PostTreatment */ | ||||
|     /* USER CODE END USB_DEVICE_Init_PostTreatment */ | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
|  | ||||
| @ -65,8 +65,8 @@ | ||||
| /* USER CODE BEGIN PRIVATE_DEFINES */ | ||||
| /* Define size for the receive and transmit buffer over CDC */ | ||||
| /* It's up to user to redefine and/or remove those define */ | ||||
| #define APP_RX_DATA_SIZE  2048 | ||||
| #define APP_TX_DATA_SIZE  2048 | ||||
| #define APP_RX_DATA_SIZE 2048 | ||||
| #define APP_TX_DATA_SIZE 2048 | ||||
| /* USER CODE END PRIVATE_DEFINES */ | ||||
| 
 | ||||
| /**
 | ||||
| @ -129,7 +129,7 @@ extern USBD_HandleTypeDef hUsbDeviceFS; | ||||
| static int8_t CDC_Init_FS(void); | ||||
| static int8_t CDC_DeInit_FS(void); | ||||
| static int8_t CDC_Control_FS(uint8_t cmd, uint8_t* pbuf, uint16_t length); | ||||
| static int8_t CDC_Receive_FS(uint8_t* pbuf, uint32_t *Len); | ||||
| static int8_t CDC_Receive_FS(uint8_t* pbuf, uint32_t* Len); | ||||
| 
 | ||||
| /* USER CODE BEGIN PRIVATE_FUNCTIONS_DECLARATION */ | ||||
| 
 | ||||
| @ -139,38 +139,33 @@ static int8_t CDC_Receive_FS(uint8_t* pbuf, uint32_t *Len); | ||||
|   * @} | ||||
|   */ | ||||
| 
 | ||||
| USBD_CDC_ItfTypeDef USBD_Interface_fops_FS = | ||||
| { | ||||
|   CDC_Init_FS, | ||||
|   CDC_DeInit_FS, | ||||
|   CDC_Control_FS, | ||||
|   CDC_Receive_FS | ||||
| }; | ||||
| USBD_CDC_ItfTypeDef USBD_Interface_fops_FS = {CDC_Init_FS, | ||||
|                                               CDC_DeInit_FS, | ||||
|                                               CDC_Control_FS, | ||||
|                                               CDC_Receive_FS}; | ||||
| 
 | ||||
| /* Private functions ---------------------------------------------------------*/ | ||||
| /**
 | ||||
|   * @brief  Initializes the CDC media low layer over the FS USB IP | ||||
|   * @retval USBD_OK if all operations are OK else USBD_FAIL | ||||
|   */ | ||||
| static int8_t CDC_Init_FS(void) | ||||
| { | ||||
|   /* USER CODE BEGIN 3 */ | ||||
|   /* Set Application Buffers */ | ||||
|   USBD_CDC_SetTxBuffer(&hUsbDeviceFS, UserTxBufferFS, 0); | ||||
|   USBD_CDC_SetRxBuffer(&hUsbDeviceFS, UserRxBufferFS); | ||||
|   return (USBD_OK); | ||||
|   /* USER CODE END 3 */ | ||||
| static int8_t CDC_Init_FS(void) { | ||||
|     /* USER CODE BEGIN 3 */ | ||||
|     /* Set Application Buffers */ | ||||
|     USBD_CDC_SetTxBuffer(&hUsbDeviceFS, UserTxBufferFS, 0); | ||||
|     USBD_CDC_SetRxBuffer(&hUsbDeviceFS, UserRxBufferFS); | ||||
|     return (USBD_OK); | ||||
|     /* USER CODE END 3 */ | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
|   * @brief  DeInitializes the CDC media low layer | ||||
|   * @retval USBD_OK if all operations are OK else USBD_FAIL | ||||
|   */ | ||||
| static int8_t CDC_DeInit_FS(void) | ||||
| { | ||||
|   /* USER CODE BEGIN 4 */ | ||||
|   return (USBD_OK); | ||||
|   /* USER CODE END 4 */ | ||||
| static int8_t CDC_DeInit_FS(void) { | ||||
|     /* USER CODE BEGIN 4 */ | ||||
|     return (USBD_OK); | ||||
|     /* USER CODE END 4 */ | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -180,70 +175,68 @@ static int8_t CDC_DeInit_FS(void) | ||||
|   * @param  length: Number of data to be sent (in bytes) | ||||
|   * @retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL | ||||
|   */ | ||||
| static int8_t CDC_Control_FS(uint8_t cmd, uint8_t* pbuf, uint16_t length) | ||||
| { | ||||
|   /* USER CODE BEGIN 5 */ | ||||
|   switch(cmd) | ||||
|   { | ||||
| static int8_t CDC_Control_FS(uint8_t cmd, uint8_t* pbuf, uint16_t length) { | ||||
|     /* USER CODE BEGIN 5 */ | ||||
|     switch(cmd) { | ||||
|     case CDC_SEND_ENCAPSULATED_COMMAND: | ||||
| 
 | ||||
|     break; | ||||
|         break; | ||||
| 
 | ||||
|     case CDC_GET_ENCAPSULATED_RESPONSE: | ||||
| 
 | ||||
|     break; | ||||
|         break; | ||||
| 
 | ||||
|     case CDC_SET_COMM_FEATURE: | ||||
| 
 | ||||
|     break; | ||||
|         break; | ||||
| 
 | ||||
|     case CDC_GET_COMM_FEATURE: | ||||
| 
 | ||||
|     break; | ||||
|         break; | ||||
| 
 | ||||
|     case CDC_CLEAR_COMM_FEATURE: | ||||
| 
 | ||||
|     break; | ||||
|         break; | ||||
| 
 | ||||
|   /*******************************************************************************/ | ||||
|   /* Line Coding Structure                                                       */ | ||||
|   /*-----------------------------------------------------------------------------*/ | ||||
|   /* Offset | Field       | Size | Value  | Description                          */ | ||||
|   /* 0      | dwDTERate   |   4  | Number |Data terminal rate, in bits per second*/ | ||||
|   /* 4      | bCharFormat |   1  | Number | Stop bits                            */ | ||||
|   /*                                        0 - 1 Stop bit                       */ | ||||
|   /*                                        1 - 1.5 Stop bits                    */ | ||||
|   /*                                        2 - 2 Stop bits                      */ | ||||
|   /* 5      | bParityType |  1   | Number | Parity                               */ | ||||
|   /*                                        0 - None                             */ | ||||
|   /*                                        1 - Odd                              */ | ||||
|   /*                                        2 - Even                             */ | ||||
|   /*                                        3 - Mark                             */ | ||||
|   /*                                        4 - Space                            */ | ||||
|   /* 6      | bDataBits  |   1   | Number Data bits (5, 6, 7, 8 or 16).          */ | ||||
|   /*******************************************************************************/ | ||||
|         /*******************************************************************************/ | ||||
|         /* Line Coding Structure                                                       */ | ||||
|         /*-----------------------------------------------------------------------------*/ | ||||
|         /* Offset | Field       | Size | Value  | Description                          */ | ||||
|         /* 0      | dwDTERate   |   4  | Number |Data terminal rate, in bits per second*/ | ||||
|         /* 4      | bCharFormat |   1  | Number | Stop bits                            */ | ||||
|         /*                                        0 - 1 Stop bit                       */ | ||||
|         /*                                        1 - 1.5 Stop bits                    */ | ||||
|         /*                                        2 - 2 Stop bits                      */ | ||||
|         /* 5      | bParityType |  1   | Number | Parity                               */ | ||||
|         /*                                        0 - None                             */ | ||||
|         /*                                        1 - Odd                              */ | ||||
|         /*                                        2 - Even                             */ | ||||
|         /*                                        3 - Mark                             */ | ||||
|         /*                                        4 - Space                            */ | ||||
|         /* 6      | bDataBits  |   1   | Number Data bits (5, 6, 7, 8 or 16).          */ | ||||
|         /*******************************************************************************/ | ||||
|     case CDC_SET_LINE_CODING: | ||||
| 
 | ||||
|     break; | ||||
|         break; | ||||
| 
 | ||||
|     case CDC_GET_LINE_CODING: | ||||
| 
 | ||||
|     break; | ||||
|         break; | ||||
| 
 | ||||
|     case CDC_SET_CONTROL_LINE_STATE: | ||||
| 
 | ||||
|     break; | ||||
|         break; | ||||
| 
 | ||||
|     case CDC_SEND_BREAK: | ||||
| 
 | ||||
|     break; | ||||
|         break; | ||||
| 
 | ||||
|   default: | ||||
|     break; | ||||
|   } | ||||
|     default: | ||||
|         break; | ||||
|     } | ||||
| 
 | ||||
|   return (USBD_OK); | ||||
|   /* USER CODE END 5 */ | ||||
|     return (USBD_OK); | ||||
|     /* USER CODE END 5 */ | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -260,13 +253,12 @@ static int8_t CDC_Control_FS(uint8_t cmd, uint8_t* pbuf, uint16_t length) | ||||
|   * @param  Len: Number of data received (in bytes) | ||||
|   * @retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL | ||||
|   */ | ||||
| static int8_t CDC_Receive_FS(uint8_t* Buf, uint32_t *Len) | ||||
| { | ||||
|   /* USER CODE BEGIN 6 */ | ||||
|   USBD_CDC_SetRxBuffer(&hUsbDeviceFS, &Buf[0]); | ||||
|   USBD_CDC_ReceivePacket(&hUsbDeviceFS); | ||||
|   return (USBD_OK); | ||||
|   /* USER CODE END 6 */ | ||||
| static int8_t CDC_Receive_FS(uint8_t* Buf, uint32_t* Len) { | ||||
|     /* USER CODE BEGIN 6 */ | ||||
|     USBD_CDC_SetRxBuffer(&hUsbDeviceFS, &Buf[0]); | ||||
|     USBD_CDC_ReceivePacket(&hUsbDeviceFS); | ||||
|     return (USBD_OK); | ||||
|     /* USER CODE END 6 */ | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -280,18 +272,17 @@ static int8_t CDC_Receive_FS(uint8_t* Buf, uint32_t *Len) | ||||
|   * @param  Len: Number of data to be sent (in bytes) | ||||
|   * @retval USBD_OK if all operations are OK else USBD_FAIL or USBD_BUSY | ||||
|   */ | ||||
| uint8_t CDC_Transmit_FS(uint8_t* Buf, uint16_t Len) | ||||
| { | ||||
|   uint8_t result = USBD_OK; | ||||
|   /* USER CODE BEGIN 7 */ | ||||
|   USBD_CDC_HandleTypeDef *hcdc = (USBD_CDC_HandleTypeDef*)hUsbDeviceFS.pClassData; | ||||
|   if (hcdc->TxState != 0){ | ||||
|     return USBD_BUSY; | ||||
|   } | ||||
|   USBD_CDC_SetTxBuffer(&hUsbDeviceFS, Buf, Len); | ||||
|   result = USBD_CDC_TransmitPacket(&hUsbDeviceFS); | ||||
|   /* USER CODE END 7 */ | ||||
|   return result; | ||||
| uint8_t CDC_Transmit_FS(uint8_t* Buf, uint16_t Len) { | ||||
|     uint8_t result = USBD_OK; | ||||
|     /* USER CODE BEGIN 7 */ | ||||
|     USBD_CDC_HandleTypeDef* hcdc = (USBD_CDC_HandleTypeDef*)hUsbDeviceFS.pClassData; | ||||
|     if(hcdc->TxState != 0) { | ||||
|         return USBD_BUSY; | ||||
|     } | ||||
|     USBD_CDC_SetTxBuffer(&hUsbDeviceFS, Buf, Len); | ||||
|     result = USBD_CDC_TransmitPacket(&hUsbDeviceFS); | ||||
|     /* USER CODE END 7 */ | ||||
|     return result; | ||||
| } | ||||
| 
 | ||||
| /* USER CODE BEGIN PRIVATE_FUNCTIONS_IMPLEMENTATION */ | ||||
|  | ||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @ -63,15 +63,15 @@ | ||||
|   * @{ | ||||
|   */ | ||||
| 
 | ||||
| #define USBD_VID     1155 | ||||
| #define USBD_LANGID_STRING     1033 | ||||
| #define USBD_MANUFACTURER_STRING     "STMicroelectronics" | ||||
| #define USBD_PID_FS     22336 | ||||
| #define USBD_PRODUCT_STRING_FS     "Flipper Zero Virtual ComPort" | ||||
| #define USBD_CONFIGURATION_STRING_FS     "CDC Config" | ||||
| #define USBD_INTERFACE_STRING_FS     "CDC Interface" | ||||
| #define USBD_VID 1155 | ||||
| #define USBD_LANGID_STRING 1033 | ||||
| #define USBD_MANUFACTURER_STRING "STMicroelectronics" | ||||
| #define USBD_PID_FS 22336 | ||||
| #define USBD_PRODUCT_STRING_FS "Flipper Zero Virtual ComPort" | ||||
| #define USBD_CONFIGURATION_STRING_FS "CDC Config" | ||||
| #define USBD_INTERFACE_STRING_FS "CDC Interface" | ||||
| 
 | ||||
| #define USB_SIZ_BOS_DESC            0x0C | ||||
| #define USB_SIZ_BOS_DESC 0x0C | ||||
| 
 | ||||
| /* USER CODE BEGIN PRIVATE_DEFINES */ | ||||
| 
 | ||||
| @ -104,27 +104,26 @@ | ||||
|   */ | ||||
| 
 | ||||
| static void Get_SerialNum(void); | ||||
| static void IntToUnicode(uint32_t value, uint8_t * pbuf, uint8_t len); | ||||
| static void IntToUnicode(uint32_t value, uint8_t* pbuf, uint8_t len); | ||||
| 
 | ||||
| /**
 | ||||
|   * @} | ||||
|   */ | ||||
| 
 | ||||
| 
 | ||||
| /** @defgroup USBD_DESC_Private_FunctionPrototypes USBD_DESC_Private_FunctionPrototypes
 | ||||
|   * @brief Private functions declaration for FS. | ||||
|   * @{ | ||||
|   */ | ||||
| 
 | ||||
| uint8_t * USBD_FS_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); | ||||
| uint8_t * USBD_FS_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); | ||||
| uint8_t * USBD_FS_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); | ||||
| uint8_t * USBD_FS_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); | ||||
| uint8_t * USBD_FS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); | ||||
| uint8_t * USBD_FS_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); | ||||
| uint8_t * USBD_FS_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); | ||||
| #if (USBD_LPM_ENABLED == 1) | ||||
| uint8_t * USBD_FS_USR_BOSDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); | ||||
| uint8_t* USBD_FS_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t* length); | ||||
| uint8_t* USBD_FS_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t* length); | ||||
| uint8_t* USBD_FS_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t* length); | ||||
| uint8_t* USBD_FS_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t* length); | ||||
| uint8_t* USBD_FS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t* length); | ||||
| uint8_t* USBD_FS_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t* length); | ||||
| uint8_t* USBD_FS_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t* length); | ||||
| #if(USBD_LPM_ENABLED == 1) | ||||
| uint8_t* USBD_FS_USR_BOSDescriptor(USBD_SpeedTypeDef speed, uint16_t* length); | ||||
| #endif /* (USBD_LPM_ENABLED == 1) */ | ||||
| 
 | ||||
| /**
 | ||||
| @ -136,74 +135,71 @@ uint8_t * USBD_FS_USR_BOSDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); | ||||
|   * @{ | ||||
|   */ | ||||
| 
 | ||||
| USBD_DescriptorsTypeDef FS_Desc = | ||||
| { | ||||
|   USBD_FS_DeviceDescriptor | ||||
| , USBD_FS_LangIDStrDescriptor | ||||
| , USBD_FS_ManufacturerStrDescriptor | ||||
| , USBD_FS_ProductStrDescriptor | ||||
| , USBD_FS_SerialStrDescriptor | ||||
| , USBD_FS_ConfigStrDescriptor | ||||
| , USBD_FS_InterfaceStrDescriptor | ||||
| #if (USBD_LPM_ENABLED == 1) | ||||
| , USBD_FS_USR_BOSDescriptor | ||||
| USBD_DescriptorsTypeDef FS_Desc = {USBD_FS_DeviceDescriptor, | ||||
|                                    USBD_FS_LangIDStrDescriptor, | ||||
|                                    USBD_FS_ManufacturerStrDescriptor, | ||||
|                                    USBD_FS_ProductStrDescriptor, | ||||
|                                    USBD_FS_SerialStrDescriptor, | ||||
|                                    USBD_FS_ConfigStrDescriptor, | ||||
|                                    USBD_FS_InterfaceStrDescriptor | ||||
| #if(USBD_LPM_ENABLED == 1) | ||||
|                                    , | ||||
|                                    USBD_FS_USR_BOSDescriptor | ||||
| #endif /* (USBD_LPM_ENABLED == 1) */ | ||||
| }; | ||||
| 
 | ||||
| #if defined ( __ICCARM__ ) /* IAR Compiler */ | ||||
|   #pragma data_alignment=4 | ||||
| #if defined(__ICCARM__) /* IAR Compiler */ | ||||
| #pragma data_alignment = 4 | ||||
| #endif /* defined ( __ICCARM__ ) */ | ||||
| /** USB standard device descriptor. */ | ||||
| __ALIGN_BEGIN uint8_t USBD_FS_DeviceDesc[USB_LEN_DEV_DESC] __ALIGN_END = | ||||
| { | ||||
|   0x12,                       /*bLength */ | ||||
|   USB_DESC_TYPE_DEVICE,       /*bDescriptorType*/ | ||||
| #if (USBD_LPM_ENABLED == 1) | ||||
|   0x01,                       /*bcdUSB */ /* changed to USB version 2.01
 | ||||
| __ALIGN_BEGIN uint8_t USBD_FS_DeviceDesc[USB_LEN_DEV_DESC] __ALIGN_END = { | ||||
|     0x12, /*bLength */ | ||||
|     USB_DESC_TYPE_DEVICE, /*bDescriptorType*/ | ||||
| #if(USBD_LPM_ENABLED == 1) | ||||
|     0x01, | ||||
| /*bcdUSB */ /* changed to USB version 2.01
 | ||||
|                                              in order to support LPM L1 suspend | ||||
|                                              resume test of USBCV3.0*/ | ||||
| #else | ||||
|   0x00,                       /*bcdUSB */ | ||||
|     0x00, /*bcdUSB */ | ||||
| #endif /* (USBD_LPM_ENABLED == 1) */ | ||||
|   0x02, | ||||
|   0x02,                       /*bDeviceClass*/ | ||||
|   0x02,                       /*bDeviceSubClass*/ | ||||
|   0x00,                       /*bDeviceProtocol*/ | ||||
|   USB_MAX_EP0_SIZE,           /*bMaxPacketSize*/ | ||||
|   LOBYTE(USBD_VID),           /*idVendor*/ | ||||
|   HIBYTE(USBD_VID),           /*idVendor*/ | ||||
|   LOBYTE(USBD_PID_FS),        /*idProduct*/ | ||||
|   HIBYTE(USBD_PID_FS),        /*idProduct*/ | ||||
|   0x00,                       /*bcdDevice rel. 2.00*/ | ||||
|   0x02, | ||||
|   USBD_IDX_MFC_STR,           /*Index of manufacturer  string*/ | ||||
|   USBD_IDX_PRODUCT_STR,       /*Index of product string*/ | ||||
|   USBD_IDX_SERIAL_STR,        /*Index of serial number string*/ | ||||
|   USBD_MAX_NUM_CONFIGURATION  /*bNumConfigurations*/ | ||||
|     0x02, | ||||
|     0x02, /*bDeviceClass*/ | ||||
|     0x02, /*bDeviceSubClass*/ | ||||
|     0x00, /*bDeviceProtocol*/ | ||||
|     USB_MAX_EP0_SIZE, /*bMaxPacketSize*/ | ||||
|     LOBYTE(USBD_VID), /*idVendor*/ | ||||
|     HIBYTE(USBD_VID), /*idVendor*/ | ||||
|     LOBYTE(USBD_PID_FS), /*idProduct*/ | ||||
|     HIBYTE(USBD_PID_FS), /*idProduct*/ | ||||
|     0x00, /*bcdDevice rel. 2.00*/ | ||||
|     0x02, | ||||
|     USBD_IDX_MFC_STR, /*Index of manufacturer  string*/ | ||||
|     USBD_IDX_PRODUCT_STR, /*Index of product string*/ | ||||
|     USBD_IDX_SERIAL_STR, /*Index of serial number string*/ | ||||
|     USBD_MAX_NUM_CONFIGURATION /*bNumConfigurations*/ | ||||
| }; | ||||
| 
 | ||||
| /* USB_DeviceDescriptor */ | ||||
| /** BOS descriptor. */ | ||||
| #if (USBD_LPM_ENABLED == 1) | ||||
| #if defined ( __ICCARM__ ) /* IAR Compiler */ | ||||
|   #pragma data_alignment=4 | ||||
| #if(USBD_LPM_ENABLED == 1) | ||||
| #if defined(__ICCARM__) /* IAR Compiler */ | ||||
| #pragma data_alignment = 4 | ||||
| #endif /* defined ( __ICCARM__ ) */ | ||||
| __ALIGN_BEGIN uint8_t USBD_FS_BOSDesc[USB_SIZ_BOS_DESC] __ALIGN_END = | ||||
| { | ||||
|   0x5, | ||||
|   USB_DESC_TYPE_BOS, | ||||
|   0xC, | ||||
|   0x0, | ||||
|   0x1,  /* 1 device capability*/ | ||||
|         /* device capability*/ | ||||
|   0x7, | ||||
|   USB_DEVICE_CAPABITY_TYPE, | ||||
|   0x2, | ||||
|   0x2,  /* LPM capability bit set*/ | ||||
|   0x0, | ||||
|   0x0, | ||||
|   0x0 | ||||
| }; | ||||
| __ALIGN_BEGIN uint8_t USBD_FS_BOSDesc[USB_SIZ_BOS_DESC] __ALIGN_END = { | ||||
|     0x5, | ||||
|     USB_DESC_TYPE_BOS, | ||||
|     0xC, | ||||
|     0x0, | ||||
|     0x1, /* 1 device capability*/ | ||||
|     /* device capability*/ | ||||
|     0x7, | ||||
|     USB_DEVICE_CAPABITY_TYPE, | ||||
|     0x2, | ||||
|     0x2, /* LPM capability bit set*/ | ||||
|     0x0, | ||||
|     0x0, | ||||
|     0x0}; | ||||
| #endif /* (USBD_LPM_ENABLED == 1) */ | ||||
| 
 | ||||
| /**
 | ||||
| @ -215,31 +211,29 @@ __ALIGN_BEGIN uint8_t USBD_FS_BOSDesc[USB_SIZ_BOS_DESC] __ALIGN_END = | ||||
|   * @{ | ||||
|   */ | ||||
| 
 | ||||
| #if defined ( __ICCARM__ ) /* IAR Compiler */ | ||||
|   #pragma data_alignment=4 | ||||
| #if defined(__ICCARM__) /* IAR Compiler */ | ||||
| #pragma data_alignment = 4 | ||||
| #endif /* defined ( __ICCARM__ ) */ | ||||
| 
 | ||||
| /** USB lang indentifier descriptor. */ | ||||
| __ALIGN_BEGIN uint8_t USBD_LangIDDesc[USB_LEN_LANGID_STR_DESC] __ALIGN_END = | ||||
| { | ||||
|      USB_LEN_LANGID_STR_DESC, | ||||
|      USB_DESC_TYPE_STRING, | ||||
|      LOBYTE(USBD_LANGID_STRING), | ||||
|      HIBYTE(USBD_LANGID_STRING) | ||||
| }; | ||||
| __ALIGN_BEGIN uint8_t USBD_LangIDDesc[USB_LEN_LANGID_STR_DESC] __ALIGN_END = { | ||||
|     USB_LEN_LANGID_STR_DESC, | ||||
|     USB_DESC_TYPE_STRING, | ||||
|     LOBYTE(USBD_LANGID_STRING), | ||||
|     HIBYTE(USBD_LANGID_STRING)}; | ||||
| 
 | ||||
| #if defined ( __ICCARM__ ) /* IAR Compiler */ | ||||
|   #pragma data_alignment=4 | ||||
| #if defined(__ICCARM__) /* IAR Compiler */ | ||||
| #pragma data_alignment = 4 | ||||
| #endif /* defined ( __ICCARM__ ) */ | ||||
| /* Internal string descriptor. */ | ||||
| __ALIGN_BEGIN uint8_t USBD_StrDesc[USBD_MAX_STR_DESC_SIZ] __ALIGN_END; | ||||
| 
 | ||||
| #if defined ( __ICCARM__ ) /*!< IAR Compiler */ | ||||
|   #pragma data_alignment=4    | ||||
| #if defined(__ICCARM__) /*!< IAR Compiler */ | ||||
| #pragma data_alignment = 4 | ||||
| #endif | ||||
| __ALIGN_BEGIN uint8_t USBD_StringSerial[USB_SIZ_STRING_SERIAL] __ALIGN_END = { | ||||
|   USB_SIZ_STRING_SERIAL, | ||||
|   USB_DESC_TYPE_STRING, | ||||
|     USB_SIZ_STRING_SERIAL, | ||||
|     USB_DESC_TYPE_STRING, | ||||
| }; | ||||
| 
 | ||||
| /**
 | ||||
| @ -257,11 +251,10 @@ __ALIGN_BEGIN uint8_t USBD_StringSerial[USB_SIZ_STRING_SERIAL] __ALIGN_END = { | ||||
|   * @param  length : Pointer to data length variable | ||||
|   * @retval Pointer to descriptor buffer | ||||
|   */ | ||||
| uint8_t * USBD_FS_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) | ||||
| { | ||||
|   UNUSED(speed); | ||||
|   *length = sizeof(USBD_FS_DeviceDesc); | ||||
|   return USBD_FS_DeviceDesc; | ||||
| uint8_t* USBD_FS_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t* length) { | ||||
|     UNUSED(speed); | ||||
|     *length = sizeof(USBD_FS_DeviceDesc); | ||||
|     return USBD_FS_DeviceDesc; | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -270,11 +263,10 @@ uint8_t * USBD_FS_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) | ||||
|   * @param  length : Pointer to data length variable | ||||
|   * @retval Pointer to descriptor buffer | ||||
|   */ | ||||
| uint8_t * USBD_FS_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) | ||||
| { | ||||
|   UNUSED(speed); | ||||
|   *length = sizeof(USBD_LangIDDesc); | ||||
|   return USBD_LangIDDesc; | ||||
| uint8_t* USBD_FS_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t* length) { | ||||
|     UNUSED(speed); | ||||
|     *length = sizeof(USBD_LangIDDesc); | ||||
|     return USBD_LangIDDesc; | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -283,17 +275,13 @@ uint8_t * USBD_FS_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) | ||||
|   * @param  length : Pointer to data length variable | ||||
|   * @retval Pointer to descriptor buffer | ||||
|   */ | ||||
| uint8_t * USBD_FS_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) | ||||
| { | ||||
|   if(speed == 0) | ||||
|   { | ||||
|     USBD_GetString((uint8_t *)USBD_PRODUCT_STRING_FS, USBD_StrDesc, length); | ||||
|   } | ||||
|   else | ||||
|   { | ||||
|     USBD_GetString((uint8_t *)USBD_PRODUCT_STRING_FS, USBD_StrDesc, length); | ||||
|   } | ||||
|   return USBD_StrDesc; | ||||
| uint8_t* USBD_FS_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t* length) { | ||||
|     if(speed == 0) { | ||||
|         USBD_GetString((uint8_t*)USBD_PRODUCT_STRING_FS, USBD_StrDesc, length); | ||||
|     } else { | ||||
|         USBD_GetString((uint8_t*)USBD_PRODUCT_STRING_FS, USBD_StrDesc, length); | ||||
|     } | ||||
|     return USBD_StrDesc; | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -302,11 +290,10 @@ uint8_t * USBD_FS_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length | ||||
|   * @param  length : Pointer to data length variable | ||||
|   * @retval Pointer to descriptor buffer | ||||
|   */ | ||||
| uint8_t * USBD_FS_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) | ||||
| { | ||||
|   UNUSED(speed); | ||||
|   USBD_GetString((uint8_t *)USBD_MANUFACTURER_STRING, USBD_StrDesc, length); | ||||
|   return USBD_StrDesc; | ||||
| uint8_t* USBD_FS_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t* length) { | ||||
|     UNUSED(speed); | ||||
|     USBD_GetString((uint8_t*)USBD_MANUFACTURER_STRING, USBD_StrDesc, length); | ||||
|     return USBD_StrDesc; | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -315,18 +302,17 @@ uint8_t * USBD_FS_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *l | ||||
|   * @param  length : Pointer to data length variable | ||||
|   * @retval Pointer to descriptor buffer | ||||
|   */ | ||||
| uint8_t * USBD_FS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) | ||||
| { | ||||
|   UNUSED(speed); | ||||
|   *length = USB_SIZ_STRING_SERIAL; | ||||
| uint8_t* USBD_FS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t* length) { | ||||
|     UNUSED(speed); | ||||
|     *length = USB_SIZ_STRING_SERIAL; | ||||
| 
 | ||||
|   /* Update the serial number string descriptor with the data from the unique
 | ||||
|     /* Update the serial number string descriptor with the data from the unique
 | ||||
|    * ID */ | ||||
|   Get_SerialNum(); | ||||
|   /* USER CODE BEGIN USBD_FS_SerialStrDescriptor */ | ||||
|     Get_SerialNum(); | ||||
|     /* USER CODE BEGIN USBD_FS_SerialStrDescriptor */ | ||||
| 
 | ||||
|   /* USER CODE END USBD_FS_SerialStrDescriptor */ | ||||
|   return (uint8_t *) USBD_StringSerial; | ||||
|     /* USER CODE END USBD_FS_SerialStrDescriptor */ | ||||
|     return (uint8_t*)USBD_StringSerial; | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -335,17 +321,13 @@ uint8_t * USBD_FS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) | ||||
|   * @param  length : Pointer to data length variable | ||||
|   * @retval Pointer to descriptor buffer | ||||
|   */ | ||||
| uint8_t * USBD_FS_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) | ||||
| { | ||||
|   if(speed == USBD_SPEED_HIGH) | ||||
|   { | ||||
|     USBD_GetString((uint8_t *)USBD_CONFIGURATION_STRING_FS, USBD_StrDesc, length); | ||||
|   } | ||||
|   else | ||||
|   { | ||||
|     USBD_GetString((uint8_t *)USBD_CONFIGURATION_STRING_FS, USBD_StrDesc, length); | ||||
|   } | ||||
|   return USBD_StrDesc; | ||||
| uint8_t* USBD_FS_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t* length) { | ||||
|     if(speed == USBD_SPEED_HIGH) { | ||||
|         USBD_GetString((uint8_t*)USBD_CONFIGURATION_STRING_FS, USBD_StrDesc, length); | ||||
|     } else { | ||||
|         USBD_GetString((uint8_t*)USBD_CONFIGURATION_STRING_FS, USBD_StrDesc, length); | ||||
|     } | ||||
|     return USBD_StrDesc; | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -354,31 +336,26 @@ uint8_t * USBD_FS_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) | ||||
|   * @param  length : Pointer to data length variable | ||||
|   * @retval Pointer to descriptor buffer | ||||
|   */ | ||||
| uint8_t * USBD_FS_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) | ||||
| { | ||||
|   if(speed == 0) | ||||
|   { | ||||
|     USBD_GetString((uint8_t *)USBD_INTERFACE_STRING_FS, USBD_StrDesc, length); | ||||
|   } | ||||
|   else | ||||
|   { | ||||
|     USBD_GetString((uint8_t *)USBD_INTERFACE_STRING_FS, USBD_StrDesc, length); | ||||
|   } | ||||
|   return USBD_StrDesc; | ||||
| uint8_t* USBD_FS_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t* length) { | ||||
|     if(speed == 0) { | ||||
|         USBD_GetString((uint8_t*)USBD_INTERFACE_STRING_FS, USBD_StrDesc, length); | ||||
|     } else { | ||||
|         USBD_GetString((uint8_t*)USBD_INTERFACE_STRING_FS, USBD_StrDesc, length); | ||||
|     } | ||||
|     return USBD_StrDesc; | ||||
| } | ||||
| 
 | ||||
| #if (USBD_LPM_ENABLED == 1) | ||||
| #if(USBD_LPM_ENABLED == 1) | ||||
| /**
 | ||||
|   * @brief  Return the BOS descriptor | ||||
|   * @param  speed : Current device speed | ||||
|   * @param  length : Pointer to data length variable | ||||
|   * @retval Pointer to descriptor buffer | ||||
|   */ | ||||
| uint8_t * USBD_FS_USR_BOSDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) | ||||
| { | ||||
|   UNUSED(speed); | ||||
|   *length = sizeof(USBD_FS_BOSDesc); | ||||
|   return (uint8_t*)USBD_FS_BOSDesc; | ||||
| uint8_t* USBD_FS_USR_BOSDescriptor(USBD_SpeedTypeDef speed, uint16_t* length) { | ||||
|     UNUSED(speed); | ||||
|     *length = sizeof(USBD_FS_BOSDesc); | ||||
|     return (uint8_t*)USBD_FS_BOSDesc; | ||||
| } | ||||
| #endif /* (USBD_LPM_ENABLED == 1) */ | ||||
| 
 | ||||
| @ -387,21 +364,19 @@ uint8_t * USBD_FS_USR_BOSDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) | ||||
|   * @param  None  | ||||
|   * @retval None | ||||
|   */ | ||||
| static void Get_SerialNum(void) | ||||
| { | ||||
|   uint32_t deviceserial0, deviceserial1, deviceserial2; | ||||
| static void Get_SerialNum(void) { | ||||
|     uint32_t deviceserial0, deviceserial1, deviceserial2; | ||||
| 
 | ||||
|   deviceserial0 = *(uint32_t *) DEVICE_ID1; | ||||
|   deviceserial1 = *(uint32_t *) DEVICE_ID2; | ||||
|   deviceserial2 = *(uint32_t *) DEVICE_ID3; | ||||
|     deviceserial0 = *(uint32_t*)DEVICE_ID1; | ||||
|     deviceserial1 = *(uint32_t*)DEVICE_ID2; | ||||
|     deviceserial2 = *(uint32_t*)DEVICE_ID3; | ||||
| 
 | ||||
|   deviceserial0 += deviceserial2; | ||||
|     deviceserial0 += deviceserial2; | ||||
| 
 | ||||
|   if (deviceserial0 != 0) | ||||
|   { | ||||
|     IntToUnicode(deviceserial0, &USBD_StringSerial[2], 8); | ||||
|     IntToUnicode(deviceserial1, &USBD_StringSerial[18], 4); | ||||
|   } | ||||
|     if(deviceserial0 != 0) { | ||||
|         IntToUnicode(deviceserial0, &USBD_StringSerial[2], 8); | ||||
|         IntToUnicode(deviceserial1, &USBD_StringSerial[18], 4); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -411,25 +386,20 @@ static void Get_SerialNum(void) | ||||
|   * @param  len: buffer length | ||||
|   * @retval None | ||||
|   */ | ||||
| static void IntToUnicode(uint32_t value, uint8_t * pbuf, uint8_t len) | ||||
| { | ||||
|   uint8_t idx = 0; | ||||
| static void IntToUnicode(uint32_t value, uint8_t* pbuf, uint8_t len) { | ||||
|     uint8_t idx = 0; | ||||
| 
 | ||||
|   for (idx = 0; idx < len; idx++) | ||||
|   { | ||||
|     if (((value >> 28)) < 0xA) | ||||
|     { | ||||
|       pbuf[2 * idx] = (value >> 28) + '0'; | ||||
|     for(idx = 0; idx < len; idx++) { | ||||
|         if(((value >> 28)) < 0xA) { | ||||
|             pbuf[2 * idx] = (value >> 28) + '0'; | ||||
|         } else { | ||||
|             pbuf[2 * idx] = (value >> 28) + 'A' - 10; | ||||
|         } | ||||
| 
 | ||||
|         value = value << 4; | ||||
| 
 | ||||
|         pbuf[2 * idx + 1] = 0; | ||||
|     } | ||||
|     else | ||||
|     { | ||||
|       pbuf[2 * idx] = (value >> 28) + 'A' - 10; | ||||
|     } | ||||
| 
 | ||||
|     value = value << 4; | ||||
| 
 | ||||
|     pbuf[2 * idx + 1] = 0; | ||||
|   } | ||||
| } | ||||
| /**
 | ||||
|   * @} | ||||
|  | ||||
| @ -6,13 +6,12 @@ | ||||
| void osDelay(uint32_t ms); | ||||
| 
 | ||||
| // some FreeRTOS types
 | ||||
| typedef void(*TaskFunction_t)(void*); | ||||
| typedef void (*TaskFunction_t)(void*); | ||||
| typedef size_t UBaseType_t; | ||||
| typedef uint32_t StackType_t; | ||||
| typedef uint32_t StaticTask_t; | ||||
| typedef pthread_t* TaskHandle_t; | ||||
| 
 | ||||
| 
 | ||||
| typedef enum { | ||||
|     SemaphoreTypeMutex, | ||||
|     SemaphoreTypeCounting, | ||||
| @ -30,48 +29,37 @@ typedef StaticQueue_t* QueueHandle_t; | ||||
| 
 | ||||
| #define portMAX_DELAY -1 | ||||
| 
 | ||||
| typedef enum { | ||||
|     pdTRUE = 1, | ||||
|     pdFALSE = 0 | ||||
| } BaseType_t; | ||||
| typedef enum { pdTRUE = 1, pdFALSE = 0 } BaseType_t; | ||||
| 
 | ||||
| typedef int32_t TickType_t; | ||||
| 
 | ||||
| #define tskIDLE_PRIORITY 0 | ||||
| 
 | ||||
| TaskHandle_t xTaskCreateStatic( | ||||
|     TaskFunction_t pxTaskCode, | ||||
|     const char * const pcName, | ||||
|     const uint32_t ulStackDepth, | ||||
|     void * const pvParameters, | ||||
|     UBaseType_t uxPriority, | ||||
|     StackType_t * const puxStackBuffer, | ||||
|     StaticTask_t * const pxTaskBuffer | ||||
| ); | ||||
| TaskHandle_t xTaskCreateStatic(TaskFunction_t pxTaskCode, | ||||
|                                const char* const pcName, | ||||
|                                const uint32_t ulStackDepth, | ||||
|                                void* const pvParameters, | ||||
|                                UBaseType_t uxPriority, | ||||
|                                StackType_t* const puxStackBuffer, | ||||
|                                StaticTask_t* const pxTaskBuffer); | ||||
| 
 | ||||
| void vTaskDelete(TaskHandle_t xTask); | ||||
| TaskHandle_t xTaskGetCurrentTaskHandle(void); | ||||
| SemaphoreHandle_t xSemaphoreCreateMutexStatic(StaticSemaphore_t* pxMutexBuffer); | ||||
| bool task_equal(TaskHandle_t a, TaskHandle_t b); | ||||
| 
 | ||||
| QueueHandle_t xQueueCreateStatic( | ||||
|     UBaseType_t uxQueueLength, | ||||
|     UBaseType_t uxItemSize, | ||||
|     uint8_t* pucQueueStorageBuffer, | ||||
|     StaticQueue_t* pxQueueBuffer | ||||
| ); | ||||
| QueueHandle_t xQueueCreateStatic(UBaseType_t uxQueueLength, | ||||
|                                  UBaseType_t uxItemSize, | ||||
|                                  uint8_t* pucQueueStorageBuffer, | ||||
|                                  StaticQueue_t* pxQueueBuffer); | ||||
| 
 | ||||
| SemaphoreHandle_t xSemaphoreCreateCountingStatic( | ||||
|     UBaseType_t uxMaxCount, | ||||
|     UBaseType_t uxInitialCount, | ||||
|     StaticSemaphore_t *pxSemaphoreBuffer | ||||
| ); | ||||
| SemaphoreHandle_t xSemaphoreCreateCountingStatic(UBaseType_t uxMaxCount, | ||||
|                                                  UBaseType_t uxInitialCount, | ||||
|                                                  StaticSemaphore_t* pxSemaphoreBuffer); | ||||
| BaseType_t xSemaphoreTake(SemaphoreHandle_t xSemaphore, TickType_t xTicksToWait); | ||||
| BaseType_t xSemaphoreGive(SemaphoreHandle_t xSemaphore); | ||||
| 
 | ||||
| BaseType_t xQueueSend( | ||||
|     QueueHandle_t xQueue, const void * pvItemToQueue, TickType_t xTicksToWait | ||||
| ); | ||||
| BaseType_t xQueueSend(QueueHandle_t xQueue, const void* pvItemToQueue, TickType_t xTicksToWait); | ||||
| 
 | ||||
| BaseType_t xQueueReceive(QueueHandle_t xQueue, void *pvBuffer, TickType_t xTicksToWait); | ||||
| 
 | ||||
|  | ||||
| @ -10,11 +10,7 @@ GPIO and HAL implementations | ||||
| #include <stdbool.h> | ||||
| #include "main.h" | ||||
| 
 | ||||
| typedef enum { | ||||
|     GpioModeInput, | ||||
|     GpioModeOutput, | ||||
|     GpioModeOpenDrain | ||||
| } GpioMode; | ||||
| typedef enum { GpioModeInput, GpioModeOutput, GpioModeOpenDrain } GpioMode; | ||||
| 
 | ||||
| typedef struct { | ||||
|     const char* port; | ||||
| @ -42,10 +38,7 @@ inline bool app_gpio_read(GpioPin gpio) { | ||||
|     return false; | ||||
| } | ||||
| 
 | ||||
| typedef enum { | ||||
|     GPIO_PIN_SET = 1, | ||||
|     GPIO_PIN_RESET = 0 | ||||
| } HAL_GPIO_PIN_STATE; | ||||
| typedef enum { GPIO_PIN_SET = 1, GPIO_PIN_RESET = 0 } HAL_GPIO_PIN_STATE; | ||||
| 
 | ||||
| void HAL_GPIO_WritePin(const char* port, uint32_t pin, HAL_GPIO_PIN_STATE state); | ||||
| 
 | ||||
| @ -106,4 +99,5 @@ typedef const char* SPI_HandleTypeDef; | ||||
| 
 | ||||
| typedef uint32_t HAL_StatusTypeDef; | ||||
| 
 | ||||
| HAL_StatusTypeDef HAL_SPI_Transmit(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size, uint32_t Timeout); | ||||
| HAL_StatusTypeDef | ||||
| HAL_SPI_Transmit(SPI_HandleTypeDef* hspi, uint8_t* pData, uint16_t Size, uint32_t Timeout); | ||||
| @ -5,12 +5,8 @@ | ||||
| #define HAL_MAX_DELAY INT_MAX | ||||
| 
 | ||||
| typedef uint32_t UART_HandleTypeDef; | ||||
| uint16_t HAL_UART_Transmit( | ||||
|     UART_HandleTypeDef* handle, | ||||
|     uint8_t* bufer, | ||||
|     uint16_t size, | ||||
|     uint32_t wait_ms | ||||
| ); | ||||
| uint16_t | ||||
| HAL_UART_Transmit(UART_HandleTypeDef* handle, uint8_t* bufer, uint16_t size, uint32_t wait_ms); | ||||
| 
 | ||||
| typedef uint32_t TIM_HandleTypeDef; | ||||
| 
 | ||||
|  | ||||
| @ -10,18 +10,17 @@ GPIO and HAL implementations | ||||
| 
 | ||||
| void app_gpio_init(GpioPin gpio, GpioMode mode) { | ||||
|     if(gpio.pin != 0) { | ||||
| 
 | ||||
|         switch(mode) { | ||||
|             case GpioModeInput: | ||||
|                 printf("[GPIO] %s%d input\n", gpio.port, gpio.pin); | ||||
|         case GpioModeInput: | ||||
|             printf("[GPIO] %s%d input\n", gpio.port, gpio.pin); | ||||
|             break; | ||||
| 
 | ||||
|             case GpioModeOutput:  | ||||
|                 printf("[GPIO] %s%d push pull\n", gpio.port, gpio.pin); | ||||
|         case GpioModeOutput: | ||||
|             printf("[GPIO] %s%d push pull\n", gpio.port, gpio.pin); | ||||
|             break; | ||||
| 
 | ||||
|             case GpioModeOpenDrain: | ||||
|                 printf("[GPIO] %s%d open drain\n", gpio.port, gpio.pin); | ||||
|         case GpioModeOpenDrain: | ||||
|             printf("[GPIO] %s%d open drain\n", gpio.port, gpio.pin); | ||||
|             break; | ||||
|         } | ||||
| 
 | ||||
| @ -44,7 +43,8 @@ void HAL_GPIO_WritePin(const char* port, uint32_t pin, HAL_GPIO_PIN_STATE state) | ||||
|     printf("[GPIO] set pin %s:%d = %d\n", port, pin, state); | ||||
| } | ||||
| 
 | ||||
| HAL_StatusTypeDef HAL_SPI_Transmit(SPI_HandleTypeDef* hspi, uint8_t *pData, uint16_t size, uint32_t Timeout) { | ||||
| HAL_StatusTypeDef | ||||
| HAL_SPI_Transmit(SPI_HandleTypeDef* hspi, uint8_t* pData, uint16_t size, uint32_t Timeout) { | ||||
|     printf("[SPI] write %d to %s: ", size, *hspi); | ||||
|     for(size_t i = 0; i < size; i++) { | ||||
|         printf("%02X ", pData[i]); | ||||
|  | ||||
| @ -10,12 +10,8 @@ Dummy hal for local fw build | ||||
| 
 | ||||
| UART_HandleTypeDef DEBUG_UART = 0; | ||||
| 
 | ||||
| uint16_t HAL_UART_Transmit( | ||||
|     UART_HandleTypeDef* handle, | ||||
|     uint8_t* bufer, | ||||
|     uint16_t size, | ||||
|     uint32_t wait_ms | ||||
| ) { | ||||
| uint16_t | ||||
| HAL_UART_Transmit(UART_HandleTypeDef* handle, uint8_t* bufer, uint16_t size, uint32_t wait_ms) { | ||||
|     uint16_t res = write(1, (const char*)bufer, size); | ||||
|     return res; | ||||
| } | ||||
| @ -16,7 +16,7 @@ void osDelay(uint32_t ms) { | ||||
| // temporary struct to pass function ptr and param to wrapper
 | ||||
| typedef struct { | ||||
|     TaskFunction_t func; | ||||
|     void * param; | ||||
|     void* param; | ||||
| } PthreadTask; | ||||
| 
 | ||||
| void* pthread_wrapper(void* p) { | ||||
| @ -30,15 +30,13 @@ void* pthread_wrapper(void* p) { | ||||
|     return NULL; | ||||
| } | ||||
| 
 | ||||
| TaskHandle_t xTaskCreateStatic( | ||||
|     TaskFunction_t pxTaskCode, | ||||
|     const char * const pcName, | ||||
|     const uint32_t ulStackDepth, | ||||
|     void * const pvParameters, | ||||
|     UBaseType_t uxPriority, | ||||
|     StackType_t * const puxStackBuffer, | ||||
|     StaticTask_t * const pxTaskBuffer | ||||
| ) { | ||||
| TaskHandle_t xTaskCreateStatic(TaskFunction_t pxTaskCode, | ||||
|                                const char* const pcName, | ||||
|                                const uint32_t ulStackDepth, | ||||
|                                void* const pvParameters, | ||||
|                                UBaseType_t uxPriority, | ||||
|                                StackType_t* const puxStackBuffer, | ||||
|                                StaticTask_t* const pxTaskBuffer) { | ||||
|     TaskHandle_t thread = malloc(sizeof(TaskHandle_t)); | ||||
|     PthreadTask* task = malloc(sizeof(PthreadTask)); | ||||
| 
 | ||||
| @ -51,14 +49,13 @@ TaskHandle_t xTaskCreateStatic( | ||||
| } | ||||
| 
 | ||||
| void vTaskDelete(TaskHandle_t xTask) { | ||||
| 
 | ||||
|     if(xTask == NULL) { | ||||
|         // kill itself
 | ||||
|         pthread_exit(NULL); | ||||
|     } | ||||
| 
 | ||||
|     // maybe thread already join
 | ||||
|     if (pthread_kill(*xTask, 0) == ESRCH) return; | ||||
|     if(pthread_kill(*xTask, 0) == ESRCH) return; | ||||
| 
 | ||||
|     // send thread_child signal to stop it сигнал, который ее завершает
 | ||||
|     pthread_cancel(*xTask); | ||||
| @ -82,16 +79,12 @@ bool task_equal(TaskHandle_t a, TaskHandle_t b) { | ||||
|     return pthread_equal(*a, *b) != 0; | ||||
| } | ||||
| 
 | ||||
| BaseType_t xQueueSend( | ||||
|     QueueHandle_t xQueue, const void * pvItemToQueue, TickType_t xTicksToWait | ||||
| ) { | ||||
| BaseType_t xQueueSend(QueueHandle_t xQueue, const void* pvItemToQueue, TickType_t xTicksToWait) { | ||||
|     // TODO: add implementation
 | ||||
|     return pdTRUE; | ||||
| } | ||||
| 
 | ||||
| BaseType_t xQueueReceive( | ||||
|     QueueHandle_t xQueue, void *pvBuffer, TickType_t xTicksToWait | ||||
| ) { | ||||
| BaseType_t xQueueReceive(QueueHandle_t xQueue, void* pvBuffer, TickType_t xTicksToWait) { | ||||
|     // TODO: add implementation
 | ||||
|     osDelay(100); | ||||
| 
 | ||||
| @ -100,12 +93,10 @@ BaseType_t xQueueReceive( | ||||
| 
 | ||||
| static uint32_t queue_global_id = 0; | ||||
| 
 | ||||
| QueueHandle_t xQueueCreateStatic( | ||||
|     UBaseType_t uxQueueLength, | ||||
|     UBaseType_t uxItemSize, | ||||
|     uint8_t* pucQueueStorageBuffer, | ||||
|     StaticQueue_t *pxQueueBuffer | ||||
| ) { | ||||
| QueueHandle_t xQueueCreateStatic(UBaseType_t uxQueueLength, | ||||
|                                  UBaseType_t uxItemSize, | ||||
|                                  uint8_t* pucQueueStorageBuffer, | ||||
|                                  StaticQueue_t* pxQueueBuffer) { | ||||
|     // TODO: check this implementation
 | ||||
|     int* msgid = malloc(sizeof(int)); | ||||
| 
 | ||||
| @ -117,11 +108,9 @@ QueueHandle_t xQueueCreateStatic( | ||||
|     return (QueueHandle_t)msgid; | ||||
| } | ||||
| 
 | ||||
| SemaphoreHandle_t xSemaphoreCreateCountingStatic( | ||||
|     UBaseType_t uxMaxCount, | ||||
|     UBaseType_t uxInitialCount, | ||||
|     StaticSemaphore_t* pxSemaphoreBuffer | ||||
| ) { | ||||
| SemaphoreHandle_t xSemaphoreCreateCountingStatic(UBaseType_t uxMaxCount, | ||||
|                                                  UBaseType_t uxInitialCount, | ||||
|                                                  StaticSemaphore_t* pxSemaphoreBuffer) { | ||||
|     pxSemaphoreBuffer->type = SemaphoreTypeCounting; | ||||
|     pxSemaphoreBuffer->take_counter = 0; | ||||
|     pxSemaphoreBuffer->give_counter = 0; | ||||
| @ -136,24 +125,23 @@ SemaphoreHandle_t xSemaphoreCreateMutexStatic(StaticSemaphore_t* pxMutexBuffer) | ||||
|     return pxMutexBuffer; | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| BaseType_t xSemaphoreTake(volatile SemaphoreHandle_t xSemaphore, TickType_t xTicksToWait) { | ||||
|     if(xSemaphore == NULL) return pdFALSE; | ||||
| 
 | ||||
|     if (xSemaphore->type == SemaphoreTypeMutex) { | ||||
|         if (xTicksToWait == portMAX_DELAY) { | ||||
|             if (pthread_mutex_lock(&xSemaphore->mutex) == 0) { | ||||
|     if(xSemaphore->type == SemaphoreTypeMutex) { | ||||
|         if(xTicksToWait == portMAX_DELAY) { | ||||
|             if(pthread_mutex_lock(&xSemaphore->mutex) == 0) { | ||||
|                 return pdTRUE; | ||||
|             } else { | ||||
|                 return pdFALSE; | ||||
|             } | ||||
|         } else { | ||||
|             TickType_t ticks = xTicksToWait; | ||||
|             while (ticks >= 0) { | ||||
|                 if (pthread_mutex_trylock(&xSemaphore->mutex) == 0) { | ||||
|             while(ticks >= 0) { | ||||
|                 if(pthread_mutex_trylock(&xSemaphore->mutex) == 0) { | ||||
|                     return pdTRUE; | ||||
|                 } | ||||
|                 if (ticks > 0) { | ||||
|                 if(ticks > 0) { | ||||
|                     osDelay(1); | ||||
|                 } | ||||
|                 ticks--; | ||||
| @ -167,10 +155,8 @@ BaseType_t xSemaphoreTake(volatile SemaphoreHandle_t xSemaphore, TickType_t xTic | ||||
| 
 | ||||
|     TickType_t ticks = xTicksToWait; | ||||
| 
 | ||||
|     while( | ||||
|         xSemaphore->take_counter != xSemaphore->give_counter | ||||
|         && (ticks > 0 || xTicksToWait == portMAX_DELAY) | ||||
|     ) { | ||||
|     while(xSemaphore->take_counter != xSemaphore->give_counter && | ||||
|           (ticks > 0 || xTicksToWait == portMAX_DELAY)) { | ||||
|         osDelay(1); | ||||
|         ticks--; | ||||
|     } | ||||
| @ -183,8 +169,8 @@ BaseType_t xSemaphoreTake(volatile SemaphoreHandle_t xSemaphore, TickType_t xTic | ||||
| BaseType_t xSemaphoreGive(SemaphoreHandle_t xSemaphore) { | ||||
|     if(xSemaphore == NULL) return pdFALSE; | ||||
| 
 | ||||
|     if (xSemaphore->type == SemaphoreTypeMutex) { | ||||
|         if (pthread_mutex_unlock(&xSemaphore->mutex) == 0) { | ||||
|     if(xSemaphore->type == SemaphoreTypeMutex) { | ||||
|         if(pthread_mutex_unlock(&xSemaphore->mutex) == 0) { | ||||
|             return pdTRUE; | ||||
|         } else { | ||||
|             return pdFALSE; | ||||
| @ -202,20 +188,18 @@ static pthread_key_t tls_keys[TLS_ITEM_COUNT]; | ||||
| static pthread_once_t tls_keys_once = PTHREAD_ONCE_INIT; | ||||
| 
 | ||||
| static void create_tls_keys() { | ||||
|     for (size_t i = 0; i < TLS_ITEM_COUNT; i++) { | ||||
|     for(size_t i = 0; i < TLS_ITEM_COUNT; i++) { | ||||
|         pthread_key_create(&tls_keys[i], NULL); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void* pvTaskGetThreadLocalStoragePointer( | ||||
|     TaskHandle_t xTaskToQuery, BaseType_t xIndex | ||||
| ) { | ||||
| void* pvTaskGetThreadLocalStoragePointer(TaskHandle_t xTaskToQuery, BaseType_t xIndex) { | ||||
|     // Non-current task TLS access is not allowed
 | ||||
|     if (xTaskToQuery != NULL) { | ||||
|     if(xTaskToQuery != NULL) { | ||||
|         return NULL; | ||||
|     } | ||||
| 
 | ||||
|     if (xIndex >= TLS_ITEM_COUNT) { | ||||
|     if(xIndex >= TLS_ITEM_COUNT) { | ||||
|         return NULL; | ||||
|     } | ||||
| 
 | ||||
| @ -224,15 +208,13 @@ void* pvTaskGetThreadLocalStoragePointer( | ||||
|     return pthread_getspecific(tls_keys[xIndex]); | ||||
| } | ||||
| 
 | ||||
| void vTaskSetThreadLocalStoragePointer( | ||||
|     TaskHandle_t xTaskToSet, BaseType_t xIndex, void *pvValue | ||||
| ) { | ||||
| void vTaskSetThreadLocalStoragePointer(TaskHandle_t xTaskToSet, BaseType_t xIndex, void* pvValue) { | ||||
|     // Non-current task TLS access is not allowed
 | ||||
|     if (xTaskToSet != NULL) { | ||||
|     if(xTaskToSet != NULL) { | ||||
|         return; | ||||
|     } | ||||
| 
 | ||||
|     if (xIndex >= TLS_ITEM_COUNT) { | ||||
|     if(xIndex >= TLS_ITEM_COUNT) { | ||||
|         return; | ||||
|     } | ||||
| 
 | ||||
|  | ||||
| @ -88,6 +88,12 @@ If you want to add some features or suggest some changes, do following steps: | ||||
| 	* Your code is merged in master branch | ||||
| 5. If you can do only part of work, create PR with `WIP` label. Describe what you have already done and what remains to be done and other people can help you. | ||||
| 
 | ||||
| ## Coding Style | ||||
| 
 | ||||
| Flipper Zero source code is formatted using clang-format for C code and rustfmt for rust. We use the [Kernel Code Style](https://www.kernel.org/doc/html/latest/process/coding-style.html) with minor changes, you can see the rules in .clang-format file. The Github CI tests will automatically check the code format and fail if the format is incorrect. | ||||
| 
 | ||||
| Also, you can check and fix format with syntax_check.sh script. | ||||
| 
 | ||||
| ## Pull requests | ||||
| 
 | ||||
| 1. Don't forget reference issues or other PR | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Nikita Beletskii
						Nikita Beletskii