[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,7 +7,8 @@ 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: | ||||
| @ -31,18 +32,19 @@ static uint8_t u8g2_gpio_and_delay_stm32(u8x8_t *u8x8, uint8_t msg, uint8_t arg_ | ||||
| 
 | ||||
|     // Function to define the logic level of the RESET line
 | ||||
|     case U8X8_MSG_GPIO_RESET: | ||||
|             #ifdef DEBUG | ||||
| #ifdef DEBUG | ||||
|         fuprintf(log, "[u8g2] rst %d\n", arg_int); | ||||
|             #endif | ||||
| #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); | ||||
|         HAL_GPIO_WritePin( | ||||
|             DISPLAY_RST_GPIO_Port, DISPLAY_RST_Pin, arg_int ? GPIO_PIN_SET : GPIO_PIN_RESET); | ||||
|         break; | ||||
| 
 | ||||
|     default: | ||||
|             #ifdef DEBUG | ||||
| #ifdef DEBUG | ||||
|         fufuprintf(log, "[u8g2] unknown io %d\n", msg); | ||||
|             #endif | ||||
| #endif | ||||
| 
 | ||||
|         return 0; //A message was received which is not implemented, return 0 to indicate an error
 | ||||
|     } | ||||
| @ -50,39 +52,40 @@ static uint8_t u8g2_gpio_and_delay_stm32(u8x8_t *u8x8, uint8_t msg, uint8_t arg_ | ||||
|     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) { | ||||
| 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 | ||||
| #ifdef DEBUG | ||||
|         fuprintf(log, "[u8g2] send %d bytes %02X\n", arg_int, ((uint8_t*)arg_ptr)[0]); | ||||
|             #endif | ||||
| #endif | ||||
| 
 | ||||
|         // TODO change it to FuriRecord SPI
 | ||||
|             HAL_SPI_Transmit(&hspi1, (uint8_t *)arg_ptr, arg_int, 10000); | ||||
|         HAL_SPI_Transmit(&hspi1, (uint8_t*)arg_ptr, arg_int, 10000); | ||||
|         break; | ||||
| 
 | ||||
|     case U8X8_MSG_BYTE_SET_DC: | ||||
|             #ifdef DEBUG | ||||
| #ifdef DEBUG | ||||
|         fuprintf(log, "[u8g2] dc %d\n", arg_int); | ||||
|             #endif | ||||
| #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); | ||||
|         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 | ||||
| #ifdef DEBUG | ||||
|         fuprintf(log, "[u8g2] init\n"); | ||||
|             #endif | ||||
| #endif | ||||
| 
 | ||||
|         // 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 | ||||
| #ifdef DEBUG | ||||
|         fuprintf(log, "[u8g2] start\n"); | ||||
|             #endif | ||||
| #endif | ||||
| 
 | ||||
|         // TODO change it to FuriRecord pin
 | ||||
|         HAL_GPIO_WritePin(DISPLAY_CS_GPIO_Port, DISPLAY_CS_Pin, GPIO_PIN_RESET); | ||||
| @ -90,9 +93,9 @@ static uint8_t u8x8_hw_spi_stm32(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, voi | ||||
|         break; | ||||
| 
 | ||||
|     case U8X8_MSG_BYTE_END_TRANSFER: | ||||
|             #ifdef DEBUG | ||||
| #ifdef DEBUG | ||||
|         fuprintf(log, "[u8g2] end\n"); | ||||
|             #endif | ||||
| #endif | ||||
| 
 | ||||
|         asm("nop"); | ||||
|         // TODO change it to FuriRecord pin
 | ||||
| @ -100,9 +103,9 @@ static uint8_t u8x8_hw_spi_stm32(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, voi | ||||
|         break; | ||||
| 
 | ||||
|     default: | ||||
|             #ifdef DEBUG | ||||
| #ifdef DEBUG | ||||
|         fuprintf(log, "[u8g2] unknown xfer %d\n", msg); | ||||
|             #endif | ||||
| #endif | ||||
| 
 | ||||
|         return 0; | ||||
|     } | ||||
| @ -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 | ||||
| } | ||||
|  | ||||
							
								
								
									
										90
									
								
								core/furi.c
									
									
									
									
									
								
							
							
						
						
									
										90
									
								
								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 | ||||
| #ifdef FURI_DEBUG | ||||
|     printf("[FURI] creating %s record\n", name); | ||||
|     #endif | ||||
| #endif | ||||
| 
 | ||||
|     FuriRecord* record = find_record(name); | ||||
| 
 | ||||
|     if(record != NULL) { | ||||
|         #ifdef FURI_DEBUG | ||||
| #ifdef FURI_DEBUG | ||||
|         printf("[FURI] record already exist\n"); | ||||
|         #endif | ||||
| #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 | ||||
| // max record count exceed
 | ||||
| #ifdef FURI_DEBUG | ||||
|         printf("[FURI] create: max record count exceed\n"); | ||||
|         #endif | ||||
| #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, | ||||
| FuriRecordSubscriber* furi_open(const char* name, | ||||
|                                 bool solo, | ||||
|                                 bool no_mute, | ||||
|                                 FlipperRecordCallback value_callback, | ||||
|                                 FlipperRecordStateCallback state_callback, | ||||
|     void* ctx | ||||
| ) { | ||||
|     #ifdef FURI_DEBUG | ||||
|                                 void* ctx) { | ||||
| #ifdef FURI_DEBUG | ||||
|     printf("[FURI] opening %s record\n", name); | ||||
|     #endif | ||||
| #endif | ||||
| 
 | ||||
|     // get furi record by name
 | ||||
|     FuriRecord* record = find_record(name); | ||||
| 
 | ||||
|     if(record == NULL) { | ||||
|         // cannot find record
 | ||||
|         #ifdef FURI_DEBUG | ||||
| // cannot find record
 | ||||
| #ifdef FURI_DEBUG | ||||
|         printf("[FURI] cannot find record %s\n", name); | ||||
|         #endif | ||||
| #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 | ||||
| // cannot add subscriber (full)
 | ||||
| #ifdef FURI_DEBUG | ||||
|         printf("[FURI] open: cannot add subscriber (full)\n"); | ||||
|         #endif | ||||
| #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 | ||||
| #ifdef FURI_DEBUG | ||||
|         printf("[FURI] open: no current task\n"); | ||||
|         #endif | ||||
| #endif | ||||
|     } | ||||
| 
 | ||||
|     return subscriber; | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| void furi_close(FuriRecordSubscriber* handler) { | ||||
|     #ifdef FURI_DEBUG | ||||
| #ifdef FURI_DEBUG | ||||
|     printf("[FURI] closing %s record\n", handler->record->name); | ||||
|     #endif | ||||
| #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 | ||||
| #ifdef FURI_DEBUG | ||||
|     printf("[FURI] read from %s\n", handler->record->name); | ||||
|     #endif | ||||
| #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 | ||||
| #ifdef FURI_DEBUG | ||||
|     printf("[FURI] write to %s\n", handler->record->name); | ||||
|     #endif | ||||
| #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 | ||||
| #ifdef FURI_DEBUG | ||||
|         printf("[FURI] write: handler closed\n"); | ||||
|         #endif | ||||
| #endif | ||||
|         return false; | ||||
|     } | ||||
| 
 | ||||
|     if(handler->record->value != NULL && size > handler->record->size) { | ||||
|         #ifdef FURI_DEBUG | ||||
| #ifdef FURI_DEBUG | ||||
|         printf("[FURI] write: wrong size %d\n", (uint32_t)size); | ||||
|         #endif | ||||
| #endif | ||||
|         return false; | ||||
|     } | ||||
| 
 | ||||
|     // check mute
 | ||||
|     if( | ||||
|         handler->record->mute_counter != handler->mute_counter | ||||
|         && !handler->no_mute | ||||
|     ) { | ||||
|         #ifdef FURI_DEBUG | ||||
|     if(handler->record->mute_counter != handler->mute_counter && !handler->no_mute) { | ||||
| #ifdef FURI_DEBUG | ||||
|         printf("[FURI] write: muted\n"); | ||||
|         #endif | ||||
| #endif | ||||
|         return false; | ||||
|     } | ||||
| 
 | ||||
|  | ||||
							
								
								
									
										13
									
								
								core/furi.h
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								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, | ||||
| FuriRecordSubscriber* furi_open(const char* name, | ||||
|                                 bool solo, | ||||
|                                 bool no_mute, | ||||
|                                 FlipperRecordCallback value_callback, | ||||
|                                 FlipperRecordStateCallback state_callback, | ||||
|     void* ctx | ||||
| ); | ||||
|                                 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 | ||||
| #ifdef FURI_DEBUG | ||||
|     printf("[FURIAC] start %s\n", name); | ||||
|     #endif | ||||
| #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 | ||||
| // max task count exceed
 | ||||
| #ifdef FURI_DEBUG | ||||
|         printf("[FURIAC] max task count exceed\n"); | ||||
|         #endif | ||||
| #endif | ||||
|         return NULL; | ||||
|     } | ||||
| 
 | ||||
|     // create task on static stack memory
 | ||||
|     task_buffer[current_buffer_idx].handler = xTaskCreateStatic( | ||||
|         (TaskFunction_t)app, | ||||
|         (const char * const)name, | ||||
|     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, | ||||
|                           (void* const)param, | ||||
|                           tskIDLE_PRIORITY + 3, // normal priority
 | ||||
|                           stack_buffer[current_buffer_idx], | ||||
|         &task_info_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 | ||||
| #ifdef FURI_DEBUG | ||||
|     printf("[FURIAC] kill %s\n", app->name); | ||||
|     #endif | ||||
| #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 | ||||
| #ifdef FURI_DEBUG | ||||
|         printf("[FURIAC] exit %s\n", current_task->name); | ||||
|         #endif | ||||
| #endif | ||||
| 
 | ||||
|         if(current_task->prev != NULL) { | ||||
|             furiac_start(current_task->prev, current_task->prev_name, param); | ||||
|         } else { | ||||
|             #ifdef FURI_DEBUG | ||||
| #ifdef FURI_DEBUG | ||||
|             printf("[FURIAC] no prev\n"); | ||||
|             #endif | ||||
| #endif | ||||
|         } | ||||
| 
 | ||||
|         // cleanup registry
 | ||||
| @ -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 | ||||
| #ifdef FURI_DEBUG | ||||
|         printf("[FURIAC] no current task found\n"); | ||||
|         #endif | ||||
| #endif | ||||
|     } | ||||
| 
 | ||||
|     #ifdef FURI_DEBUG | ||||
| #ifdef FURI_DEBUG | ||||
|     printf("[FURIAC] switch %s to %s\n", current_task->name, name); | ||||
|     #endif | ||||
| #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, ...); | ||||
|  | ||||
| @ -9,16 +9,16 @@ 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); | ||||
| } | ||||
| 
 | ||||
| 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 | ||||
| @ -41,7 +41,9 @@ bool register_tty_uart() { | ||||
|         return false; | ||||
|     } | ||||
| 
 | ||||
|     FILE* fp = fopencookie(NULL, "w", (cookie_io_functions_t) { | ||||
|     FILE* fp = fopencookie(NULL, | ||||
|                            "w", | ||||
|                            (cookie_io_functions_t){ | ||||
|                                .read = NULL, | ||||
|                                .write = stdout_write, | ||||
|                                .seek = NULL, | ||||
|  | ||||
| @ -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 | ||||
| @ -72,11 +72,11 @@ | ||||
| 
 | ||||
| /* Co-routine definitions. */ | ||||
| #define configUSE_CO_ROUTINES 0 | ||||
| #define configMAX_CO_ROUTINE_PRIORITIES          ( 2 ) | ||||
| #define configMAX_CO_ROUTINE_PRIORITIES (2) | ||||
| 
 | ||||
| /* Software timer definitions. */ | ||||
| #define configUSE_TIMERS 1 | ||||
| #define configTIMER_TASK_PRIORITY                ( 2 ) | ||||
| #define configTIMER_TASK_PRIORITY (2) | ||||
| #define configTIMER_QUEUE_LENGTH 10 | ||||
| #define configTIMER_TASK_STACK_DEPTH 256 | ||||
| 
 | ||||
| @ -93,10 +93,10 @@ to exclude the API function. */ | ||||
| 
 | ||||
| /* 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"
 | ||||
| @ -111,15 +111,22 @@ 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
 | ||||
|  | ||||
| @ -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,16 +140,17 @@ | ||||
|   *        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*/ | ||||
| #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,
 | ||||
| @ -221,197 +224,197 @@ | ||||
|   */ | ||||
| 
 | ||||
| #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 ------------------------------------------------------------*/ | ||||
| @ -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 ------------------------------------------------------------------*/ | ||||
| @ -89,7 +89,7 @@ | ||||
| /* 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 | ||||
| @ -105,25 +105,28 @@ | ||||
| 
 | ||||
| /* DEBUG macros */ | ||||
| 
 | ||||
| #if (USBD_DEBUG_LEVEL > 0) | ||||
| #define USBD_UsrLog(...)    printf(__VA_ARGS__);\ | ||||
| #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__);\ | ||||
| #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__);\ | ||||
| #if(USBD_DEBUG_LEVEL > 2) | ||||
| #define USBD_DbgLog(...) \ | ||||
|     printf("DEBUG : ");  \ | ||||
|     printf(__VA_ARGS__); \ | ||||
|     printf("\n"); | ||||
| #else | ||||
| #define USBD_DbgLog(...) | ||||
| @ -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 ------------------------------------------------------------------*/ | ||||
|  | ||||
| @ -38,12 +38,13 @@ void app_gpio_init(GpioPin gpio, GpioMode mode) { | ||||
| void delay_us(uint32_t time) { | ||||
|     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,17 +55,20 @@ | ||||
| /* 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 ) | ||||
| { | ||||
| __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 | ||||
| @ -82,8 +85,9 @@ __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 ) | ||||
| { | ||||
| void vApplicationGetIdleTaskMemory(StaticTask_t** ppxIdleTaskTCBBuffer, | ||||
|                                    StackType_t** ppxIdleTaskStackBuffer, | ||||
|                                    uint32_t* pulIdleTaskStackSize) { | ||||
|     *ppxIdleTaskTCBBuffer = &xIdleTaskTCBBuffer; | ||||
|     *ppxIdleTaskStackBuffer = &xIdleStack[0]; | ||||
|     *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE; | ||||
| @ -95,8 +99,9 @@ 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 )   | ||||
| { | ||||
| void vApplicationGetTimerTaskMemory(StaticTask_t** ppxTimerTaskTCBBuffer, | ||||
|                                     StackType_t** ppxTimerTaskStackBuffer, | ||||
|                                     uint32_t* pulTimerTaskStackSize) { | ||||
|     *ppxTimerTaskTCBBuffer = &xTimerTaskTCBBuffer; | ||||
|     *ppxTimerTaskStackBuffer = &xTimerStack[0]; | ||||
|     *pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH; | ||||
|  | ||||
| @ -75,7 +75,7 @@ static void MX_TIM5_Init(void); | ||||
| static void MX_TIM15_Init(void); | ||||
| static void MX_USART1_UART_Init(void); | ||||
| static void MX_TIM8_Init(void); | ||||
| void StartDefaultTask(void const * argument); | ||||
| void StartDefaultTask(void const* argument); | ||||
| 
 | ||||
| /* USER CODE BEGIN PFP */ | ||||
| 
 | ||||
| @ -90,13 +90,11 @@ void StartDefaultTask(void const * argument); | ||||
|   * @brief  The application entry point. | ||||
|   * @retval int | ||||
|   */ | ||||
| int main(void) | ||||
| { | ||||
| int main(void) { | ||||
|     /* USER CODE BEGIN 1 */ | ||||
| 
 | ||||
|     /* USER CODE END 1 */ | ||||
| 
 | ||||
| 
 | ||||
|     /* MCU Configuration--------------------------------------------------------*/ | ||||
| 
 | ||||
|     /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ | ||||
| @ -160,8 +158,7 @@ int main(void) | ||||
| 
 | ||||
|     /* Infinite loop */ | ||||
|     /* USER CODE BEGIN WHILE */ | ||||
|   while (1) | ||||
|   { | ||||
|     while(1) { | ||||
|         /* USER CODE END WHILE */ | ||||
| 
 | ||||
|         /* USER CODE BEGIN 3 */ | ||||
| @ -173,8 +170,7 @@ int main(void) | ||||
|   * @brief System Clock Configuration | ||||
|   * @retval None | ||||
|   */ | ||||
| void SystemClock_Config(void) | ||||
| { | ||||
| void SystemClock_Config(void) { | ||||
|     RCC_OscInitTypeDef RCC_OscInitStruct = {0}; | ||||
|     RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; | ||||
|     RCC_PeriphCLKInitTypeDef PeriphClkInit = {0}; | ||||
| @ -190,25 +186,23 @@ void SystemClock_Config(void) | ||||
|     RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV7; | ||||
|     RCC_OscInitStruct.PLL.PLLQ = RCC_PLLQ_DIV2; | ||||
|     RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV2; | ||||
|   if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) | ||||
|   { | ||||
|     if(HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { | ||||
|         Error_Handler(); | ||||
|     } | ||||
|     /** Initializes the CPU, AHB and APB busses clocks 
 | ||||
|   */ | ||||
|   RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK | ||||
|                               |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2; | ||||
|     RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_PCLK1 | | ||||
|                                   RCC_CLOCKTYPE_PCLK2; | ||||
|     RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; | ||||
|     RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; | ||||
|     RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; | ||||
|     RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; | ||||
| 
 | ||||
|   if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_3) != HAL_OK) | ||||
|   { | ||||
|     if(HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_3) != HAL_OK) { | ||||
|         Error_Handler(); | ||||
|     } | ||||
|   PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USART1|RCC_PERIPHCLK_USB | ||||
|                               |RCC_PERIPHCLK_ADC; | ||||
|     PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USART1 | RCC_PERIPHCLK_USB | | ||||
|                                          RCC_PERIPHCLK_ADC; | ||||
|     PeriphClkInit.Usart1ClockSelection = RCC_USART1CLKSOURCE_PCLK2; | ||||
|     PeriphClkInit.AdcClockSelection = RCC_ADCCLKSOURCE_SYSCLK; | ||||
|     PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_PLLSAI1; | ||||
| @ -219,14 +213,12 @@ void SystemClock_Config(void) | ||||
|     PeriphClkInit.PLLSAI1.PLLSAI1Q = RCC_PLLQ_DIV2; | ||||
|     PeriphClkInit.PLLSAI1.PLLSAI1R = RCC_PLLR_DIV2; | ||||
|     PeriphClkInit.PLLSAI1.PLLSAI1ClockOut = RCC_PLLSAI1_48M2CLK; | ||||
|   if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK) | ||||
|   { | ||||
|     if(HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK) { | ||||
|         Error_Handler(); | ||||
|     } | ||||
|     /** Configure the main internal regulator output voltage 
 | ||||
|   */ | ||||
|   if (HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1) != HAL_OK) | ||||
|   { | ||||
|     if(HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1) != HAL_OK) { | ||||
|         Error_Handler(); | ||||
|     } | ||||
| } | ||||
| @ -236,9 +228,7 @@ void SystemClock_Config(void) | ||||
|   * @param None | ||||
|   * @retval None | ||||
|   */ | ||||
| static void MX_ADC1_Init(void) | ||||
| { | ||||
| 
 | ||||
| static void MX_ADC1_Init(void) { | ||||
|     /* USER CODE BEGIN ADC1_Init 0 */ | ||||
| 
 | ||||
|     /* USER CODE END ADC1_Init 0 */ | ||||
| @ -266,15 +256,13 @@ static void MX_ADC1_Init(void) | ||||
|     hadc1.Init.DMAContinuousRequests = DISABLE; | ||||
|     hadc1.Init.Overrun = ADC_OVR_DATA_PRESERVED; | ||||
|     hadc1.Init.OversamplingMode = DISABLE; | ||||
|   if (HAL_ADC_Init(&hadc1) != HAL_OK) | ||||
|   { | ||||
|     if(HAL_ADC_Init(&hadc1) != HAL_OK) { | ||||
|         Error_Handler(); | ||||
|     } | ||||
|     /** Configure the ADC multi-mode 
 | ||||
|   */ | ||||
|     multimode.Mode = ADC_MODE_INDEPENDENT; | ||||
|   if (HAL_ADCEx_MultiModeConfigChannel(&hadc1, &multimode) != HAL_OK) | ||||
|   { | ||||
|     if(HAL_ADCEx_MultiModeConfigChannel(&hadc1, &multimode) != HAL_OK) { | ||||
|         Error_Handler(); | ||||
|     } | ||||
|     /** Configure Regular Channel 
 | ||||
| @ -285,14 +273,12 @@ static void MX_ADC1_Init(void) | ||||
|     sConfig.SingleDiff = ADC_SINGLE_ENDED; | ||||
|     sConfig.OffsetNumber = ADC_OFFSET_NONE; | ||||
|     sConfig.Offset = 0; | ||||
|   if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK) | ||||
|   { | ||||
|     if(HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK) { | ||||
|         Error_Handler(); | ||||
|     } | ||||
|     /* USER CODE BEGIN ADC1_Init 2 */ | ||||
| 
 | ||||
|     /* USER CODE END ADC1_Init 2 */ | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -300,9 +286,7 @@ static void MX_ADC1_Init(void) | ||||
|   * @param None | ||||
|   * @retval None | ||||
|   */ | ||||
| static void MX_COMP1_Init(void) | ||||
| { | ||||
| 
 | ||||
| static void MX_COMP1_Init(void) { | ||||
|     /* USER CODE BEGIN COMP1_Init 0 */ | ||||
| 
 | ||||
|     /* USER CODE END COMP1_Init 0 */ | ||||
| @ -319,14 +303,12 @@ static void MX_COMP1_Init(void) | ||||
|     hcomp1.Init.Mode = COMP_POWERMODE_HIGHSPEED; | ||||
|     hcomp1.Init.WindowMode = COMP_WINDOWMODE_DISABLE; | ||||
|     hcomp1.Init.TriggerMode = COMP_TRIGGERMODE_NONE; | ||||
|   if (HAL_COMP_Init(&hcomp1) != HAL_OK) | ||||
|   { | ||||
|     if(HAL_COMP_Init(&hcomp1) != HAL_OK) { | ||||
|         Error_Handler(); | ||||
|     } | ||||
|     /* USER CODE BEGIN COMP1_Init 2 */ | ||||
| 
 | ||||
|     /* USER CODE END COMP1_Init 2 */ | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -334,9 +316,7 @@ static void MX_COMP1_Init(void) | ||||
|   * @param None | ||||
|   * @retval None | ||||
|   */ | ||||
| static void MX_DAC1_Init(void) | ||||
| { | ||||
| 
 | ||||
| static void MX_DAC1_Init(void) { | ||||
|     /* USER CODE BEGIN DAC1_Init 0 */ | ||||
| 
 | ||||
|     /* USER CODE END DAC1_Init 0 */ | ||||
| @ -349,8 +329,7 @@ static void MX_DAC1_Init(void) | ||||
|     /** DAC Initialization 
 | ||||
|   */ | ||||
|     hdac1.Instance = DAC1; | ||||
|   if (HAL_DAC_Init(&hdac1) != HAL_OK) | ||||
|   { | ||||
|     if(HAL_DAC_Init(&hdac1) != HAL_OK) { | ||||
|         Error_Handler(); | ||||
|     } | ||||
|     /** DAC channel OUT1 config 
 | ||||
| @ -360,14 +339,12 @@ static void MX_DAC1_Init(void) | ||||
|     sConfig.DAC_OutputBuffer = DAC_OUTPUTBUFFER_ENABLE; | ||||
|     sConfig.DAC_ConnectOnChipPeripheral = DAC_CHIPCONNECT_ENABLE; | ||||
|     sConfig.DAC_UserTrimming = DAC_TRIMMING_FACTORY; | ||||
|   if (HAL_DAC_ConfigChannel(&hdac1, &sConfig, DAC_CHANNEL_1) != HAL_OK) | ||||
|   { | ||||
|     if(HAL_DAC_ConfigChannel(&hdac1, &sConfig, DAC_CHANNEL_1) != HAL_OK) { | ||||
|         Error_Handler(); | ||||
|     } | ||||
|     /* USER CODE BEGIN DAC1_Init 2 */ | ||||
| 
 | ||||
|     /* USER CODE END DAC1_Init 2 */ | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -375,9 +352,7 @@ static void MX_DAC1_Init(void) | ||||
|   * @param None | ||||
|   * @retval None | ||||
|   */ | ||||
| static void MX_SPI1_Init(void) | ||||
| { | ||||
| 
 | ||||
| static void MX_SPI1_Init(void) { | ||||
|     /* USER CODE BEGIN SPI1_Init 0 */ | ||||
| 
 | ||||
|     /* USER CODE END SPI1_Init 0 */ | ||||
| @ -400,14 +375,12 @@ static void MX_SPI1_Init(void) | ||||
|     hspi1.Init.CRCPolynomial = 7; | ||||
|     hspi1.Init.CRCLength = SPI_CRC_LENGTH_DATASIZE; | ||||
|     hspi1.Init.NSSPMode = SPI_NSS_PULSE_ENABLE; | ||||
|   if (HAL_SPI_Init(&hspi1) != HAL_OK) | ||||
|   { | ||||
|     if(HAL_SPI_Init(&hspi1) != HAL_OK) { | ||||
|         Error_Handler(); | ||||
|     } | ||||
|     /* USER CODE BEGIN SPI1_Init 2 */ | ||||
| 
 | ||||
|     /* USER CODE END SPI1_Init 2 */ | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -415,9 +388,7 @@ static void MX_SPI1_Init(void) | ||||
|   * @param None | ||||
|   * @retval None | ||||
|   */ | ||||
| static void MX_SPI3_Init(void) | ||||
| { | ||||
| 
 | ||||
| static void MX_SPI3_Init(void) { | ||||
|     /* USER CODE BEGIN SPI3_Init 0 */ | ||||
| 
 | ||||
|     /* USER CODE END SPI3_Init 0 */ | ||||
| @ -440,14 +411,12 @@ static void MX_SPI3_Init(void) | ||||
|     hspi3.Init.CRCPolynomial = 7; | ||||
|     hspi3.Init.CRCLength = SPI_CRC_LENGTH_DATASIZE; | ||||
|     hspi3.Init.NSSPMode = SPI_NSS_PULSE_ENABLE; | ||||
|   if (HAL_SPI_Init(&hspi3) != HAL_OK) | ||||
|   { | ||||
|     if(HAL_SPI_Init(&hspi3) != HAL_OK) { | ||||
|         Error_Handler(); | ||||
|     } | ||||
|     /* USER CODE BEGIN SPI3_Init 2 */ | ||||
| 
 | ||||
|     /* USER CODE END SPI3_Init 2 */ | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -455,9 +424,7 @@ static void MX_SPI3_Init(void) | ||||
|   * @param None | ||||
|   * @retval None | ||||
|   */ | ||||
| static void MX_TIM5_Init(void) | ||||
| { | ||||
| 
 | ||||
| static void MX_TIM5_Init(void) { | ||||
|     /* USER CODE BEGIN TIM5_Init 0 */ | ||||
| 
 | ||||
|     /* USER CODE END TIM5_Init 0 */ | ||||
| @ -474,29 +441,25 @@ static void MX_TIM5_Init(void) | ||||
|     htim5.Init.Period = 291; | ||||
|     htim5.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; | ||||
|     htim5.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; | ||||
|   if (HAL_TIM_PWM_Init(&htim5) != HAL_OK) | ||||
|   { | ||||
|     if(HAL_TIM_PWM_Init(&htim5) != HAL_OK) { | ||||
|         Error_Handler(); | ||||
|     } | ||||
|     sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET; | ||||
|     sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; | ||||
|   if (HAL_TIMEx_MasterConfigSynchronization(&htim5, &sMasterConfig) != HAL_OK) | ||||
|   { | ||||
|     if(HAL_TIMEx_MasterConfigSynchronization(&htim5, &sMasterConfig) != HAL_OK) { | ||||
|         Error_Handler(); | ||||
|     } | ||||
|     sConfigOC.OCMode = TIM_OCMODE_PWM1; | ||||
|     sConfigOC.Pulse = 145; | ||||
|     sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH; | ||||
|     sConfigOC.OCFastMode = TIM_OCFAST_DISABLE; | ||||
|   if (HAL_TIM_PWM_ConfigChannel(&htim5, &sConfigOC, TIM_CHANNEL_4) != HAL_OK) | ||||
|   { | ||||
|     if(HAL_TIM_PWM_ConfigChannel(&htim5, &sConfigOC, TIM_CHANNEL_4) != HAL_OK) { | ||||
|         Error_Handler(); | ||||
|     } | ||||
|     /* USER CODE BEGIN TIM5_Init 2 */ | ||||
| 
 | ||||
|     /* USER CODE END TIM5_Init 2 */ | ||||
|     HAL_TIM_MspPostInit(&htim5); | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -504,9 +467,7 @@ static void MX_TIM5_Init(void) | ||||
|   * @param None | ||||
|   * @retval None | ||||
|   */ | ||||
| static void MX_TIM8_Init(void) | ||||
| { | ||||
| 
 | ||||
| static void MX_TIM8_Init(void) { | ||||
|     /* USER CODE BEGIN TIM8_Init 0 */ | ||||
| 
 | ||||
|     /* USER CODE END TIM8_Init 0 */ | ||||
| @ -519,44 +480,38 @@ static void MX_TIM8_Init(void) | ||||
| 
 | ||||
|     /* USER CODE END TIM8_Init 1 */ | ||||
|     htim8.Instance = TIM8; | ||||
|   htim8.Init.Prescaler = 64-1; | ||||
|     htim8.Init.Prescaler = 64 - 1; | ||||
|     htim8.Init.CounterMode = TIM_COUNTERMODE_UP; | ||||
|   htim8.Init.Period = 32768-1; | ||||
|     htim8.Init.Period = 32768 - 1; | ||||
|     htim8.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; | ||||
|     htim8.Init.RepetitionCounter = 0; | ||||
|     htim8.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; | ||||
|   if (HAL_TIM_Base_Init(&htim8) != HAL_OK) | ||||
|   { | ||||
|     if(HAL_TIM_Base_Init(&htim8) != HAL_OK) { | ||||
|         Error_Handler(); | ||||
|     } | ||||
|     sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL; | ||||
|   if (HAL_TIM_ConfigClockSource(&htim8, &sClockSourceConfig) != HAL_OK) | ||||
|   { | ||||
|     if(HAL_TIM_ConfigClockSource(&htim8, &sClockSourceConfig) != HAL_OK) { | ||||
|         Error_Handler(); | ||||
|     } | ||||
|   if (HAL_TIM_IC_Init(&htim8) != HAL_OK) | ||||
|   { | ||||
|     if(HAL_TIM_IC_Init(&htim8) != HAL_OK) { | ||||
|         Error_Handler(); | ||||
|     } | ||||
|     sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET; | ||||
|     sMasterConfig.MasterOutputTrigger2 = TIM_TRGO2_RESET; | ||||
|     sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; | ||||
|   if (HAL_TIMEx_MasterConfigSynchronization(&htim8, &sMasterConfig) != HAL_OK) | ||||
|   { | ||||
|     if(HAL_TIMEx_MasterConfigSynchronization(&htim8, &sMasterConfig) != HAL_OK) { | ||||
|         Error_Handler(); | ||||
|     } | ||||
|     sConfigIC.ICPolarity = TIM_INPUTCHANNELPOLARITY_BOTHEDGE; | ||||
|     sConfigIC.ICSelection = TIM_ICSELECTION_DIRECTTI; | ||||
|     sConfigIC.ICPrescaler = TIM_ICPSC_DIV1; | ||||
|     sConfigIC.ICFilter = 0; | ||||
|   if (HAL_TIM_IC_ConfigChannel(&htim8, &sConfigIC, TIM_CHANNEL_2) != HAL_OK) | ||||
|   { | ||||
|     if(HAL_TIM_IC_ConfigChannel(&htim8, &sConfigIC, TIM_CHANNEL_2) != HAL_OK) { | ||||
|         Error_Handler(); | ||||
|     } | ||||
|     /* USER CODE BEGIN TIM8_Init 2 */ | ||||
| 
 | ||||
|     /* USER CODE END TIM8_Init 2 */ | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -564,9 +519,7 @@ static void MX_TIM8_Init(void) | ||||
|   * @param None | ||||
|   * @retval None | ||||
|   */ | ||||
| static void MX_TIM15_Init(void) | ||||
| { | ||||
| 
 | ||||
| static void MX_TIM15_Init(void) { | ||||
|     /* USER CODE BEGIN TIM15_Init 0 */ | ||||
| 
 | ||||
|     /* USER CODE END TIM15_Init 0 */ | ||||
| @ -585,14 +538,12 @@ static void MX_TIM15_Init(void) | ||||
|     htim15.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; | ||||
|     htim15.Init.RepetitionCounter = 0; | ||||
|     htim15.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; | ||||
|   if (HAL_TIM_OC_Init(&htim15) != HAL_OK) | ||||
|   { | ||||
|     if(HAL_TIM_OC_Init(&htim15) != HAL_OK) { | ||||
|         Error_Handler(); | ||||
|     } | ||||
|     sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET; | ||||
|     sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; | ||||
|   if (HAL_TIMEx_MasterConfigSynchronization(&htim15, &sMasterConfig) != HAL_OK) | ||||
|   { | ||||
|     if(HAL_TIMEx_MasterConfigSynchronization(&htim15, &sMasterConfig) != HAL_OK) { | ||||
|         Error_Handler(); | ||||
|     } | ||||
|     sConfigOC.OCMode = TIM_OCMODE_TIMING; | ||||
| @ -602,12 +553,10 @@ static void MX_TIM15_Init(void) | ||||
|     sConfigOC.OCFastMode = TIM_OCFAST_DISABLE; | ||||
|     sConfigOC.OCIdleState = TIM_OCIDLESTATE_RESET; | ||||
|     sConfigOC.OCNIdleState = TIM_OCNIDLESTATE_RESET; | ||||
|   if (HAL_TIM_OC_ConfigChannel(&htim15, &sConfigOC, TIM_CHANNEL_1) != HAL_OK) | ||||
|   { | ||||
|     if(HAL_TIM_OC_ConfigChannel(&htim15, &sConfigOC, TIM_CHANNEL_1) != HAL_OK) { | ||||
|         Error_Handler(); | ||||
|     } | ||||
|   if (HAL_TIM_OC_ConfigChannel(&htim15, &sConfigOC, TIM_CHANNEL_2) != HAL_OK) | ||||
|   { | ||||
|     if(HAL_TIM_OC_ConfigChannel(&htim15, &sConfigOC, TIM_CHANNEL_2) != HAL_OK) { | ||||
|         Error_Handler(); | ||||
|     } | ||||
|     sBreakDeadTimeConfig.OffStateRunMode = TIM_OSSR_DISABLE; | ||||
| @ -617,15 +566,13 @@ static void MX_TIM15_Init(void) | ||||
|     sBreakDeadTimeConfig.BreakState = TIM_BREAK_DISABLE; | ||||
|     sBreakDeadTimeConfig.BreakPolarity = TIM_BREAKPOLARITY_HIGH; | ||||
|     sBreakDeadTimeConfig.AutomaticOutput = TIM_AUTOMATICOUTPUT_DISABLE; | ||||
|   if (HAL_TIMEx_ConfigBreakDeadTime(&htim15, &sBreakDeadTimeConfig) != HAL_OK) | ||||
|   { | ||||
|     if(HAL_TIMEx_ConfigBreakDeadTime(&htim15, &sBreakDeadTimeConfig) != HAL_OK) { | ||||
|         Error_Handler(); | ||||
|     } | ||||
|     /* USER CODE BEGIN TIM15_Init 2 */ | ||||
| 
 | ||||
|     /* USER CODE END TIM15_Init 2 */ | ||||
|     HAL_TIM_MspPostInit(&htim15); | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -633,9 +580,7 @@ static void MX_TIM15_Init(void) | ||||
|   * @param None | ||||
|   * @retval None | ||||
|   */ | ||||
| static void MX_USART1_UART_Init(void) | ||||
| { | ||||
| 
 | ||||
| static void MX_USART1_UART_Init(void) { | ||||
|     /* USER CODE BEGIN USART1_Init 0 */ | ||||
| 
 | ||||
|     /* USER CODE END USART1_Init 0 */ | ||||
| @ -653,14 +598,12 @@ static void MX_USART1_UART_Init(void) | ||||
|     huart1.Init.OverSampling = UART_OVERSAMPLING_16; | ||||
|     huart1.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE; | ||||
|     huart1.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT; | ||||
|   if (HAL_UART_Init(&huart1) != HAL_OK) | ||||
|   { | ||||
|     if(HAL_UART_Init(&huart1) != HAL_OK) { | ||||
|         Error_Handler(); | ||||
|     } | ||||
|     /* USER CODE BEGIN USART1_Init 2 */ | ||||
| 
 | ||||
|     /* USER CODE END USART1_Init 2 */ | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -668,8 +611,7 @@ static void MX_USART1_UART_Init(void) | ||||
|   * @param None | ||||
|   * @retval None | ||||
|   */ | ||||
| static void MX_GPIO_Init(void) | ||||
| { | ||||
| static void MX_GPIO_Init(void) { | ||||
|     GPIO_InitTypeDef GPIO_InitStruct = {0}; | ||||
| 
 | ||||
|     /* GPIO Ports Clock Enable */ | ||||
| @ -680,22 +622,22 @@ static void MX_GPIO_Init(void) | ||||
|     __HAL_RCC_GPIOD_CLK_ENABLE(); | ||||
| 
 | ||||
|     /*Configure GPIO pin Output Level */ | ||||
|   HAL_GPIO_WritePin(GPIOA, DISPLAY_DI_Pin|CC1101_CS_Pin, GPIO_PIN_RESET); | ||||
|     HAL_GPIO_WritePin(GPIOA, DISPLAY_DI_Pin | CC1101_CS_Pin, GPIO_PIN_RESET); | ||||
| 
 | ||||
|     /*Configure GPIO pin Output Level */ | ||||
|   HAL_GPIO_WritePin(GPIOB, LED_BLUE_Pin|LED_GREEN_Pin, GPIO_PIN_SET); | ||||
|     HAL_GPIO_WritePin(GPIOB, LED_BLUE_Pin | LED_GREEN_Pin, GPIO_PIN_SET); | ||||
| 
 | ||||
|     /*Configure GPIO pin Output Level */ | ||||
|   HAL_GPIO_WritePin(GPIOB, DISPLAY_RST_Pin|IR_TX_Pin|DISPLAY_BACKLIGHT_Pin, GPIO_PIN_RESET); | ||||
|     HAL_GPIO_WritePin(GPIOB, DISPLAY_RST_Pin | IR_TX_Pin | DISPLAY_BACKLIGHT_Pin, GPIO_PIN_RESET); | ||||
| 
 | ||||
|     /*Configure GPIO pin Output Level */ | ||||
|   HAL_GPIO_WritePin(GPIOC, VIBRO_Pin|DISPLAY_CS_Pin, GPIO_PIN_RESET); | ||||
|     HAL_GPIO_WritePin(GPIOC, VIBRO_Pin | DISPLAY_CS_Pin, GPIO_PIN_RESET); | ||||
| 
 | ||||
|     /*Configure GPIO pin Output Level */ | ||||
|     HAL_GPIO_WritePin(LED_RED_GPIO_Port, LED_RED_Pin, GPIO_PIN_SET); | ||||
| 
 | ||||
|     /*Configure GPIO pins : PC13 PC0 PC1 PC9 */ | ||||
|   GPIO_InitStruct.Pin = GPIO_PIN_13|GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_9; | ||||
|     GPIO_InitStruct.Pin = GPIO_PIN_13 | GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_9; | ||||
|     GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; | ||||
|     GPIO_InitStruct.Pull = GPIO_NOPULL; | ||||
|     HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); | ||||
| @ -707,52 +649,52 @@ static void MX_GPIO_Init(void) | ||||
|     HAL_GPIO_Init(CHRG_GPIO_Port, &GPIO_InitStruct); | ||||
| 
 | ||||
|     /*Configure GPIO pins : BUTTON_DOWN_Pin BUTTON_BACK_Pin */ | ||||
|   GPIO_InitStruct.Pin = BUTTON_DOWN_Pin|BUTTON_BACK_Pin; | ||||
|     GPIO_InitStruct.Pin = BUTTON_DOWN_Pin | BUTTON_BACK_Pin; | ||||
|     GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING; | ||||
|     GPIO_InitStruct.Pull = GPIO_PULLDOWN; | ||||
|     HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); | ||||
| 
 | ||||
|     /*Configure GPIO pins : DISPLAY_DI_Pin CC1101_CS_Pin */ | ||||
|   GPIO_InitStruct.Pin = DISPLAY_DI_Pin|CC1101_CS_Pin; | ||||
|     GPIO_InitStruct.Pin = DISPLAY_DI_Pin | CC1101_CS_Pin; | ||||
|     GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; | ||||
|     GPIO_InitStruct.Pull = GPIO_NOPULL; | ||||
|     GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; | ||||
|     HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); | ||||
| 
 | ||||
|     /*Configure GPIO pins : PA5 PA7 */ | ||||
|   GPIO_InitStruct.Pin = GPIO_PIN_5|GPIO_PIN_7; | ||||
|     GPIO_InitStruct.Pin = GPIO_PIN_5 | GPIO_PIN_7; | ||||
|     GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; | ||||
|     GPIO_InitStruct.Pull = GPIO_NOPULL; | ||||
|     HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); | ||||
| 
 | ||||
|     /*Configure GPIO pins : BUTTON_UP_Pin BUTTON_RIGHT_Pin BUTTON_OK_Pin */ | ||||
|   GPIO_InitStruct.Pin = BUTTON_UP_Pin|BUTTON_RIGHT_Pin|BUTTON_OK_Pin; | ||||
|     GPIO_InitStruct.Pin = BUTTON_UP_Pin | BUTTON_RIGHT_Pin | BUTTON_OK_Pin; | ||||
|     GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING; | ||||
|     GPIO_InitStruct.Pull = GPIO_PULLDOWN; | ||||
|     HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); | ||||
| 
 | ||||
|     /*Configure GPIO pins : LED_BLUE_Pin LED_GREEN_Pin */ | ||||
|   GPIO_InitStruct.Pin = LED_BLUE_Pin|LED_GREEN_Pin; | ||||
|     GPIO_InitStruct.Pin = LED_BLUE_Pin | LED_GREEN_Pin; | ||||
|     GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_OD; | ||||
|     GPIO_InitStruct.Pull = GPIO_NOPULL; | ||||
|     GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM; | ||||
|     HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); | ||||
| 
 | ||||
|     /*Configure GPIO pins : PB2 PB12 */ | ||||
|   GPIO_InitStruct.Pin = GPIO_PIN_2|GPIO_PIN_12; | ||||
|     GPIO_InitStruct.Pin = GPIO_PIN_2 | GPIO_PIN_12; | ||||
|     GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; | ||||
|     GPIO_InitStruct.Pull = GPIO_NOPULL; | ||||
|     HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); | ||||
| 
 | ||||
|     /*Configure GPIO pins : DISPLAY_RST_Pin IR_TX_Pin DISPLAY_BACKLIGHT_Pin */ | ||||
|   GPIO_InitStruct.Pin = DISPLAY_RST_Pin|IR_TX_Pin|DISPLAY_BACKLIGHT_Pin; | ||||
|     GPIO_InitStruct.Pin = DISPLAY_RST_Pin | IR_TX_Pin | DISPLAY_BACKLIGHT_Pin; | ||||
|     GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; | ||||
|     GPIO_InitStruct.Pull = GPIO_NOPULL; | ||||
|     GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; | ||||
|     HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); | ||||
| 
 | ||||
|     /*Configure GPIO pins : VIBRO_Pin DISPLAY_CS_Pin */ | ||||
|   GPIO_InitStruct.Pin = VIBRO_Pin|DISPLAY_CS_Pin; | ||||
|     GPIO_InitStruct.Pin = VIBRO_Pin | DISPLAY_CS_Pin; | ||||
|     GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; | ||||
|     GPIO_InitStruct.Pull = GPIO_NOPULL; | ||||
|     GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; | ||||
| @ -798,7 +740,6 @@ static void MX_GPIO_Init(void) | ||||
| 
 | ||||
|     HAL_NVIC_SetPriority(EXTI9_5_IRQn, 5, 0); | ||||
|     HAL_NVIC_EnableIRQ(EXTI9_5_IRQn); | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| /* USER CODE BEGIN 4 */ | ||||
| @ -812,16 +753,14 @@ void app(); | ||||
|   * @retval None | ||||
|   */ | ||||
| /* USER CODE END Header_StartDefaultTask */ | ||||
| void StartDefaultTask(void const * argument) | ||||
| { | ||||
| void StartDefaultTask(void const* argument) { | ||||
|     /* init code for USB_DEVICE */ | ||||
|     MX_USB_DEVICE_Init(); | ||||
|     /* USER CODE BEGIN 5 */ | ||||
|     /* Infinite loop */ | ||||
|     app(); | ||||
| 
 | ||||
|   for(;;) | ||||
|   { | ||||
|     for(;;) { | ||||
|         osDelay(1); | ||||
|     } | ||||
|     /* USER CODE END 5 */ | ||||
| @ -831,8 +770,7 @@ void StartDefaultTask(void const * argument) | ||||
|   * @brief  This function is executed in case of error occurrence. | ||||
|   * @retval None | ||||
|   */ | ||||
| void Error_Handler(void) | ||||
| { | ||||
| void Error_Handler(void) { | ||||
|     /* USER CODE BEGIN Error_Handler_Debug */ | ||||
|     /* User can add his own implementation to report the HAL error return state */ | ||||
| 
 | ||||
| @ -847,8 +785,7 @@ void Error_Handler(void) | ||||
|   * @param  line: assert_param error line source number | ||||
|   * @retval None | ||||
|   */ | ||||
| void assert_failed(char *file, uint32_t line) | ||||
| {  | ||||
| void assert_failed(char* file, uint32_t line) { | ||||
|     /* USER CODE BEGIN 6 */ | ||||
|     /* User can add his own implementation to report the file name and line number,
 | ||||
|      tex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ | ||||
|  | ||||
| @ -59,12 +59,11 @@ | ||||
| 
 | ||||
| /* 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) | ||||
| { | ||||
| void HAL_MspInit(void) { | ||||
|     /* USER CODE BEGIN MspInit 0 */ | ||||
| 
 | ||||
|     /* USER CODE END MspInit 0 */ | ||||
| @ -87,11 +86,9 @@ void HAL_MspInit(void) | ||||
| * @param hadc: ADC handle pointer | ||||
| * @retval None | ||||
| */ | ||||
| void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc) | ||||
| { | ||||
| void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc) { | ||||
|     GPIO_InitTypeDef GPIO_InitStruct = {0}; | ||||
|   if(hadc->Instance==ADC1) | ||||
|   { | ||||
|     if(hadc->Instance == ADC1) { | ||||
|         /* USER CODE BEGIN ADC1_MspInit 0 */ | ||||
| 
 | ||||
|         /* USER CODE END ADC1_MspInit 0 */ | ||||
| @ -118,7 +115,6 @@ void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc) | ||||
| 
 | ||||
|         /* USER CODE END ADC1_MspInit 1 */ | ||||
|     } | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -127,10 +123,8 @@ 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) | ||||
|   { | ||||
| void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc) { | ||||
|     if(hadc->Instance == ADC1) { | ||||
|         /* USER CODE BEGIN ADC1_MspDeInit 0 */ | ||||
| 
 | ||||
|         /* USER CODE END ADC1_MspDeInit 0 */ | ||||
| @ -149,7 +143,6 @@ void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc) | ||||
| 
 | ||||
|         /* USER CODE END ADC1_MspDeInit 1 */ | ||||
|     } | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -158,11 +151,9 @@ void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc) | ||||
| * @param hcomp: COMP handle pointer | ||||
| * @retval None | ||||
| */ | ||||
| void HAL_COMP_MspInit(COMP_HandleTypeDef* hcomp) | ||||
| { | ||||
| void HAL_COMP_MspInit(COMP_HandleTypeDef* hcomp) { | ||||
|     GPIO_InitTypeDef GPIO_InitStruct = {0}; | ||||
|   if(hcomp->Instance==COMP1) | ||||
|   { | ||||
|     if(hcomp->Instance == COMP1) { | ||||
|         /* USER CODE BEGIN COMP1_MspInit 0 */ | ||||
| 
 | ||||
|         /* USER CODE END COMP1_MspInit 0 */ | ||||
| @ -180,7 +171,6 @@ void HAL_COMP_MspInit(COMP_HandleTypeDef* hcomp) | ||||
| 
 | ||||
|         /* USER CODE END COMP1_MspInit 1 */ | ||||
|     } | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -189,10 +179,8 @@ 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) | ||||
|   { | ||||
| void HAL_COMP_MspDeInit(COMP_HandleTypeDef* hcomp) { | ||||
|     if(hcomp->Instance == COMP1) { | ||||
|         /* USER CODE BEGIN COMP1_MspDeInit 0 */ | ||||
| 
 | ||||
|         /* USER CODE END COMP1_MspDeInit 0 */ | ||||
| @ -206,7 +194,6 @@ void HAL_COMP_MspDeInit(COMP_HandleTypeDef* hcomp) | ||||
| 
 | ||||
|         /* USER CODE END COMP1_MspDeInit 1 */ | ||||
|     } | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -215,11 +202,9 @@ void HAL_COMP_MspDeInit(COMP_HandleTypeDef* hcomp) | ||||
| * @param hdac: DAC handle pointer | ||||
| * @retval None | ||||
| */ | ||||
| void HAL_DAC_MspInit(DAC_HandleTypeDef* hdac) | ||||
| { | ||||
| void HAL_DAC_MspInit(DAC_HandleTypeDef* hdac) { | ||||
|     GPIO_InitTypeDef GPIO_InitStruct = {0}; | ||||
|   if(hdac->Instance==DAC1) | ||||
|   { | ||||
|     if(hdac->Instance == DAC1) { | ||||
|         /* USER CODE BEGIN DAC1_MspInit 0 */ | ||||
| 
 | ||||
|         /* USER CODE END DAC1_MspInit 0 */ | ||||
| @ -239,7 +224,6 @@ void HAL_DAC_MspInit(DAC_HandleTypeDef* hdac) | ||||
| 
 | ||||
|         /* USER CODE END DAC1_MspInit 1 */ | ||||
|     } | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -248,10 +232,8 @@ 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) | ||||
|   { | ||||
| void HAL_DAC_MspDeInit(DAC_HandleTypeDef* hdac) { | ||||
|     if(hdac->Instance == DAC1) { | ||||
|         /* USER CODE BEGIN DAC1_MspDeInit 0 */ | ||||
| 
 | ||||
|         /* USER CODE END DAC1_MspDeInit 0 */ | ||||
| @ -267,7 +249,6 @@ void HAL_DAC_MspDeInit(DAC_HandleTypeDef* hdac) | ||||
| 
 | ||||
|         /* USER CODE END DAC1_MspDeInit 1 */ | ||||
|     } | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -276,11 +257,9 @@ void HAL_DAC_MspDeInit(DAC_HandleTypeDef* hdac) | ||||
| * @param hspi: SPI handle pointer | ||||
| * @retval None | ||||
| */ | ||||
| void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi) | ||||
| { | ||||
| void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi) { | ||||
|     GPIO_InitTypeDef GPIO_InitStruct = {0}; | ||||
|   if(hspi->Instance==SPI1) | ||||
|   { | ||||
|     if(hspi->Instance == SPI1) { | ||||
|         /* USER CODE BEGIN SPI1_MspInit 0 */ | ||||
| 
 | ||||
|         /* USER CODE END SPI1_MspInit 0 */ | ||||
| @ -292,7 +271,7 @@ void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi) | ||||
|     PB3 (JTDO-TRACESWO)     ------> SPI1_SCK | ||||
|     PB5     ------> SPI1_MOSI  | ||||
|     */ | ||||
|     GPIO_InitStruct.Pin = GPIO_PIN_3|GPIO_PIN_5; | ||||
|         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; | ||||
| @ -302,9 +281,7 @@ void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi) | ||||
|         /* USER CODE BEGIN SPI1_MspInit 1 */ | ||||
| 
 | ||||
|         /* USER CODE END SPI1_MspInit 1 */ | ||||
|   } | ||||
|   else if(hspi->Instance==SPI3) | ||||
|   { | ||||
|     } else if(hspi->Instance == SPI3) { | ||||
|         /* USER CODE BEGIN SPI3_MspInit 0 */ | ||||
| 
 | ||||
|         /* USER CODE END SPI3_MspInit 0 */ | ||||
| @ -317,7 +294,7 @@ void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi) | ||||
|     PC11     ------> SPI3_MISO | ||||
|     PC12     ------> SPI3_MOSI  | ||||
|     */ | ||||
|     GPIO_InitStruct.Pin = GPIO_PIN_10|GPIO_PIN_11|GPIO_PIN_12; | ||||
|         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; | ||||
| @ -328,7 +305,6 @@ void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi) | ||||
| 
 | ||||
|         /* USER CODE END SPI3_MspInit 1 */ | ||||
|     } | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -337,10 +313,8 @@ 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) | ||||
|   { | ||||
| void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi) { | ||||
|     if(hspi->Instance == SPI1) { | ||||
|         /* USER CODE BEGIN SPI1_MspDeInit 0 */ | ||||
| 
 | ||||
|         /* USER CODE END SPI1_MspDeInit 0 */ | ||||
| @ -351,14 +325,12 @@ void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi) | ||||
|     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 END SPI1_MspDeInit 1 */ | ||||
|   } | ||||
|   else if(hspi->Instance==SPI3) | ||||
|   { | ||||
|     } else if(hspi->Instance == SPI3) { | ||||
|         /* USER CODE BEGIN SPI3_MspDeInit 0 */ | ||||
| 
 | ||||
|         /* USER CODE END SPI3_MspDeInit 0 */ | ||||
| @ -370,13 +342,12 @@ void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi) | ||||
|     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 */ | ||||
|     } | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -385,10 +356,8 @@ 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) | ||||
|   { | ||||
| 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 */ | ||||
| @ -398,7 +367,6 @@ void HAL_TIM_PWM_MspInit(TIM_HandleTypeDef* htim_pwm) | ||||
| 
 | ||||
|         /* USER CODE END TIM5_MspInit 1 */ | ||||
|     } | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -407,11 +375,9 @@ 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) | ||||
| { | ||||
| void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base) { | ||||
|     GPIO_InitTypeDef GPIO_InitStruct = {0}; | ||||
|   if(htim_base->Instance==TIM8) | ||||
|   { | ||||
|     if(htim_base->Instance == TIM8) { | ||||
|         /* USER CODE BEGIN TIM8_MspInit 0 */ | ||||
| 
 | ||||
|         /* USER CODE END TIM8_MspInit 0 */ | ||||
| @ -436,7 +402,6 @@ void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base) | ||||
| 
 | ||||
|         /* USER CODE END TIM8_MspInit 1 */ | ||||
|     } | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -445,10 +410,8 @@ 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) | ||||
|   { | ||||
| 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 */ | ||||
| @ -458,14 +421,11 @@ void HAL_TIM_OC_MspInit(TIM_HandleTypeDef* htim_oc) | ||||
| 
 | ||||
|         /* USER CODE END TIM15_MspInit 1 */ | ||||
|     } | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim) | ||||
| { | ||||
| void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim) { | ||||
|     GPIO_InitTypeDef GPIO_InitStruct = {0}; | ||||
|   if(htim->Instance==TIM5) | ||||
|   { | ||||
|     if(htim->Instance == TIM5) { | ||||
|         /* USER CODE BEGIN TIM5_MspPostInit 0 */ | ||||
| 
 | ||||
|         /* USER CODE END TIM5_MspPostInit 0 */ | ||||
| @ -483,9 +443,7 @@ void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim) | ||||
|         /* USER CODE BEGIN TIM5_MspPostInit 1 */ | ||||
| 
 | ||||
|         /* USER CODE END TIM5_MspPostInit 1 */ | ||||
|   } | ||||
|   else if(htim->Instance==TIM15) | ||||
|   { | ||||
|     } else if(htim->Instance == TIM15) { | ||||
|         /* USER CODE BEGIN TIM15_MspPostInit 0 */ | ||||
| 
 | ||||
|         /* USER CODE END TIM15_MspPostInit 0 */ | ||||
| @ -495,7 +453,7 @@ void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim) | ||||
|     PB13     ------> TIM15_CH1N | ||||
|     PB15     ------> TIM15_CH2  | ||||
|     */ | ||||
|     GPIO_InitStruct.Pin = RFID_OUT_Pin|RFID_PULL_Pin; | ||||
|         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; | ||||
| @ -506,7 +464,6 @@ void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim) | ||||
| 
 | ||||
|         /* USER CODE END TIM15_MspPostInit 1 */ | ||||
|     } | ||||
| 
 | ||||
| } | ||||
| /**
 | ||||
| * @brief TIM_PWM MSP De-Initialization | ||||
| @ -514,10 +471,8 @@ 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) | ||||
|   { | ||||
| 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 */ | ||||
| @ -527,7 +482,6 @@ void HAL_TIM_PWM_MspDeInit(TIM_HandleTypeDef* htim_pwm) | ||||
| 
 | ||||
|         /* USER CODE END TIM5_MspDeInit 1 */ | ||||
|     } | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -536,10 +490,8 @@ 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) | ||||
|   { | ||||
| 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 */ | ||||
| @ -557,7 +509,6 @@ void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* htim_base) | ||||
| 
 | ||||
|         /* USER CODE END TIM8_MspDeInit 1 */ | ||||
|     } | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -566,10 +517,8 @@ 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) | ||||
|   { | ||||
| 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 */ | ||||
| @ -579,7 +528,6 @@ void HAL_TIM_OC_MspDeInit(TIM_HandleTypeDef* htim_oc) | ||||
| 
 | ||||
|         /* USER CODE END TIM15_MspDeInit 1 */ | ||||
|     } | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -588,11 +536,9 @@ void HAL_TIM_OC_MspDeInit(TIM_HandleTypeDef* htim_oc) | ||||
| * @param huart: UART handle pointer | ||||
| * @retval None | ||||
| */ | ||||
| void HAL_UART_MspInit(UART_HandleTypeDef* huart) | ||||
| { | ||||
| void HAL_UART_MspInit(UART_HandleTypeDef* huart) { | ||||
|     GPIO_InitTypeDef GPIO_InitStruct = {0}; | ||||
|   if(huart->Instance==USART1) | ||||
|   { | ||||
|     if(huart->Instance == USART1) { | ||||
|         /* USER CODE BEGIN USART1_MspInit 0 */ | ||||
| 
 | ||||
|         /* USER CODE END USART1_MspInit 0 */ | ||||
| @ -604,7 +550,7 @@ void HAL_UART_MspInit(UART_HandleTypeDef* huart) | ||||
|     PA9     ------> USART1_TX | ||||
|     PA10     ------> USART1_RX  | ||||
|     */ | ||||
|     GPIO_InitStruct.Pin = GPIO_PIN_9|GPIO_PIN_10; | ||||
|         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; | ||||
| @ -615,7 +561,6 @@ void HAL_UART_MspInit(UART_HandleTypeDef* huart) | ||||
| 
 | ||||
|         /* USER CODE END USART1_MspInit 1 */ | ||||
|     } | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -624,10 +569,8 @@ 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) | ||||
|   { | ||||
| void HAL_UART_MspDeInit(UART_HandleTypeDef* huart) { | ||||
|     if(huart->Instance == USART1) { | ||||
|         /* USER CODE BEGIN USART1_MspDeInit 0 */ | ||||
| 
 | ||||
|         /* USER CODE END USART1_MspDeInit 0 */ | ||||
| @ -638,13 +581,12 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef* huart) | ||||
|     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 1 */ | ||||
|  | ||||
| @ -70,8 +70,7 @@ extern TIM_HandleTypeDef htim8; | ||||
| /**
 | ||||
|   * @brief This function handles Non maskable interrupt. | ||||
|   */ | ||||
| void NMI_Handler(void) | ||||
| { | ||||
| void NMI_Handler(void) { | ||||
|     /* USER CODE BEGIN NonMaskableInt_IRQn 0 */ | ||||
| 
 | ||||
|     /* USER CODE END NonMaskableInt_IRQn 0 */ | ||||
| @ -83,13 +82,11 @@ void NMI_Handler(void) | ||||
| /**
 | ||||
|   * @brief This function handles Hard fault interrupt. | ||||
|   */ | ||||
| void HardFault_Handler(void) | ||||
| { | ||||
| void HardFault_Handler(void) { | ||||
|     /* USER CODE BEGIN HardFault_IRQn 0 */ | ||||
| 
 | ||||
|     /* USER CODE END HardFault_IRQn 0 */ | ||||
|   while (1) | ||||
|   { | ||||
|     while(1) { | ||||
|         /* USER CODE BEGIN W1_HardFault_IRQn 0 */ | ||||
|         /* USER CODE END W1_HardFault_IRQn 0 */ | ||||
|     } | ||||
| @ -98,13 +95,11 @@ void HardFault_Handler(void) | ||||
| /**
 | ||||
|   * @brief This function handles Memory management fault. | ||||
|   */ | ||||
| void MemManage_Handler(void) | ||||
| { | ||||
| void MemManage_Handler(void) { | ||||
|     /* USER CODE BEGIN MemoryManagement_IRQn 0 */ | ||||
| 
 | ||||
|     /* USER CODE END MemoryManagement_IRQn 0 */ | ||||
|   while (1) | ||||
|   { | ||||
|     while(1) { | ||||
|         /* USER CODE BEGIN W1_MemoryManagement_IRQn 0 */ | ||||
|         /* USER CODE END W1_MemoryManagement_IRQn 0 */ | ||||
|     } | ||||
| @ -113,13 +108,11 @@ void MemManage_Handler(void) | ||||
| /**
 | ||||
|   * @brief This function handles Prefetch fault, memory access fault. | ||||
|   */ | ||||
| void BusFault_Handler(void) | ||||
| { | ||||
| void BusFault_Handler(void) { | ||||
|     /* USER CODE BEGIN BusFault_IRQn 0 */ | ||||
| 
 | ||||
|     /* USER CODE END BusFault_IRQn 0 */ | ||||
|   while (1) | ||||
|   { | ||||
|     while(1) { | ||||
|         /* USER CODE BEGIN W1_BusFault_IRQn 0 */ | ||||
|         /* USER CODE END W1_BusFault_IRQn 0 */ | ||||
|     } | ||||
| @ -128,13 +121,11 @@ void BusFault_Handler(void) | ||||
| /**
 | ||||
|   * @brief This function handles Undefined instruction or illegal state. | ||||
|   */ | ||||
| void UsageFault_Handler(void) | ||||
| { | ||||
| void UsageFault_Handler(void) { | ||||
|     /* USER CODE BEGIN UsageFault_IRQn 0 */ | ||||
| 
 | ||||
|     /* USER CODE END UsageFault_IRQn 0 */ | ||||
|   while (1) | ||||
|   { | ||||
|     while(1) { | ||||
|         /* USER CODE BEGIN W1_UsageFault_IRQn 0 */ | ||||
|         /* USER CODE END W1_UsageFault_IRQn 0 */ | ||||
|     } | ||||
| @ -143,8 +134,7 @@ void UsageFault_Handler(void) | ||||
| /**
 | ||||
|   * @brief This function handles Debug monitor. | ||||
|   */ | ||||
| void DebugMon_Handler(void) | ||||
| { | ||||
| void DebugMon_Handler(void) { | ||||
|     /* USER CODE BEGIN DebugMonitor_IRQn 0 */ | ||||
| 
 | ||||
|     /* USER CODE END DebugMonitor_IRQn 0 */ | ||||
| @ -156,18 +146,16 @@ void DebugMon_Handler(void) | ||||
| /**
 | ||||
|   * @brief This function handles System tick timer. | ||||
|   */ | ||||
| void SysTick_Handler(void) | ||||
| { | ||||
| 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) | ||||
|   { | ||||
| #if(INCLUDE_xTaskGetSchedulerState == 1) | ||||
|     if(xTaskGetSchedulerState() != taskSCHEDULER_NOT_STARTED) { | ||||
| #endif /* INCLUDE_xTaskGetSchedulerState */ | ||||
|         xPortSysTickHandler(); | ||||
| #if (INCLUDE_xTaskGetSchedulerState == 1 ) | ||||
| #if(INCLUDE_xTaskGetSchedulerState == 1) | ||||
|     } | ||||
| #endif /* INCLUDE_xTaskGetSchedulerState */ | ||||
|     /* USER CODE BEGIN SysTick_IRQn 1 */ | ||||
| @ -185,8 +173,7 @@ void SysTick_Handler(void) | ||||
| /**
 | ||||
|   * @brief This function handles EXTI line0 interrupt. | ||||
|   */ | ||||
| void EXTI0_IRQHandler(void) | ||||
| { | ||||
| void EXTI0_IRQHandler(void) { | ||||
|     /* USER CODE BEGIN EXTI0_IRQn 0 */ | ||||
| 
 | ||||
|     /* USER CODE END EXTI0_IRQn 0 */ | ||||
| @ -199,8 +186,7 @@ void EXTI0_IRQHandler(void) | ||||
| /**
 | ||||
|   * @brief This function handles EXTI line1 interrupt. | ||||
|   */ | ||||
| void EXTI1_IRQHandler(void) | ||||
| { | ||||
| void EXTI1_IRQHandler(void) { | ||||
|     /* USER CODE BEGIN EXTI1_IRQn 0 */ | ||||
| 
 | ||||
|     /* USER CODE END EXTI1_IRQn 0 */ | ||||
| @ -213,8 +199,7 @@ void EXTI1_IRQHandler(void) | ||||
| /**
 | ||||
|   * @brief This function handles EXTI line2 interrupt. | ||||
|   */ | ||||
| void EXTI2_IRQHandler(void) | ||||
| { | ||||
| void EXTI2_IRQHandler(void) { | ||||
|     /* USER CODE BEGIN EXTI2_IRQn 0 */ | ||||
| 
 | ||||
|     /* USER CODE END EXTI2_IRQn 0 */ | ||||
| @ -227,8 +212,7 @@ void EXTI2_IRQHandler(void) | ||||
| /**
 | ||||
|   * @brief This function handles EXTI line4 interrupt. | ||||
|   */ | ||||
| void EXTI4_IRQHandler(void) | ||||
| { | ||||
| void EXTI4_IRQHandler(void) { | ||||
|     /* USER CODE BEGIN EXTI4_IRQn 0 */ | ||||
| 
 | ||||
|     /* USER CODE END EXTI4_IRQn 0 */ | ||||
| @ -241,8 +225,7 @@ void EXTI4_IRQHandler(void) | ||||
| /**
 | ||||
|   * @brief This function handles EXTI line[9:5] interrupts. | ||||
|   */ | ||||
| void EXTI9_5_IRQHandler(void) | ||||
| { | ||||
| void EXTI9_5_IRQHandler(void) { | ||||
|     /* USER CODE BEGIN EXTI9_5_IRQn 0 */ | ||||
| 
 | ||||
|     /* USER CODE END EXTI9_5_IRQn 0 */ | ||||
| @ -254,29 +237,25 @@ void EXTI9_5_IRQHandler(void) | ||||
|     /* 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)) { | ||||
| 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) | ||||
| { | ||||
| 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) | ||||
|     { | ||||
|     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((htim8.Instance->CCMR1 & TIM_CCMR1_CC2S) != 0x00U) { | ||||
|                 /*
 | ||||
| #if (USE_HAL_TIM_REGISTER_CALLBACKS == 1) | ||||
|         htim->IC_CaptureCallback(htim); | ||||
| #else | ||||
| @ -288,12 +267,11 @@ void TIM8_CC_IRQHandler(void) | ||||
|                 } | ||||
|             } | ||||
|             /* Output compare event */ | ||||
|       else | ||||
|       { | ||||
|             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); | ||||
| @ -307,7 +285,6 @@ void TIM8_CC_IRQHandler(void) | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
|     /* USER CODE END TIM8_CC_IRQn 0 */ | ||||
|     // HAL_TIM_IRQHandler(&htim8);
 | ||||
|     /* USER CODE BEGIN TIM8_CC_IRQn 1 */ | ||||
| @ -318,8 +295,7 @@ void TIM8_CC_IRQHandler(void) | ||||
| /**
 | ||||
|   * @brief This function handles USB OTG FS global interrupt. | ||||
|   */ | ||||
| void OTG_FS_IRQHandler(void) | ||||
| { | ||||
| void OTG_FS_IRQHandler(void) { | ||||
|     /* USER CODE BEGIN OTG_FS_IRQn 0 */ | ||||
| 
 | ||||
|     /* USER CODE END OTG_FS_IRQn 0 */ | ||||
|  | ||||
| @ -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,12 +188,11 @@ | ||||
|   * @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 */ | ||||
| @ -253,25 +263,20 @@ void SystemInit(void) | ||||
|   * @param  None | ||||
|   * @retval None | ||||
|   */ | ||||
| void SystemCoreClockUpdate(void) | ||||
| { | ||||
| 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 */ | ||||
|     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 */ | ||||
|     } 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) | ||||
|   { | ||||
|     switch(RCC->CFGR & RCC_CFGR_SWS) { | ||||
|     case 0x00: /* MSI used as system clock source */ | ||||
|         SystemCoreClock = msirange; | ||||
|         break; | ||||
| @ -289,10 +294,9 @@ void SystemCoreClockUpdate(void) | ||||
|          SYSCLK = PLL_VCO / PLLR | ||||
|          */ | ||||
|         pllsource = (RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC); | ||||
|       pllm = ((RCC->PLLCFGR & RCC_PLLCFGR_PLLM) >> 4U) + 1U ; | ||||
|         pllm = ((RCC->PLLCFGR & RCC_PLLCFGR_PLLM) >> 4U) + 1U; | ||||
| 
 | ||||
|       switch (pllsource) | ||||
|       { | ||||
|         switch(pllsource) { | ||||
|         case 0x02: /* HSI used as PLL clock source */ | ||||
|             pllvco = (HSI_VALUE / pllm); | ||||
|             break; | ||||
| @ -307,7 +311,7 @@ void SystemCoreClockUpdate(void) | ||||
|         } | ||||
|         pllvco = pllvco * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 8U); | ||||
|         pllr = (((RCC->PLLCFGR & RCC_PLLCFGR_PLLR) >> 25U) + 1U) * 2U; | ||||
|       SystemCoreClock = pllvco/pllr; | ||||
|         SystemCoreClock = pllvco / pllr; | ||||
|         break; | ||||
| 
 | ||||
|     default: | ||||
| @ -321,7 +325,6 @@ void SystemCoreClockUpdate(void) | ||||
|     SystemCoreClock >>= tmp; | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| /**
 | ||||
|   * @} | ||||
|   */ | ||||
|  | ||||
| @ -63,27 +63,22 @@ extern USBD_DescriptorsTypeDef FS_Desc; | ||||
|   * Init USB device Library, add supported class and start the library | ||||
|   * @retval None | ||||
|   */ | ||||
| void MX_USB_DEVICE_Init(void) | ||||
| { | ||||
| void MX_USB_DEVICE_Init(void) { | ||||
|     /* USER CODE BEGIN 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) | ||||
|   { | ||||
|     if(USBD_Init(&hUsbDeviceFS, &FS_Desc, DEVICE_FS) != USBD_OK) { | ||||
|         Error_Handler(); | ||||
|     } | ||||
|   if (USBD_RegisterClass(&hUsbDeviceFS, &USBD_CDC) != USBD_OK) | ||||
|   { | ||||
|     if(USBD_RegisterClass(&hUsbDeviceFS, &USBD_CDC) != USBD_OK) { | ||||
|         Error_Handler(); | ||||
|     } | ||||
|   if (USBD_CDC_RegisterInterface(&hUsbDeviceFS, &USBD_Interface_fops_FS) != USBD_OK) | ||||
|   { | ||||
|     if(USBD_CDC_RegisterInterface(&hUsbDeviceFS, &USBD_Interface_fops_FS) != USBD_OK) { | ||||
|         Error_Handler(); | ||||
|     } | ||||
|   if (USBD_Start(&hUsbDeviceFS) != USBD_OK) | ||||
|   { | ||||
|     if(USBD_Start(&hUsbDeviceFS) != USBD_OK) { | ||||
|         Error_Handler(); | ||||
|     } | ||||
|     /* USER CODE BEGIN USB_DEVICE_Init_PostTreatment */ | ||||
|  | ||||
| @ -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,21 +139,17 @@ static int8_t CDC_Receive_FS(uint8_t* pbuf, uint32_t *Len); | ||||
|   * @} | ||||
|   */ | ||||
| 
 | ||||
| USBD_CDC_ItfTypeDef USBD_Interface_fops_FS = | ||||
| { | ||||
|   CDC_Init_FS, | ||||
| USBD_CDC_ItfTypeDef USBD_Interface_fops_FS = {CDC_Init_FS, | ||||
|                                               CDC_DeInit_FS, | ||||
|                                               CDC_Control_FS, | ||||
|   CDC_Receive_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) | ||||
| { | ||||
| static int8_t CDC_Init_FS(void) { | ||||
|     /* USER CODE BEGIN 3 */ | ||||
|     /* Set Application Buffers */ | ||||
|     USBD_CDC_SetTxBuffer(&hUsbDeviceFS, UserTxBufferFS, 0); | ||||
| @ -166,8 +162,7 @@ static int8_t CDC_Init_FS(void) | ||||
|   * @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) | ||||
| { | ||||
| static int8_t CDC_DeInit_FS(void) { | ||||
|     /* USER CODE BEGIN 4 */ | ||||
|     return (USBD_OK); | ||||
|     /* USER CODE END 4 */ | ||||
| @ -180,11 +175,9 @@ 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) | ||||
| { | ||||
| static int8_t CDC_Control_FS(uint8_t cmd, uint8_t* pbuf, uint16_t length) { | ||||
|     /* USER CODE BEGIN 5 */ | ||||
|   switch(cmd) | ||||
|   { | ||||
|     switch(cmd) { | ||||
|     case CDC_SEND_ENCAPSULATED_COMMAND: | ||||
| 
 | ||||
|         break; | ||||
| @ -260,8 +253,7 @@ 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) | ||||
| { | ||||
| 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); | ||||
| @ -280,12 +272,11 @@ 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 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){ | ||||
|     USBD_CDC_HandleTypeDef* hcdc = (USBD_CDC_HandleTypeDef*)hUsbDeviceFS.pClassData; | ||||
|     if(hcdc->TxState != 0) { | ||||
|         return USBD_BUSY; | ||||
|     } | ||||
|     USBD_CDC_SetTxBuffer(&hUsbDeviceFS, Buf, Len); | ||||
|  | ||||
| @ -47,7 +47,7 @@ void Error_Handler(void); | ||||
| /* USER CODE END 0 */ | ||||
| 
 | ||||
| /* Exported function prototypes ----------------------------------------------*/ | ||||
| extern USBD_StatusTypeDef USBD_LL_BatteryCharging(USBD_HandleTypeDef *pdev); | ||||
| extern USBD_StatusTypeDef USBD_LL_BatteryCharging(USBD_HandleTypeDef* pdev); | ||||
| 
 | ||||
| /* USER CODE BEGIN PFP */ | ||||
| /* Private function prototypes -----------------------------------------------*/ | ||||
| @ -67,11 +67,9 @@ extern void SystemClock_Config(void); | ||||
| *******************************************************************************/ | ||||
| /* MSP Init */ | ||||
| 
 | ||||
| void HAL_PCD_MspInit(PCD_HandleTypeDef* pcdHandle) | ||||
| { | ||||
| void HAL_PCD_MspInit(PCD_HandleTypeDef* pcdHandle) { | ||||
|     GPIO_InitTypeDef GPIO_InitStruct = {0}; | ||||
|   if(pcdHandle->Instance==USB_OTG_FS) | ||||
|   { | ||||
|     if(pcdHandle->Instance == USB_OTG_FS) { | ||||
|         /* USER CODE BEGIN USB_OTG_FS_MspInit 0 */ | ||||
| 
 | ||||
|         /* USER CODE END USB_OTG_FS_MspInit 0 */ | ||||
| @ -81,7 +79,7 @@ void HAL_PCD_MspInit(PCD_HandleTypeDef* pcdHandle) | ||||
|     PA11     ------> USB_OTG_FS_DM | ||||
|     PA12     ------> USB_OTG_FS_DP  | ||||
|     */ | ||||
|     GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_12; | ||||
|         GPIO_InitStruct.Pin = 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; | ||||
| @ -92,14 +90,11 @@ void HAL_PCD_MspInit(PCD_HandleTypeDef* pcdHandle) | ||||
|         __HAL_RCC_USB_OTG_FS_CLK_ENABLE(); | ||||
| 
 | ||||
|         /* Enable VDDUSB */ | ||||
|     if(__HAL_RCC_PWR_IS_CLK_DISABLED()) | ||||
|     { | ||||
|         if(__HAL_RCC_PWR_IS_CLK_DISABLED()) { | ||||
|             __HAL_RCC_PWR_CLK_ENABLE(); | ||||
|             HAL_PWREx_EnableVddUSB(); | ||||
|             __HAL_RCC_PWR_CLK_DISABLE(); | ||||
|     } | ||||
|     else | ||||
|     { | ||||
|         } else { | ||||
|             HAL_PWREx_EnableVddUSB(); | ||||
|         } | ||||
| 
 | ||||
| @ -112,10 +107,8 @@ void HAL_PCD_MspInit(PCD_HandleTypeDef* pcdHandle) | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void HAL_PCD_MspDeInit(PCD_HandleTypeDef* pcdHandle) | ||||
| { | ||||
|   if(pcdHandle->Instance==USB_OTG_FS) | ||||
|   { | ||||
| void HAL_PCD_MspDeInit(PCD_HandleTypeDef* pcdHandle) { | ||||
|     if(pcdHandle->Instance == USB_OTG_FS) { | ||||
|         /* USER CODE BEGIN USB_OTG_FS_MspDeInit 0 */ | ||||
| 
 | ||||
|         /* USER CODE END USB_OTG_FS_MspDeInit 0 */ | ||||
| @ -126,17 +119,14 @@ void HAL_PCD_MspDeInit(PCD_HandleTypeDef* pcdHandle) | ||||
|     PA11     ------> USB_OTG_FS_DM | ||||
|     PA12     ------> USB_OTG_FS_DP  | ||||
|     */ | ||||
|     HAL_GPIO_DeInit(GPIOA, GPIO_PIN_11|GPIO_PIN_12); | ||||
|         HAL_GPIO_DeInit(GPIOA, GPIO_PIN_11 | GPIO_PIN_12); | ||||
| 
 | ||||
|         /* Disable VDDUSB */ | ||||
|     if(__HAL_RCC_PWR_IS_CLK_DISABLED()) | ||||
|     { | ||||
|         if(__HAL_RCC_PWR_IS_CLK_DISABLED()) { | ||||
|             __HAL_RCC_PWR_CLK_ENABLE(); | ||||
|             HAL_PWREx_DisableVddUSB(); | ||||
|             __HAL_RCC_PWR_CLK_DISABLE(); | ||||
|     } | ||||
|     else | ||||
|     { | ||||
|         } else { | ||||
|             HAL_PWREx_DisableVddUSB(); | ||||
|         } | ||||
| 
 | ||||
| @ -154,13 +144,13 @@ void HAL_PCD_MspDeInit(PCD_HandleTypeDef* pcdHandle) | ||||
|   * @param  hpcd: PCD handle | ||||
|   * @retval None | ||||
|   */ | ||||
| #if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) | ||||
| static void PCD_SetupStageCallback(PCD_HandleTypeDef *hpcd) | ||||
| #if(USE_HAL_PCD_REGISTER_CALLBACKS == 1U) | ||||
| static void PCD_SetupStageCallback(PCD_HandleTypeDef* hpcd) | ||||
| #else | ||||
| void HAL_PCD_SetupStageCallback(PCD_HandleTypeDef *hpcd) | ||||
| void HAL_PCD_SetupStageCallback(PCD_HandleTypeDef* hpcd) | ||||
| #endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ | ||||
| { | ||||
|   USBD_LL_SetupStage((USBD_HandleTypeDef*)hpcd->pData, (uint8_t *)hpcd->Setup); | ||||
|     USBD_LL_SetupStage((USBD_HandleTypeDef*)hpcd->pData, (uint8_t*)hpcd->Setup); | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -169,10 +159,10 @@ void HAL_PCD_SetupStageCallback(PCD_HandleTypeDef *hpcd) | ||||
|   * @param  epnum: Endpoint number | ||||
|   * @retval None | ||||
|   */ | ||||
| #if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) | ||||
| static void PCD_DataOutStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) | ||||
| #if(USE_HAL_PCD_REGISTER_CALLBACKS == 1U) | ||||
| static void PCD_DataOutStageCallback(PCD_HandleTypeDef* hpcd, uint8_t epnum) | ||||
| #else | ||||
| void HAL_PCD_DataOutStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) | ||||
| void HAL_PCD_DataOutStageCallback(PCD_HandleTypeDef* hpcd, uint8_t epnum) | ||||
| #endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ | ||||
| { | ||||
|     USBD_LL_DataOutStage((USBD_HandleTypeDef*)hpcd->pData, epnum, hpcd->OUT_ep[epnum].xfer_buff); | ||||
| @ -184,10 +174,10 @@ void HAL_PCD_DataOutStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) | ||||
|   * @param  epnum: Endpoint number | ||||
|   * @retval None | ||||
|   */ | ||||
| #if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) | ||||
| static void PCD_DataInStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) | ||||
| #if(USE_HAL_PCD_REGISTER_CALLBACKS == 1U) | ||||
| static void PCD_DataInStageCallback(PCD_HandleTypeDef* hpcd, uint8_t epnum) | ||||
| #else | ||||
| void HAL_PCD_DataInStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) | ||||
| void HAL_PCD_DataInStageCallback(PCD_HandleTypeDef* hpcd, uint8_t epnum) | ||||
| #endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ | ||||
| { | ||||
|     USBD_LL_DataInStage((USBD_HandleTypeDef*)hpcd->pData, epnum, hpcd->IN_ep[epnum].xfer_buff); | ||||
| @ -198,10 +188,10 @@ void HAL_PCD_DataInStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) | ||||
|   * @param  hpcd: PCD handle | ||||
|   * @retval None | ||||
|   */ | ||||
| #if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) | ||||
| static void PCD_SOFCallback(PCD_HandleTypeDef *hpcd) | ||||
| #if(USE_HAL_PCD_REGISTER_CALLBACKS == 1U) | ||||
| static void PCD_SOFCallback(PCD_HandleTypeDef* hpcd) | ||||
| #else | ||||
| void HAL_PCD_SOFCallback(PCD_HandleTypeDef *hpcd) | ||||
| void HAL_PCD_SOFCallback(PCD_HandleTypeDef* hpcd) | ||||
| #endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ | ||||
| { | ||||
|     USBD_LL_SOF((USBD_HandleTypeDef*)hpcd->pData); | ||||
| @ -212,16 +202,15 @@ void HAL_PCD_SOFCallback(PCD_HandleTypeDef *hpcd) | ||||
|   * @param  hpcd: PCD handle | ||||
|   * @retval None | ||||
|   */ | ||||
| #if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) | ||||
| static void PCD_ResetCallback(PCD_HandleTypeDef *hpcd) | ||||
| #if(USE_HAL_PCD_REGISTER_CALLBACKS == 1U) | ||||
| static void PCD_ResetCallback(PCD_HandleTypeDef* hpcd) | ||||
| #else | ||||
| void HAL_PCD_ResetCallback(PCD_HandleTypeDef *hpcd) | ||||
| void HAL_PCD_ResetCallback(PCD_HandleTypeDef* hpcd) | ||||
| #endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ | ||||
| { | ||||
|     USBD_SpeedTypeDef speed = USBD_SPEED_FULL; | ||||
| 
 | ||||
|   if ( hpcd->Init.speed != PCD_SPEED_FULL) | ||||
|   { | ||||
|     if(hpcd->Init.speed != PCD_SPEED_FULL) { | ||||
|         Error_Handler(); | ||||
|     } | ||||
|     /* Set Speed. */ | ||||
| @ -237,10 +226,10 @@ void HAL_PCD_ResetCallback(PCD_HandleTypeDef *hpcd) | ||||
|   * @param  hpcd: PCD handle | ||||
|   * @retval None | ||||
|   */ | ||||
| #if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) | ||||
| static void PCD_SuspendCallback(PCD_HandleTypeDef *hpcd) | ||||
| #if(USE_HAL_PCD_REGISTER_CALLBACKS == 1U) | ||||
| static void PCD_SuspendCallback(PCD_HandleTypeDef* hpcd) | ||||
| #else | ||||
| void HAL_PCD_SuspendCallback(PCD_HandleTypeDef *hpcd) | ||||
| void HAL_PCD_SuspendCallback(PCD_HandleTypeDef* hpcd) | ||||
| #endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ | ||||
| { | ||||
|     __HAL_PCD_GATE_PHYCLOCK(hpcd); | ||||
| @ -248,8 +237,7 @@ void HAL_PCD_SuspendCallback(PCD_HandleTypeDef *hpcd) | ||||
|     USBD_LL_Suspend((USBD_HandleTypeDef*)hpcd->pData); | ||||
|     /* Enter in STOP mode. */ | ||||
|     /* USER CODE BEGIN 2 */ | ||||
|   if (hpcd->Init.low_power_enable) | ||||
|   { | ||||
|     if(hpcd->Init.low_power_enable) { | ||||
|         /* Set SLEEPDEEP bit and SleepOnExit of Cortex System Control Register. */ | ||||
|         SCB->SCR |= (uint32_t)((uint32_t)(SCB_SCR_SLEEPDEEP_Msk | SCB_SCR_SLEEPONEXIT_Msk)); | ||||
|     } | ||||
| @ -262,19 +250,18 @@ void HAL_PCD_SuspendCallback(PCD_HandleTypeDef *hpcd) | ||||
|   * @param  hpcd: PCD handle | ||||
|   * @retval None | ||||
|   */ | ||||
| #if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) | ||||
| static void PCD_ResumeCallback(PCD_HandleTypeDef *hpcd) | ||||
| #if(USE_HAL_PCD_REGISTER_CALLBACKS == 1U) | ||||
| static void PCD_ResumeCallback(PCD_HandleTypeDef* hpcd) | ||||
| #else | ||||
| void HAL_PCD_ResumeCallback(PCD_HandleTypeDef *hpcd) | ||||
| void HAL_PCD_ResumeCallback(PCD_HandleTypeDef* hpcd) | ||||
| #endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ | ||||
| { | ||||
|     __HAL_PCD_UNGATE_PHYCLOCK(hpcd); | ||||
| 
 | ||||
|     /* USER CODE BEGIN 3 */ | ||||
|   if (hpcd->Init.low_power_enable) | ||||
|   { | ||||
|     if(hpcd->Init.low_power_enable) { | ||||
|         /* Reset SLEEPDEEP bit of Cortex System Control Register. */ | ||||
|     SCB->SCR &= (uint32_t)~((uint32_t)(SCB_SCR_SLEEPDEEP_Msk | SCB_SCR_SLEEPONEXIT_Msk)); | ||||
|         SCB->SCR &= (uint32_t) ~((uint32_t)(SCB_SCR_SLEEPDEEP_Msk | SCB_SCR_SLEEPONEXIT_Msk)); | ||||
|         SystemClockConfig_Resume(); | ||||
|     } | ||||
|     /* USER CODE END 3 */ | ||||
| @ -287,10 +274,10 @@ void HAL_PCD_ResumeCallback(PCD_HandleTypeDef *hpcd) | ||||
|   * @param  epnum: Endpoint number | ||||
|   * @retval None | ||||
|   */ | ||||
| #if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) | ||||
| static void PCD_ISOOUTIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) | ||||
| #if(USE_HAL_PCD_REGISTER_CALLBACKS == 1U) | ||||
| static void PCD_ISOOUTIncompleteCallback(PCD_HandleTypeDef* hpcd, uint8_t epnum) | ||||
| #else | ||||
| void HAL_PCD_ISOOUTIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) | ||||
| void HAL_PCD_ISOOUTIncompleteCallback(PCD_HandleTypeDef* hpcd, uint8_t epnum) | ||||
| #endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ | ||||
| { | ||||
|     USBD_LL_IsoOUTIncomplete((USBD_HandleTypeDef*)hpcd->pData, epnum); | ||||
| @ -302,10 +289,10 @@ void HAL_PCD_ISOOUTIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) | ||||
|   * @param  epnum: Endpoint number | ||||
|   * @retval None | ||||
|   */ | ||||
| #if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) | ||||
| static void PCD_ISOINIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) | ||||
| #if(USE_HAL_PCD_REGISTER_CALLBACKS == 1U) | ||||
| static void PCD_ISOINIncompleteCallback(PCD_HandleTypeDef* hpcd, uint8_t epnum) | ||||
| #else | ||||
| void HAL_PCD_ISOINIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) | ||||
| void HAL_PCD_ISOINIncompleteCallback(PCD_HandleTypeDef* hpcd, uint8_t epnum) | ||||
| #endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ | ||||
| { | ||||
|     USBD_LL_IsoINIncomplete((USBD_HandleTypeDef*)hpcd->pData, epnum); | ||||
| @ -316,10 +303,10 @@ void HAL_PCD_ISOINIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) | ||||
|   * @param  hpcd: PCD handle | ||||
|   * @retval None | ||||
|   */ | ||||
| #if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) | ||||
| static void PCD_ConnectCallback(PCD_HandleTypeDef *hpcd) | ||||
| #if(USE_HAL_PCD_REGISTER_CALLBACKS == 1U) | ||||
| static void PCD_ConnectCallback(PCD_HandleTypeDef* hpcd) | ||||
| #else | ||||
| void HAL_PCD_ConnectCallback(PCD_HandleTypeDef *hpcd) | ||||
| void HAL_PCD_ConnectCallback(PCD_HandleTypeDef* hpcd) | ||||
| #endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ | ||||
| { | ||||
|     // TODO send UsbConnect event to FURI
 | ||||
| @ -332,10 +319,10 @@ void HAL_PCD_ConnectCallback(PCD_HandleTypeDef *hpcd) | ||||
|   * @param  hpcd: PCD handle | ||||
|   * @retval None | ||||
|   */ | ||||
| #if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) | ||||
| static void PCD_DisconnectCallback(PCD_HandleTypeDef *hpcd) | ||||
| #if(USE_HAL_PCD_REGISTER_CALLBACKS == 1U) | ||||
| static void PCD_DisconnectCallback(PCD_HandleTypeDef* hpcd) | ||||
| #else | ||||
| void HAL_PCD_DisconnectCallback(PCD_HandleTypeDef *hpcd) | ||||
| void HAL_PCD_DisconnectCallback(PCD_HandleTypeDef* hpcd) | ||||
| #endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ | ||||
| { | ||||
|     // TODO send UsbDisconnect event to FURI
 | ||||
| @ -352,10 +339,9 @@ void HAL_PCD_DisconnectCallback(PCD_HandleTypeDef *hpcd) | ||||
|   * @param  pdev: Device handle | ||||
|   * @retval USBD status | ||||
|   */ | ||||
| USBD_StatusTypeDef USBD_LL_Init(USBD_HandleTypeDef *pdev) | ||||
| { | ||||
| USBD_StatusTypeDef USBD_LL_Init(USBD_HandleTypeDef* pdev) { | ||||
|     /* Init USB Ip. */ | ||||
|   if (pdev->id == DEVICE_FS) { | ||||
|     if(pdev->id == DEVICE_FS) { | ||||
|         /* Enable USB power on Pwrctrl CR2 register. */ | ||||
|         /* Link the driver to the stack. */ | ||||
|         hpcd_USB_OTG_FS.pData = pdev; | ||||
| @ -371,20 +357,21 @@ USBD_StatusTypeDef USBD_LL_Init(USBD_HandleTypeDef *pdev) | ||||
|         hpcd_USB_OTG_FS.Init.battery_charging_enable = DISABLE; | ||||
|         hpcd_USB_OTG_FS.Init.use_dedicated_ep1 = DISABLE; | ||||
|         hpcd_USB_OTG_FS.Init.vbus_sensing_enable = DISABLE; | ||||
|   if (HAL_PCD_Init(&hpcd_USB_OTG_FS) != HAL_OK) | ||||
|   { | ||||
|     Error_Handler( ); | ||||
|         if(HAL_PCD_Init(&hpcd_USB_OTG_FS) != HAL_OK) { | ||||
|             Error_Handler(); | ||||
|         } | ||||
| 
 | ||||
| #if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) | ||||
| #if(USE_HAL_PCD_REGISTER_CALLBACKS == 1U) | ||||
|         /* Register USB PCD CallBacks */ | ||||
|         HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_SOF_CB_ID, PCD_SOFCallback); | ||||
|   HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_SETUPSTAGE_CB_ID, PCD_SetupStageCallback); | ||||
|         HAL_PCD_RegisterCallback( | ||||
|             &hpcd_USB_OTG_FS, HAL_PCD_SETUPSTAGE_CB_ID, PCD_SetupStageCallback); | ||||
|         HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_RESET_CB_ID, PCD_ResetCallback); | ||||
|         HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_SUSPEND_CB_ID, PCD_SuspendCallback); | ||||
|         HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_RESUME_CB_ID, PCD_ResumeCallback); | ||||
|         HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_CONNECT_CB_ID, PCD_ConnectCallback); | ||||
|   HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_DISCONNECT_CB_ID, PCD_DisconnectCallback); | ||||
|         HAL_PCD_RegisterCallback( | ||||
|             &hpcd_USB_OTG_FS, HAL_PCD_DISCONNECT_CB_ID, PCD_DisconnectCallback); | ||||
| 
 | ||||
|         HAL_PCD_RegisterDataOutStageCallback(&hpcd_USB_OTG_FS, PCD_DataOutStageCallback); | ||||
|         HAL_PCD_RegisterDataInStageCallback(&hpcd_USB_OTG_FS, PCD_DataInStageCallback); | ||||
| @ -403,27 +390,26 @@ USBD_StatusTypeDef USBD_LL_Init(USBD_HandleTypeDef *pdev) | ||||
|   * @param  pdev: Device handle | ||||
|   * @retval USBD status | ||||
|   */ | ||||
| USBD_StatusTypeDef USBD_LL_DeInit(USBD_HandleTypeDef *pdev) | ||||
| { | ||||
| USBD_StatusTypeDef USBD_LL_DeInit(USBD_HandleTypeDef* pdev) { | ||||
|     HAL_StatusTypeDef hal_status = HAL_OK; | ||||
|     USBD_StatusTypeDef usb_status = USBD_OK; | ||||
| 
 | ||||
|     hal_status = HAL_PCD_DeInit(pdev->pData); | ||||
| 
 | ||||
|   switch (hal_status) { | ||||
|     case HAL_OK : | ||||
|     switch(hal_status) { | ||||
|     case HAL_OK: | ||||
|         usb_status = USBD_OK; | ||||
|         break; | ||||
|     case HAL_ERROR : | ||||
|     case HAL_ERROR: | ||||
|         usb_status = USBD_FAIL; | ||||
|         break; | ||||
|     case HAL_BUSY : | ||||
|     case HAL_BUSY: | ||||
|         usb_status = USBD_BUSY; | ||||
|         break; | ||||
|     case HAL_TIMEOUT : | ||||
|     case HAL_TIMEOUT: | ||||
|         usb_status = USBD_FAIL; | ||||
|         break; | ||||
|     default : | ||||
|     default: | ||||
|         usb_status = USBD_FAIL; | ||||
|         break; | ||||
|     } | ||||
| @ -435,27 +421,26 @@ USBD_StatusTypeDef USBD_LL_DeInit(USBD_HandleTypeDef *pdev) | ||||
|   * @param  pdev: Device handle | ||||
|   * @retval USBD status | ||||
|   */ | ||||
| USBD_StatusTypeDef USBD_LL_Start(USBD_HandleTypeDef *pdev) | ||||
| { | ||||
| USBD_StatusTypeDef USBD_LL_Start(USBD_HandleTypeDef* pdev) { | ||||
|     HAL_StatusTypeDef hal_status = HAL_OK; | ||||
|     USBD_StatusTypeDef usb_status = USBD_OK; | ||||
| 
 | ||||
|     hal_status = HAL_PCD_Start(pdev->pData); | ||||
| 
 | ||||
|   switch (hal_status) { | ||||
|     case HAL_OK : | ||||
|     switch(hal_status) { | ||||
|     case HAL_OK: | ||||
|         usb_status = USBD_OK; | ||||
|         break; | ||||
|     case HAL_ERROR : | ||||
|     case HAL_ERROR: | ||||
|         usb_status = USBD_FAIL; | ||||
|         break; | ||||
|     case HAL_BUSY : | ||||
|     case HAL_BUSY: | ||||
|         usb_status = USBD_BUSY; | ||||
|         break; | ||||
|     case HAL_TIMEOUT : | ||||
|     case HAL_TIMEOUT: | ||||
|         usb_status = USBD_FAIL; | ||||
|         break; | ||||
|     default : | ||||
|     default: | ||||
|         usb_status = USBD_FAIL; | ||||
|         break; | ||||
|     } | ||||
| @ -467,27 +452,26 @@ USBD_StatusTypeDef USBD_LL_Start(USBD_HandleTypeDef *pdev) | ||||
|   * @param  pdev: Device handle | ||||
|   * @retval USBD status | ||||
|   */ | ||||
| USBD_StatusTypeDef USBD_LL_Stop(USBD_HandleTypeDef *pdev) | ||||
| { | ||||
| USBD_StatusTypeDef USBD_LL_Stop(USBD_HandleTypeDef* pdev) { | ||||
|     HAL_StatusTypeDef hal_status = HAL_OK; | ||||
|     USBD_StatusTypeDef usb_status = USBD_OK; | ||||
| 
 | ||||
|     hal_status = HAL_PCD_Stop(pdev->pData); | ||||
| 
 | ||||
|   switch (hal_status) { | ||||
|     case HAL_OK : | ||||
|     switch(hal_status) { | ||||
|     case HAL_OK: | ||||
|         usb_status = USBD_OK; | ||||
|         break; | ||||
|     case HAL_ERROR : | ||||
|     case HAL_ERROR: | ||||
|         usb_status = USBD_FAIL; | ||||
|         break; | ||||
|     case HAL_BUSY : | ||||
|     case HAL_BUSY: | ||||
|         usb_status = USBD_BUSY; | ||||
|         break; | ||||
|     case HAL_TIMEOUT : | ||||
|     case HAL_TIMEOUT: | ||||
|         usb_status = USBD_FAIL; | ||||
|         break; | ||||
|     default : | ||||
|     default: | ||||
|         usb_status = USBD_FAIL; | ||||
|         break; | ||||
|     } | ||||
| @ -502,27 +486,27 @@ USBD_StatusTypeDef USBD_LL_Stop(USBD_HandleTypeDef *pdev) | ||||
|   * @param  ep_mps: Endpoint max packet size | ||||
|   * @retval USBD status | ||||
|   */ | ||||
| USBD_StatusTypeDef USBD_LL_OpenEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr, uint8_t ep_type, uint16_t ep_mps) | ||||
| { | ||||
| USBD_StatusTypeDef | ||||
| USBD_LL_OpenEP(USBD_HandleTypeDef* pdev, uint8_t ep_addr, uint8_t ep_type, uint16_t ep_mps) { | ||||
|     HAL_StatusTypeDef hal_status = HAL_OK; | ||||
|     USBD_StatusTypeDef usb_status = USBD_OK; | ||||
| 
 | ||||
|     hal_status = HAL_PCD_EP_Open(pdev->pData, ep_addr, ep_mps, ep_type); | ||||
| 
 | ||||
|   switch (hal_status) { | ||||
|     case HAL_OK : | ||||
|     switch(hal_status) { | ||||
|     case HAL_OK: | ||||
|         usb_status = USBD_OK; | ||||
|         break; | ||||
|     case HAL_ERROR : | ||||
|     case HAL_ERROR: | ||||
|         usb_status = USBD_FAIL; | ||||
|         break; | ||||
|     case HAL_BUSY : | ||||
|     case HAL_BUSY: | ||||
|         usb_status = USBD_BUSY; | ||||
|         break; | ||||
|     case HAL_TIMEOUT : | ||||
|     case HAL_TIMEOUT: | ||||
|         usb_status = USBD_FAIL; | ||||
|         break; | ||||
|     default : | ||||
|     default: | ||||
|         usb_status = USBD_FAIL; | ||||
|         break; | ||||
|     } | ||||
| @ -535,27 +519,26 @@ USBD_StatusTypeDef USBD_LL_OpenEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr, uin | ||||
|   * @param  ep_addr: Endpoint number | ||||
|   * @retval USBD status | ||||
|   */ | ||||
| USBD_StatusTypeDef USBD_LL_CloseEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) | ||||
| { | ||||
| USBD_StatusTypeDef USBD_LL_CloseEP(USBD_HandleTypeDef* pdev, uint8_t ep_addr) { | ||||
|     HAL_StatusTypeDef hal_status = HAL_OK; | ||||
|     USBD_StatusTypeDef usb_status = USBD_OK; | ||||
| 
 | ||||
|     hal_status = HAL_PCD_EP_Close(pdev->pData, ep_addr); | ||||
| 
 | ||||
|   switch (hal_status) { | ||||
|     case HAL_OK : | ||||
|     switch(hal_status) { | ||||
|     case HAL_OK: | ||||
|         usb_status = USBD_OK; | ||||
|         break; | ||||
|     case HAL_ERROR : | ||||
|     case HAL_ERROR: | ||||
|         usb_status = USBD_FAIL; | ||||
|         break; | ||||
|     case HAL_BUSY : | ||||
|     case HAL_BUSY: | ||||
|         usb_status = USBD_BUSY; | ||||
|         break; | ||||
|     case HAL_TIMEOUT : | ||||
|     case HAL_TIMEOUT: | ||||
|         usb_status = USBD_FAIL; | ||||
|         break; | ||||
|     default : | ||||
|     default: | ||||
|         usb_status = USBD_FAIL; | ||||
|         break; | ||||
|     } | ||||
| @ -568,27 +551,26 @@ USBD_StatusTypeDef USBD_LL_CloseEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) | ||||
|   * @param  ep_addr: Endpoint number | ||||
|   * @retval USBD status | ||||
|   */ | ||||
| USBD_StatusTypeDef USBD_LL_FlushEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) | ||||
| { | ||||
| USBD_StatusTypeDef USBD_LL_FlushEP(USBD_HandleTypeDef* pdev, uint8_t ep_addr) { | ||||
|     HAL_StatusTypeDef hal_status = HAL_OK; | ||||
|     USBD_StatusTypeDef usb_status = USBD_OK; | ||||
| 
 | ||||
|     hal_status = HAL_PCD_EP_Flush(pdev->pData, ep_addr); | ||||
| 
 | ||||
|   switch (hal_status) { | ||||
|     case HAL_OK : | ||||
|     switch(hal_status) { | ||||
|     case HAL_OK: | ||||
|         usb_status = USBD_OK; | ||||
|         break; | ||||
|     case HAL_ERROR : | ||||
|     case HAL_ERROR: | ||||
|         usb_status = USBD_FAIL; | ||||
|         break; | ||||
|     case HAL_BUSY : | ||||
|     case HAL_BUSY: | ||||
|         usb_status = USBD_BUSY; | ||||
|         break; | ||||
|     case HAL_TIMEOUT : | ||||
|     case HAL_TIMEOUT: | ||||
|         usb_status = USBD_FAIL; | ||||
|         break; | ||||
|     default : | ||||
|     default: | ||||
|         usb_status = USBD_FAIL; | ||||
|         break; | ||||
|     } | ||||
| @ -601,27 +583,26 @@ USBD_StatusTypeDef USBD_LL_FlushEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) | ||||
|   * @param  ep_addr: Endpoint number | ||||
|   * @retval USBD status | ||||
|   */ | ||||
| USBD_StatusTypeDef USBD_LL_StallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) | ||||
| { | ||||
| USBD_StatusTypeDef USBD_LL_StallEP(USBD_HandleTypeDef* pdev, uint8_t ep_addr) { | ||||
|     HAL_StatusTypeDef hal_status = HAL_OK; | ||||
|     USBD_StatusTypeDef usb_status = USBD_OK; | ||||
| 
 | ||||
|     hal_status = HAL_PCD_EP_SetStall(pdev->pData, ep_addr); | ||||
| 
 | ||||
|   switch (hal_status) { | ||||
|     case HAL_OK : | ||||
|     switch(hal_status) { | ||||
|     case HAL_OK: | ||||
|         usb_status = USBD_OK; | ||||
|         break; | ||||
|     case HAL_ERROR : | ||||
|     case HAL_ERROR: | ||||
|         usb_status = USBD_FAIL; | ||||
|         break; | ||||
|     case HAL_BUSY : | ||||
|     case HAL_BUSY: | ||||
|         usb_status = USBD_BUSY; | ||||
|         break; | ||||
|     case HAL_TIMEOUT : | ||||
|     case HAL_TIMEOUT: | ||||
|         usb_status = USBD_FAIL; | ||||
|         break; | ||||
|     default : | ||||
|     default: | ||||
|         usb_status = USBD_FAIL; | ||||
|         break; | ||||
|     } | ||||
| @ -634,27 +615,26 @@ USBD_StatusTypeDef USBD_LL_StallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) | ||||
|   * @param  ep_addr: Endpoint number | ||||
|   * @retval USBD status | ||||
|   */ | ||||
| USBD_StatusTypeDef USBD_LL_ClearStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) | ||||
| { | ||||
| USBD_StatusTypeDef USBD_LL_ClearStallEP(USBD_HandleTypeDef* pdev, uint8_t ep_addr) { | ||||
|     HAL_StatusTypeDef hal_status = HAL_OK; | ||||
|     USBD_StatusTypeDef usb_status = USBD_OK; | ||||
| 
 | ||||
|     hal_status = HAL_PCD_EP_ClrStall(pdev->pData, ep_addr); | ||||
| 
 | ||||
|   switch (hal_status) { | ||||
|     case HAL_OK : | ||||
|     switch(hal_status) { | ||||
|     case HAL_OK: | ||||
|         usb_status = USBD_OK; | ||||
|         break; | ||||
|     case HAL_ERROR : | ||||
|     case HAL_ERROR: | ||||
|         usb_status = USBD_FAIL; | ||||
|         break; | ||||
|     case HAL_BUSY : | ||||
|     case HAL_BUSY: | ||||
|         usb_status = USBD_BUSY; | ||||
|         break; | ||||
|     case HAL_TIMEOUT : | ||||
|     case HAL_TIMEOUT: | ||||
|         usb_status = USBD_FAIL; | ||||
|         break; | ||||
|     default : | ||||
|     default: | ||||
|         usb_status = USBD_FAIL; | ||||
|         break; | ||||
|     } | ||||
| @ -667,16 +647,12 @@ USBD_StatusTypeDef USBD_LL_ClearStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_add | ||||
|   * @param  ep_addr: Endpoint number | ||||
|   * @retval Stall (1: Yes, 0: No) | ||||
|   */ | ||||
| uint8_t USBD_LL_IsStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) | ||||
| { | ||||
|   PCD_HandleTypeDef *hpcd = (PCD_HandleTypeDef*) pdev->pData; | ||||
| uint8_t USBD_LL_IsStallEP(USBD_HandleTypeDef* pdev, uint8_t ep_addr) { | ||||
|     PCD_HandleTypeDef* hpcd = (PCD_HandleTypeDef*)pdev->pData; | ||||
| 
 | ||||
|   if((ep_addr & 0x80) == 0x80) | ||||
|   { | ||||
|     if((ep_addr & 0x80) == 0x80) { | ||||
|         return hpcd->IN_ep[ep_addr & 0x7F].is_stall; | ||||
|   } | ||||
|   else | ||||
|   { | ||||
|     } else { | ||||
|         return hpcd->OUT_ep[ep_addr & 0x7F].is_stall; | ||||
|     } | ||||
| } | ||||
| @ -687,27 +663,26 @@ uint8_t USBD_LL_IsStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) | ||||
|   * @param  dev_addr: Device address | ||||
|   * @retval USBD status | ||||
|   */ | ||||
| USBD_StatusTypeDef USBD_LL_SetUSBAddress(USBD_HandleTypeDef *pdev, uint8_t dev_addr) | ||||
| { | ||||
| USBD_StatusTypeDef USBD_LL_SetUSBAddress(USBD_HandleTypeDef* pdev, uint8_t dev_addr) { | ||||
|     HAL_StatusTypeDef hal_status = HAL_OK; | ||||
|     USBD_StatusTypeDef usb_status = USBD_OK; | ||||
| 
 | ||||
|     hal_status = HAL_PCD_SetAddress(pdev->pData, dev_addr); | ||||
| 
 | ||||
|   switch (hal_status) { | ||||
|     case HAL_OK : | ||||
|     switch(hal_status) { | ||||
|     case HAL_OK: | ||||
|         usb_status = USBD_OK; | ||||
|         break; | ||||
|     case HAL_ERROR : | ||||
|     case HAL_ERROR: | ||||
|         usb_status = USBD_FAIL; | ||||
|         break; | ||||
|     case HAL_BUSY : | ||||
|     case HAL_BUSY: | ||||
|         usb_status = USBD_BUSY; | ||||
|         break; | ||||
|     case HAL_TIMEOUT : | ||||
|     case HAL_TIMEOUT: | ||||
|         usb_status = USBD_FAIL; | ||||
|         break; | ||||
|     default : | ||||
|     default: | ||||
|         usb_status = USBD_FAIL; | ||||
|         break; | ||||
|     } | ||||
| @ -722,27 +697,27 @@ USBD_StatusTypeDef USBD_LL_SetUSBAddress(USBD_HandleTypeDef *pdev, uint8_t dev_a | ||||
|   * @param  size: Data size     | ||||
|   * @retval USBD status | ||||
|   */ | ||||
| USBD_StatusTypeDef USBD_LL_Transmit(USBD_HandleTypeDef *pdev, uint8_t ep_addr, uint8_t *pbuf, uint16_t size) | ||||
| { | ||||
| USBD_StatusTypeDef | ||||
| USBD_LL_Transmit(USBD_HandleTypeDef* pdev, uint8_t ep_addr, uint8_t* pbuf, uint16_t size) { | ||||
|     HAL_StatusTypeDef hal_status = HAL_OK; | ||||
|     USBD_StatusTypeDef usb_status = USBD_OK; | ||||
| 
 | ||||
|     hal_status = HAL_PCD_EP_Transmit(pdev->pData, ep_addr, pbuf, size); | ||||
| 
 | ||||
|   switch (hal_status) { | ||||
|     case HAL_OK : | ||||
|     switch(hal_status) { | ||||
|     case HAL_OK: | ||||
|         usb_status = USBD_OK; | ||||
|         break; | ||||
|     case HAL_ERROR : | ||||
|     case HAL_ERROR: | ||||
|         usb_status = USBD_FAIL; | ||||
|         break; | ||||
|     case HAL_BUSY : | ||||
|     case HAL_BUSY: | ||||
|         usb_status = USBD_BUSY; | ||||
|         break; | ||||
|     case HAL_TIMEOUT : | ||||
|     case HAL_TIMEOUT: | ||||
|         usb_status = USBD_FAIL; | ||||
|         break; | ||||
|     default : | ||||
|     default: | ||||
|         usb_status = USBD_FAIL; | ||||
|         break; | ||||
|     } | ||||
| @ -757,27 +732,27 @@ USBD_StatusTypeDef USBD_LL_Transmit(USBD_HandleTypeDef *pdev, uint8_t ep_addr, u | ||||
|   * @param  size: Data size | ||||
|   * @retval USBD status | ||||
|   */ | ||||
| USBD_StatusTypeDef USBD_LL_PrepareReceive(USBD_HandleTypeDef *pdev, uint8_t ep_addr, uint8_t *pbuf, uint16_t size) | ||||
| { | ||||
| USBD_StatusTypeDef | ||||
| USBD_LL_PrepareReceive(USBD_HandleTypeDef* pdev, uint8_t ep_addr, uint8_t* pbuf, uint16_t size) { | ||||
|     HAL_StatusTypeDef hal_status = HAL_OK; | ||||
|     USBD_StatusTypeDef usb_status = USBD_OK; | ||||
| 
 | ||||
|     hal_status = HAL_PCD_EP_Receive(pdev->pData, ep_addr, pbuf, size); | ||||
| 
 | ||||
|   switch (hal_status) { | ||||
|     case HAL_OK : | ||||
|     switch(hal_status) { | ||||
|     case HAL_OK: | ||||
|         usb_status = USBD_OK; | ||||
|         break; | ||||
|     case HAL_ERROR : | ||||
|     case HAL_ERROR: | ||||
|         usb_status = USBD_FAIL; | ||||
|         break; | ||||
|     case HAL_BUSY : | ||||
|     case HAL_BUSY: | ||||
|         usb_status = USBD_BUSY; | ||||
|         break; | ||||
|     case HAL_TIMEOUT : | ||||
|     case HAL_TIMEOUT: | ||||
|         usb_status = USBD_FAIL; | ||||
|         break; | ||||
|     default : | ||||
|     default: | ||||
|         usb_status = USBD_FAIL; | ||||
|         break; | ||||
|     } | ||||
| @ -790,9 +765,8 @@ USBD_StatusTypeDef USBD_LL_PrepareReceive(USBD_HandleTypeDef *pdev, uint8_t ep_a | ||||
|   * @param  ep_addr: Endpoint number | ||||
|   * @retval Recived Data Size | ||||
|   */ | ||||
| uint32_t USBD_LL_GetRxDataSize(USBD_HandleTypeDef *pdev, uint8_t ep_addr) | ||||
| { | ||||
|   return HAL_PCD_EP_GetRxCount((PCD_HandleTypeDef*) pdev->pData, ep_addr); | ||||
| uint32_t USBD_LL_GetRxDataSize(USBD_HandleTypeDef* pdev, uint8_t ep_addr) { | ||||
|     return HAL_PCD_EP_GetRxCount((PCD_HandleTypeDef*)pdev->pData, ep_addr); | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -801,17 +775,14 @@ uint32_t USBD_LL_GetRxDataSize(USBD_HandleTypeDef *pdev, uint8_t ep_addr) | ||||
|   * @param  msg: LPM message | ||||
|   * @retval None | ||||
|   */ | ||||
| void HAL_PCDEx_LPM_Callback(PCD_HandleTypeDef *hpcd, PCD_LPM_MsgTypeDef msg) | ||||
| { | ||||
|   switch (msg) | ||||
|   { | ||||
| void HAL_PCDEx_LPM_Callback(PCD_HandleTypeDef* hpcd, PCD_LPM_MsgTypeDef msg) { | ||||
|     switch(msg) { | ||||
|     case PCD_LPM_L0_ACTIVE: | ||||
|     if (hpcd->Init.low_power_enable) | ||||
|     { | ||||
|         if(hpcd->Init.low_power_enable) { | ||||
|             SystemClockConfig_Resume(); | ||||
| 
 | ||||
|             /* Reset SLEEPDEEP bit of Cortex System Control Register. */ | ||||
|       SCB->SCR &= (uint32_t)~((uint32_t)(SCB_SCR_SLEEPDEEP_Msk | SCB_SCR_SLEEPONEXIT_Msk)); | ||||
|             SCB->SCR &= (uint32_t) ~((uint32_t)(SCB_SCR_SLEEPDEEP_Msk | SCB_SCR_SLEEPONEXIT_Msk)); | ||||
|         } | ||||
|         __HAL_PCD_UNGATE_PHYCLOCK(hpcd); | ||||
|         USBD_LL_Resume(hpcd->pData); | ||||
| @ -822,8 +793,7 @@ void HAL_PCDEx_LPM_Callback(PCD_HandleTypeDef *hpcd, PCD_LPM_MsgTypeDef msg) | ||||
|         USBD_LL_Suspend(hpcd->pData); | ||||
| 
 | ||||
|         /* Enter in STOP mode. */ | ||||
|     if (hpcd->Init.low_power_enable) | ||||
|     {    | ||||
|         if(hpcd->Init.low_power_enable) { | ||||
|             /* Set SLEEPDEEP bit and SleepOnExit of Cortex System Control Register. */ | ||||
|             SCB->SCR |= (uint32_t)((uint32_t)(SCB_SCR_SLEEPDEEP_Msk | SCB_SCR_SLEEPONEXIT_Msk)); | ||||
|         } | ||||
| @ -836,8 +806,7 @@ void HAL_PCDEx_LPM_Callback(PCD_HandleTypeDef *hpcd, PCD_LPM_MsgTypeDef msg) | ||||
|   * @param  Delay: Delay in ms | ||||
|   * @retval None | ||||
|   */ | ||||
| void USBD_LL_Delay(uint32_t Delay) | ||||
| { | ||||
| void USBD_LL_Delay(uint32_t Delay) { | ||||
|     HAL_Delay(Delay); | ||||
| } | ||||
| 
 | ||||
| @ -846,9 +815,8 @@ void USBD_LL_Delay(uint32_t Delay) | ||||
|   * @param  size: Size of allocated memory | ||||
|   * @retval None | ||||
|   */ | ||||
| void *USBD_static_malloc(uint32_t size) | ||||
| { | ||||
|   static uint32_t mem[(sizeof(USBD_CDC_HandleTypeDef)/4)+1];/* On 32-bit boundary */ | ||||
| void* USBD_static_malloc(uint32_t size) { | ||||
|     static uint32_t mem[(sizeof(USBD_CDC_HandleTypeDef) / 4) + 1]; /* On 32-bit boundary */ | ||||
|     return mem; | ||||
| } | ||||
| 
 | ||||
| @ -857,9 +825,7 @@ void *USBD_static_malloc(uint32_t size) | ||||
|   * @param  p: Pointer to allocated  memory address | ||||
|   * @retval None | ||||
|   */ | ||||
| void USBD_static_free(void *p) | ||||
| { | ||||
| 
 | ||||
| void USBD_static_free(void* p) { | ||||
| } | ||||
| 
 | ||||
| /* USER CODE BEGIN 5 */ | ||||
| @ -868,8 +834,7 @@ void USBD_static_free(void *p) | ||||
|   *         enable HSI, PLL and select PLL as system clock source. | ||||
|   * @retval None | ||||
|   */ | ||||
| static void SystemClockConfig_Resume(void) | ||||
| { | ||||
| static void SystemClockConfig_Resume(void) { | ||||
|     SystemClock_Config(); | ||||
| } | ||||
| /* USER CODE END 5 */ | ||||
|  | ||||
| @ -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,30 +135,29 @@ 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 = | ||||
| { | ||||
| __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
 | ||||
| #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 | ||||
| @ -184,12 +182,11 @@ __ALIGN_BEGIN uint8_t USBD_FS_DeviceDesc[USB_LEN_DEV_DESC] __ALIGN_END = | ||||
| 
 | ||||
| /* 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 = | ||||
| { | ||||
| __ALIGN_BEGIN uint8_t USBD_FS_BOSDesc[USB_SIZ_BOS_DESC] __ALIGN_END = { | ||||
|     0x5, | ||||
|     USB_DESC_TYPE_BOS, | ||||
|     0xC, | ||||
| @ -202,8 +199,7 @@ __ALIGN_BEGIN uint8_t USBD_FS_BOSDesc[USB_SIZ_BOS_DESC] __ALIGN_END = | ||||
|     0x2, /* LPM capability bit set*/ | ||||
|     0x0, | ||||
|     0x0, | ||||
|   0x0 | ||||
| }; | ||||
|     0x0}; | ||||
| #endif /* (USBD_LPM_ENABLED == 1) */ | ||||
| 
 | ||||
| /**
 | ||||
| @ -215,27 +211,25 @@ __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 = | ||||
| { | ||||
| __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) | ||||
| }; | ||||
|     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, | ||||
| @ -257,8 +251,7 @@ __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) | ||||
| { | ||||
| uint8_t* USBD_FS_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t* length) { | ||||
|     UNUSED(speed); | ||||
|     *length = sizeof(USBD_FS_DeviceDesc); | ||||
|     return USBD_FS_DeviceDesc; | ||||
| @ -270,8 +263,7 @@ 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) | ||||
| { | ||||
| uint8_t* USBD_FS_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t* length) { | ||||
|     UNUSED(speed); | ||||
|     *length = sizeof(USBD_LangIDDesc); | ||||
|     return USBD_LangIDDesc; | ||||
| @ -283,15 +275,11 @@ 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); | ||||
| 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,10 +290,9 @@ 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) | ||||
| { | ||||
| uint8_t* USBD_FS_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t* length) { | ||||
|     UNUSED(speed); | ||||
|   USBD_GetString((uint8_t *)USBD_MANUFACTURER_STRING, USBD_StrDesc, length); | ||||
|     USBD_GetString((uint8_t*)USBD_MANUFACTURER_STRING, USBD_StrDesc, length); | ||||
|     return USBD_StrDesc; | ||||
| } | ||||
| 
 | ||||
| @ -315,8 +302,7 @@ 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) | ||||
| { | ||||
| uint8_t* USBD_FS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t* length) { | ||||
|     UNUSED(speed); | ||||
|     *length = USB_SIZ_STRING_SERIAL; | ||||
| 
 | ||||
| @ -326,7 +312,7 @@ uint8_t * USBD_FS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) | ||||
|     /* USER CODE BEGIN USBD_FS_SerialStrDescriptor */ | ||||
| 
 | ||||
|     /* USER CODE END USBD_FS_SerialStrDescriptor */ | ||||
|   return (uint8_t *) USBD_StringSerial; | ||||
|     return (uint8_t*)USBD_StringSerial; | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -335,15 +321,11 @@ 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); | ||||
| 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,28 +336,23 @@ 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); | ||||
| 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) | ||||
| { | ||||
| 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; | ||||
| @ -387,18 +364,16 @@ uint8_t * USBD_FS_USR_BOSDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) | ||||
|   * @param  None  | ||||
|   * @retval None | ||||
|   */ | ||||
| static void Get_SerialNum(void) | ||||
| { | ||||
| 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; | ||||
| 
 | ||||
|   if (deviceserial0 != 0) | ||||
|   { | ||||
|     if(deviceserial0 != 0) { | ||||
|         IntToUnicode(deviceserial0, &USBD_StringSerial[2], 8); | ||||
|         IntToUnicode(deviceserial1, &USBD_StringSerial[18], 4); | ||||
|     } | ||||
| @ -411,18 +386,13 @@ static void Get_SerialNum(void) | ||||
|   * @param  len: buffer length | ||||
|   * @retval None | ||||
|   */ | ||||
| static void IntToUnicode(uint32_t value, uint8_t * pbuf, uint8_t len) | ||||
| { | ||||
| 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) | ||||
|     { | ||||
|     for(idx = 0; idx < len; idx++) { | ||||
|         if(((value >> 28)) < 0xA) { | ||||
|             pbuf[2 * idx] = (value >> 28) + '0'; | ||||
|     } | ||||
|     else | ||||
|     { | ||||
|         } else { | ||||
|             pbuf[2 * idx] = (value >> 28) + 'A' - 10; | ||||
|         } | ||||
| 
 | ||||
|  | ||||
| @ -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 | ||||
| @ -72,11 +72,11 @@ | ||||
| 
 | ||||
| /* Co-routine definitions. */ | ||||
| #define configUSE_CO_ROUTINES 0 | ||||
| #define configMAX_CO_ROUTINE_PRIORITIES          ( 2 ) | ||||
| #define configMAX_CO_ROUTINE_PRIORITIES (2) | ||||
| 
 | ||||
| /* Software timer definitions. */ | ||||
| #define configUSE_TIMERS 1 | ||||
| #define configTIMER_TASK_PRIORITY                ( 2 ) | ||||
| #define configTIMER_TASK_PRIORITY (2) | ||||
| #define configTIMER_QUEUE_LENGTH 10 | ||||
| #define configTIMER_TASK_STACK_DEPTH 256 | ||||
| 
 | ||||
| @ -93,10 +93,10 @@ to exclude the API function. */ | ||||
| 
 | ||||
| /* 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"
 | ||||
| @ -111,15 +111,22 @@ 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
 | ||||
|  | ||||
| @ -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,16 +140,17 @@ | ||||
|   *        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*/ | ||||
| #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,
 | ||||
| @ -221,197 +224,197 @@ | ||||
|   */ | ||||
| 
 | ||||
| #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 ------------------------------------------------------------*/ | ||||
| @ -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 ------------------------------------------------------------------*/ | ||||
| @ -92,7 +92,7 @@ | ||||
| /* 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 | ||||
| @ -108,25 +108,28 @@ | ||||
| 
 | ||||
| /* DEBUG macros */ | ||||
| 
 | ||||
| #if (USBD_DEBUG_LEVEL > 0) | ||||
| #define USBD_UsrLog(...)    printf(__VA_ARGS__);\ | ||||
| #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__);\ | ||||
| #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__);\ | ||||
| #if(USBD_DEBUG_LEVEL > 2) | ||||
| #define USBD_DbgLog(...) \ | ||||
|     printf("DEBUG : ");  \ | ||||
|     printf(__VA_ARGS__); \ | ||||
|     printf("\n"); | ||||
| #else | ||||
| #define USBD_DbgLog(...) | ||||
| @ -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 ------------------------------------------------------------------*/ | ||||
|  | ||||
| @ -38,12 +38,13 @@ void app_gpio_init(GpioPin gpio, GpioMode mode) { | ||||
| void delay_us(uint32_t time) { | ||||
|     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,17 +55,20 @@ | ||||
| /* 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 ) | ||||
| { | ||||
| __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 | ||||
| @ -82,8 +85,9 @@ __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 ) | ||||
| { | ||||
| void vApplicationGetIdleTaskMemory(StaticTask_t** ppxIdleTaskTCBBuffer, | ||||
|                                    StackType_t** ppxIdleTaskStackBuffer, | ||||
|                                    uint32_t* pulIdleTaskStackSize) { | ||||
|     *ppxIdleTaskTCBBuffer = &xIdleTaskTCBBuffer; | ||||
|     *ppxIdleTaskStackBuffer = &xIdleStack[0]; | ||||
|     *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE; | ||||
| @ -95,8 +99,9 @@ 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 )   | ||||
| { | ||||
| void vApplicationGetTimerTaskMemory(StaticTask_t** ppxTimerTaskTCBBuffer, | ||||
|                                     StackType_t** ppxTimerTaskStackBuffer, | ||||
|                                     uint32_t* pulTimerTaskStackSize) { | ||||
|     *ppxTimerTaskTCBBuffer = &xTimerTaskTCBBuffer; | ||||
|     *ppxTimerTaskStackBuffer = &xTimerStack[0]; | ||||
|     *pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH; | ||||
|  | ||||
| @ -72,7 +72,7 @@ static void MX_TIM5_Init(void); | ||||
| static void MX_TIM15_Init(void); | ||||
| static void MX_USART1_UART_Init(void); | ||||
| static void MX_TIM8_Init(void); | ||||
| void StartDefaultTask(void const * argument); | ||||
| void StartDefaultTask(void const* argument); | ||||
| 
 | ||||
| /* USER CODE BEGIN PFP */ | ||||
| 
 | ||||
| @ -87,13 +87,11 @@ void StartDefaultTask(void const * argument); | ||||
|   * @brief  The application entry point. | ||||
|   * @retval int | ||||
|   */ | ||||
| int main(void) | ||||
| { | ||||
| int main(void) { | ||||
|     /* USER CODE BEGIN 1 */ | ||||
| 
 | ||||
|     /* USER CODE END 1 */ | ||||
| 
 | ||||
| 
 | ||||
|     /* MCU Configuration--------------------------------------------------------*/ | ||||
| 
 | ||||
|     /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ | ||||
| @ -156,8 +154,7 @@ int main(void) | ||||
| 
 | ||||
|     /* Infinite loop */ | ||||
|     /* USER CODE BEGIN WHILE */ | ||||
|   while (1) | ||||
|   { | ||||
|     while(1) { | ||||
|         /* USER CODE END WHILE */ | ||||
| 
 | ||||
|         /* USER CODE BEGIN 3 */ | ||||
| @ -169,8 +166,7 @@ int main(void) | ||||
|   * @brief System Clock Configuration | ||||
|   * @retval None | ||||
|   */ | ||||
| void SystemClock_Config(void) | ||||
| { | ||||
| void SystemClock_Config(void) { | ||||
|     RCC_OscInitTypeDef RCC_OscInitStruct = {0}; | ||||
|     RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; | ||||
|     RCC_PeriphCLKInitTypeDef PeriphClkInit = {0}; | ||||
| @ -186,25 +182,23 @@ void SystemClock_Config(void) | ||||
|     RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV7; | ||||
|     RCC_OscInitStruct.PLL.PLLQ = RCC_PLLQ_DIV2; | ||||
|     RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV2; | ||||
|   if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) | ||||
|   { | ||||
|     if(HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { | ||||
|         Error_Handler(); | ||||
|     } | ||||
|     /** Initializes the CPU, AHB and APB busses clocks 
 | ||||
|   */ | ||||
|   RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK | ||||
|                               |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2; | ||||
|     RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_PCLK1 | | ||||
|                                   RCC_CLOCKTYPE_PCLK2; | ||||
|     RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; | ||||
|     RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; | ||||
|     RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; | ||||
|     RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; | ||||
| 
 | ||||
|   if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_3) != HAL_OK) | ||||
|   { | ||||
|     if(HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_3) != HAL_OK) { | ||||
|         Error_Handler(); | ||||
|     } | ||||
|   PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USART1|RCC_PERIPHCLK_USB | ||||
|                               |RCC_PERIPHCLK_ADC; | ||||
|     PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USART1 | RCC_PERIPHCLK_USB | | ||||
|                                          RCC_PERIPHCLK_ADC; | ||||
|     PeriphClkInit.Usart1ClockSelection = RCC_USART1CLKSOURCE_PCLK2; | ||||
|     PeriphClkInit.AdcClockSelection = RCC_ADCCLKSOURCE_SYSCLK; | ||||
|     PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_PLLSAI1; | ||||
| @ -215,14 +209,12 @@ void SystemClock_Config(void) | ||||
|     PeriphClkInit.PLLSAI1.PLLSAI1Q = RCC_PLLQ_DIV2; | ||||
|     PeriphClkInit.PLLSAI1.PLLSAI1R = RCC_PLLR_DIV2; | ||||
|     PeriphClkInit.PLLSAI1.PLLSAI1ClockOut = RCC_PLLSAI1_48M2CLK; | ||||
|   if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK) | ||||
|   { | ||||
|     if(HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK) { | ||||
|         Error_Handler(); | ||||
|     } | ||||
|     /** Configure the main internal regulator output voltage 
 | ||||
|   */ | ||||
|   if (HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1) != HAL_OK) | ||||
|   { | ||||
|     if(HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1) != HAL_OK) { | ||||
|         Error_Handler(); | ||||
|     } | ||||
| } | ||||
| @ -232,9 +224,7 @@ void SystemClock_Config(void) | ||||
|   * @param None | ||||
|   * @retval None | ||||
|   */ | ||||
| static void MX_ADC1_Init(void) | ||||
| { | ||||
| 
 | ||||
| static void MX_ADC1_Init(void) { | ||||
|     /* USER CODE BEGIN ADC1_Init 0 */ | ||||
| 
 | ||||
|     /* USER CODE END ADC1_Init 0 */ | ||||
| @ -262,15 +252,13 @@ static void MX_ADC1_Init(void) | ||||
|     hadc1.Init.DMAContinuousRequests = DISABLE; | ||||
|     hadc1.Init.Overrun = ADC_OVR_DATA_PRESERVED; | ||||
|     hadc1.Init.OversamplingMode = DISABLE; | ||||
|   if (HAL_ADC_Init(&hadc1) != HAL_OK) | ||||
|   { | ||||
|     if(HAL_ADC_Init(&hadc1) != HAL_OK) { | ||||
|         Error_Handler(); | ||||
|     } | ||||
|     /** Configure the ADC multi-mode 
 | ||||
|   */ | ||||
|     multimode.Mode = ADC_MODE_INDEPENDENT; | ||||
|   if (HAL_ADCEx_MultiModeConfigChannel(&hadc1, &multimode) != HAL_OK) | ||||
|   { | ||||
|     if(HAL_ADCEx_MultiModeConfigChannel(&hadc1, &multimode) != HAL_OK) { | ||||
|         Error_Handler(); | ||||
|     } | ||||
|     /** Configure Regular Channel 
 | ||||
| @ -281,14 +269,12 @@ static void MX_ADC1_Init(void) | ||||
|     sConfig.SingleDiff = ADC_SINGLE_ENDED; | ||||
|     sConfig.OffsetNumber = ADC_OFFSET_NONE; | ||||
|     sConfig.Offset = 0; | ||||
|   if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK) | ||||
|   { | ||||
|     if(HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK) { | ||||
|         Error_Handler(); | ||||
|     } | ||||
|     /* USER CODE BEGIN ADC1_Init 2 */ | ||||
| 
 | ||||
|     /* USER CODE END ADC1_Init 2 */ | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -296,9 +282,7 @@ static void MX_ADC1_Init(void) | ||||
|   * @param None | ||||
|   * @retval None | ||||
|   */ | ||||
| static void MX_COMP1_Init(void) | ||||
| { | ||||
| 
 | ||||
| static void MX_COMP1_Init(void) { | ||||
|     /* USER CODE BEGIN COMP1_Init 0 */ | ||||
| 
 | ||||
|     /* USER CODE END COMP1_Init 0 */ | ||||
| @ -315,14 +299,12 @@ static void MX_COMP1_Init(void) | ||||
|     hcomp1.Init.Mode = COMP_POWERMODE_HIGHSPEED; | ||||
|     hcomp1.Init.WindowMode = COMP_WINDOWMODE_DISABLE; | ||||
|     hcomp1.Init.TriggerMode = COMP_TRIGGERMODE_NONE; | ||||
|   if (HAL_COMP_Init(&hcomp1) != HAL_OK) | ||||
|   { | ||||
|     if(HAL_COMP_Init(&hcomp1) != HAL_OK) { | ||||
|         Error_Handler(); | ||||
|     } | ||||
|     /* USER CODE BEGIN COMP1_Init 2 */ | ||||
| 
 | ||||
|     /* USER CODE END COMP1_Init 2 */ | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -330,9 +312,7 @@ static void MX_COMP1_Init(void) | ||||
|   * @param None | ||||
|   * @retval None | ||||
|   */ | ||||
| static void MX_SPI1_Init(void) | ||||
| { | ||||
| 
 | ||||
| static void MX_SPI1_Init(void) { | ||||
|     /* USER CODE BEGIN SPI1_Init 0 */ | ||||
| 
 | ||||
|     /* USER CODE END SPI1_Init 0 */ | ||||
| @ -355,14 +335,12 @@ static void MX_SPI1_Init(void) | ||||
|     hspi1.Init.CRCPolynomial = 7; | ||||
|     hspi1.Init.CRCLength = SPI_CRC_LENGTH_DATASIZE; | ||||
|     hspi1.Init.NSSPMode = SPI_NSS_PULSE_ENABLE; | ||||
|   if (HAL_SPI_Init(&hspi1) != HAL_OK) | ||||
|   { | ||||
|     if(HAL_SPI_Init(&hspi1) != HAL_OK) { | ||||
|         Error_Handler(); | ||||
|     } | ||||
|     /* USER CODE BEGIN SPI1_Init 2 */ | ||||
| 
 | ||||
|     /* USER CODE END SPI1_Init 2 */ | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -370,9 +348,7 @@ static void MX_SPI1_Init(void) | ||||
|   * @param None | ||||
|   * @retval None | ||||
|   */ | ||||
| static void MX_SPI3_Init(void) | ||||
| { | ||||
| 
 | ||||
| static void MX_SPI3_Init(void) { | ||||
|     /* USER CODE BEGIN SPI3_Init 0 */ | ||||
| 
 | ||||
|     /* USER CODE END SPI3_Init 0 */ | ||||
| @ -395,14 +371,12 @@ static void MX_SPI3_Init(void) | ||||
|     hspi3.Init.CRCPolynomial = 7; | ||||
|     hspi3.Init.CRCLength = SPI_CRC_LENGTH_DATASIZE; | ||||
|     hspi3.Init.NSSPMode = SPI_NSS_PULSE_ENABLE; | ||||
|   if (HAL_SPI_Init(&hspi3) != HAL_OK) | ||||
|   { | ||||
|     if(HAL_SPI_Init(&hspi3) != HAL_OK) { | ||||
|         Error_Handler(); | ||||
|     } | ||||
|     /* USER CODE BEGIN SPI3_Init 2 */ | ||||
| 
 | ||||
|     /* USER CODE END SPI3_Init 2 */ | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -410,9 +384,7 @@ static void MX_SPI3_Init(void) | ||||
|   * @param None | ||||
|   * @retval None | ||||
|   */ | ||||
| static void MX_TIM5_Init(void) | ||||
| { | ||||
| 
 | ||||
| static void MX_TIM5_Init(void) { | ||||
|     /* USER CODE BEGIN TIM5_Init 0 */ | ||||
| 
 | ||||
|     /* USER CODE END TIM5_Init 0 */ | ||||
| @ -429,29 +401,25 @@ static void MX_TIM5_Init(void) | ||||
|     htim5.Init.Period = 291; | ||||
|     htim5.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; | ||||
|     htim5.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; | ||||
|   if (HAL_TIM_PWM_Init(&htim5) != HAL_OK) | ||||
|   { | ||||
|     if(HAL_TIM_PWM_Init(&htim5) != HAL_OK) { | ||||
|         Error_Handler(); | ||||
|     } | ||||
|     sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET; | ||||
|     sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; | ||||
|   if (HAL_TIMEx_MasterConfigSynchronization(&htim5, &sMasterConfig) != HAL_OK) | ||||
|   { | ||||
|     if(HAL_TIMEx_MasterConfigSynchronization(&htim5, &sMasterConfig) != HAL_OK) { | ||||
|         Error_Handler(); | ||||
|     } | ||||
|     sConfigOC.OCMode = TIM_OCMODE_PWM1; | ||||
|     sConfigOC.Pulse = 145; | ||||
|     sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH; | ||||
|     sConfigOC.OCFastMode = TIM_OCFAST_DISABLE; | ||||
|   if (HAL_TIM_PWM_ConfigChannel(&htim5, &sConfigOC, TIM_CHANNEL_4) != HAL_OK) | ||||
|   { | ||||
|     if(HAL_TIM_PWM_ConfigChannel(&htim5, &sConfigOC, TIM_CHANNEL_4) != HAL_OK) { | ||||
|         Error_Handler(); | ||||
|     } | ||||
|     /* USER CODE BEGIN TIM5_Init 2 */ | ||||
| 
 | ||||
|     /* USER CODE END TIM5_Init 2 */ | ||||
|     HAL_TIM_MspPostInit(&htim5); | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -459,9 +427,7 @@ static void MX_TIM5_Init(void) | ||||
|   * @param None | ||||
|   * @retval None | ||||
|   */ | ||||
| static void MX_TIM8_Init(void) | ||||
| { | ||||
| 
 | ||||
| static void MX_TIM8_Init(void) { | ||||
|     /* USER CODE BEGIN TIM8_Init 0 */ | ||||
| 
 | ||||
|     /* USER CODE END TIM8_Init 0 */ | ||||
| @ -474,44 +440,38 @@ static void MX_TIM8_Init(void) | ||||
| 
 | ||||
|     /* USER CODE END TIM8_Init 1 */ | ||||
|     htim8.Instance = TIM8; | ||||
|   htim8.Init.Prescaler = 64-1; | ||||
|     htim8.Init.Prescaler = 64 - 1; | ||||
|     htim8.Init.CounterMode = TIM_COUNTERMODE_UP; | ||||
|   htim8.Init.Period = 32768-1; | ||||
|     htim8.Init.Period = 32768 - 1; | ||||
|     htim8.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; | ||||
|     htim8.Init.RepetitionCounter = 0; | ||||
|     htim8.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; | ||||
|   if (HAL_TIM_Base_Init(&htim8) != HAL_OK) | ||||
|   { | ||||
|     if(HAL_TIM_Base_Init(&htim8) != HAL_OK) { | ||||
|         Error_Handler(); | ||||
|     } | ||||
|     sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL; | ||||
|   if (HAL_TIM_ConfigClockSource(&htim8, &sClockSourceConfig) != HAL_OK) | ||||
|   { | ||||
|     if(HAL_TIM_ConfigClockSource(&htim8, &sClockSourceConfig) != HAL_OK) { | ||||
|         Error_Handler(); | ||||
|     } | ||||
|   if (HAL_TIM_IC_Init(&htim8) != HAL_OK) | ||||
|   { | ||||
|     if(HAL_TIM_IC_Init(&htim8) != HAL_OK) { | ||||
|         Error_Handler(); | ||||
|     } | ||||
|     sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET; | ||||
|     sMasterConfig.MasterOutputTrigger2 = TIM_TRGO2_RESET; | ||||
|     sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; | ||||
|   if (HAL_TIMEx_MasterConfigSynchronization(&htim8, &sMasterConfig) != HAL_OK) | ||||
|   { | ||||
|     if(HAL_TIMEx_MasterConfigSynchronization(&htim8, &sMasterConfig) != HAL_OK) { | ||||
|         Error_Handler(); | ||||
|     } | ||||
|     sConfigIC.ICPolarity = TIM_INPUTCHANNELPOLARITY_BOTHEDGE; | ||||
|     sConfigIC.ICSelection = TIM_ICSELECTION_DIRECTTI; | ||||
|     sConfigIC.ICPrescaler = TIM_ICPSC_DIV1; | ||||
|     sConfigIC.ICFilter = 0; | ||||
|   if (HAL_TIM_IC_ConfigChannel(&htim8, &sConfigIC, TIM_CHANNEL_2) != HAL_OK) | ||||
|   { | ||||
|     if(HAL_TIM_IC_ConfigChannel(&htim8, &sConfigIC, TIM_CHANNEL_2) != HAL_OK) { | ||||
|         Error_Handler(); | ||||
|     } | ||||
|     /* USER CODE BEGIN TIM8_Init 2 */ | ||||
| 
 | ||||
|     /* USER CODE END TIM8_Init 2 */ | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -519,9 +479,7 @@ static void MX_TIM8_Init(void) | ||||
|   * @param None | ||||
|   * @retval None | ||||
|   */ | ||||
| static void MX_TIM15_Init(void) | ||||
| { | ||||
| 
 | ||||
| static void MX_TIM15_Init(void) { | ||||
|     /* USER CODE BEGIN TIM15_Init 0 */ | ||||
| 
 | ||||
|     /* USER CODE END TIM15_Init 0 */ | ||||
| @ -540,14 +498,12 @@ static void MX_TIM15_Init(void) | ||||
|     htim15.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; | ||||
|     htim15.Init.RepetitionCounter = 0; | ||||
|     htim15.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; | ||||
|   if (HAL_TIM_OC_Init(&htim15) != HAL_OK) | ||||
|   { | ||||
|     if(HAL_TIM_OC_Init(&htim15) != HAL_OK) { | ||||
|         Error_Handler(); | ||||
|     } | ||||
|     sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET; | ||||
|     sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; | ||||
|   if (HAL_TIMEx_MasterConfigSynchronization(&htim15, &sMasterConfig) != HAL_OK) | ||||
|   { | ||||
|     if(HAL_TIMEx_MasterConfigSynchronization(&htim15, &sMasterConfig) != HAL_OK) { | ||||
|         Error_Handler(); | ||||
|     } | ||||
|     sConfigOC.OCMode = TIM_OCMODE_TIMING; | ||||
| @ -557,12 +513,10 @@ static void MX_TIM15_Init(void) | ||||
|     sConfigOC.OCFastMode = TIM_OCFAST_DISABLE; | ||||
|     sConfigOC.OCIdleState = TIM_OCIDLESTATE_RESET; | ||||
|     sConfigOC.OCNIdleState = TIM_OCNIDLESTATE_RESET; | ||||
|   if (HAL_TIM_OC_ConfigChannel(&htim15, &sConfigOC, TIM_CHANNEL_1) != HAL_OK) | ||||
|   { | ||||
|     if(HAL_TIM_OC_ConfigChannel(&htim15, &sConfigOC, TIM_CHANNEL_1) != HAL_OK) { | ||||
|         Error_Handler(); | ||||
|     } | ||||
|   if (HAL_TIM_OC_ConfigChannel(&htim15, &sConfigOC, TIM_CHANNEL_2) != HAL_OK) | ||||
|   { | ||||
|     if(HAL_TIM_OC_ConfigChannel(&htim15, &sConfigOC, TIM_CHANNEL_2) != HAL_OK) { | ||||
|         Error_Handler(); | ||||
|     } | ||||
|     sBreakDeadTimeConfig.OffStateRunMode = TIM_OSSR_DISABLE; | ||||
| @ -572,15 +526,13 @@ static void MX_TIM15_Init(void) | ||||
|     sBreakDeadTimeConfig.BreakState = TIM_BREAK_DISABLE; | ||||
|     sBreakDeadTimeConfig.BreakPolarity = TIM_BREAKPOLARITY_HIGH; | ||||
|     sBreakDeadTimeConfig.AutomaticOutput = TIM_AUTOMATICOUTPUT_DISABLE; | ||||
|   if (HAL_TIMEx_ConfigBreakDeadTime(&htim15, &sBreakDeadTimeConfig) != HAL_OK) | ||||
|   { | ||||
|     if(HAL_TIMEx_ConfigBreakDeadTime(&htim15, &sBreakDeadTimeConfig) != HAL_OK) { | ||||
|         Error_Handler(); | ||||
|     } | ||||
|     /* USER CODE BEGIN TIM15_Init 2 */ | ||||
| 
 | ||||
|     /* USER CODE END TIM15_Init 2 */ | ||||
|     HAL_TIM_MspPostInit(&htim15); | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -588,9 +540,7 @@ static void MX_TIM15_Init(void) | ||||
|   * @param None | ||||
|   * @retval None | ||||
|   */ | ||||
| static void MX_USART1_UART_Init(void) | ||||
| { | ||||
| 
 | ||||
| static void MX_USART1_UART_Init(void) { | ||||
|     /* USER CODE BEGIN USART1_Init 0 */ | ||||
| 
 | ||||
|     /* USER CODE END USART1_Init 0 */ | ||||
| @ -608,14 +558,12 @@ static void MX_USART1_UART_Init(void) | ||||
|     huart1.Init.OverSampling = UART_OVERSAMPLING_16; | ||||
|     huart1.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE; | ||||
|     huart1.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT; | ||||
|   if (HAL_UART_Init(&huart1) != HAL_OK) | ||||
|   { | ||||
|     if(HAL_UART_Init(&huart1) != HAL_OK) { | ||||
|         Error_Handler(); | ||||
|     } | ||||
|     /* USER CODE BEGIN USART1_Init 2 */ | ||||
| 
 | ||||
|     /* USER CODE END USART1_Init 2 */ | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -623,8 +571,7 @@ static void MX_USART1_UART_Init(void) | ||||
|   * @param None | ||||
|   * @retval None | ||||
|   */ | ||||
| static void MX_GPIO_Init(void) | ||||
| { | ||||
| static void MX_GPIO_Init(void) { | ||||
|     GPIO_InitTypeDef GPIO_InitStruct = {0}; | ||||
| 
 | ||||
|     /* GPIO Ports Clock Enable */ | ||||
| @ -635,16 +582,16 @@ static void MX_GPIO_Init(void) | ||||
|     __HAL_RCC_GPIOD_CLK_ENABLE(); | ||||
| 
 | ||||
|     /*Configure GPIO pin Output Level */ | ||||
|   HAL_GPIO_WritePin(GPIOA, DISPLAY_DI_Pin|CC1101_CS_Pin, GPIO_PIN_RESET); | ||||
|     HAL_GPIO_WritePin(GPIOA, DISPLAY_DI_Pin | CC1101_CS_Pin, GPIO_PIN_RESET); | ||||
| 
 | ||||
|     /*Configure GPIO pin Output Level */ | ||||
|   HAL_GPIO_WritePin(GPIOC, NFC_CS_Pin|VIBRO_Pin|DISPLAY_CS_Pin|SD_CS_Pin, GPIO_PIN_RESET); | ||||
|     HAL_GPIO_WritePin(GPIOC, NFC_CS_Pin | VIBRO_Pin | DISPLAY_CS_Pin | SD_CS_Pin, GPIO_PIN_RESET); | ||||
| 
 | ||||
|     /*Configure GPIO pin Output Level */ | ||||
|   HAL_GPIO_WritePin(GPIOB, LED_BLUE_Pin|LED_GREEN_Pin, GPIO_PIN_SET); | ||||
|     HAL_GPIO_WritePin(GPIOB, LED_BLUE_Pin | LED_GREEN_Pin, GPIO_PIN_SET); | ||||
| 
 | ||||
|     /*Configure GPIO pin Output Level */ | ||||
|   HAL_GPIO_WritePin(GPIOB, DISPLAY_RST_Pin|IR_TX_Pin|DISPLAY_BACKLIGHT_Pin, GPIO_PIN_RESET); | ||||
|     HAL_GPIO_WritePin(GPIOB, DISPLAY_RST_Pin | IR_TX_Pin | DISPLAY_BACKLIGHT_Pin, GPIO_PIN_RESET); | ||||
| 
 | ||||
|     /*Configure GPIO pin Output Level */ | ||||
|     HAL_GPIO_WritePin(LED_RED_GPIO_Port, LED_RED_Pin, GPIO_PIN_SET); | ||||
| @ -656,7 +603,7 @@ static void MX_GPIO_Init(void) | ||||
|     HAL_GPIO_Init(BUTTON_BACK_GPIO_Port, &GPIO_InitStruct); | ||||
| 
 | ||||
|     /*Configure GPIO pins : PC0 PC1 */ | ||||
|   GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1; | ||||
|     GPIO_InitStruct.Pin = GPIO_PIN_0 | GPIO_PIN_1; | ||||
|     GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; | ||||
|     GPIO_InitStruct.Pull = GPIO_NOPULL; | ||||
|     HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); | ||||
| @ -674,46 +621,46 @@ static void MX_GPIO_Init(void) | ||||
|     HAL_GPIO_Init(BUTTON_DOWN_GPIO_Port, &GPIO_InitStruct); | ||||
| 
 | ||||
|     /*Configure GPIO pins : DISPLAY_DI_Pin CC1101_CS_Pin */ | ||||
|   GPIO_InitStruct.Pin = DISPLAY_DI_Pin|CC1101_CS_Pin; | ||||
|     GPIO_InitStruct.Pin = DISPLAY_DI_Pin | CC1101_CS_Pin; | ||||
|     GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; | ||||
|     GPIO_InitStruct.Pull = GPIO_NOPULL; | ||||
|     GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; | ||||
|     HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); | ||||
| 
 | ||||
|     /*Configure GPIO pins : PA4 PA5 PA6 PA7 */ | ||||
|   GPIO_InitStruct.Pin = GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7; | ||||
|     GPIO_InitStruct.Pin = GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7; | ||||
|     GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; | ||||
|     GPIO_InitStruct.Pull = GPIO_NOPULL; | ||||
|     HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); | ||||
| 
 | ||||
|     /*Configure GPIO pins : NFC_CS_Pin VIBRO_Pin DISPLAY_CS_Pin SD_CS_Pin */ | ||||
|   GPIO_InitStruct.Pin = NFC_CS_Pin|VIBRO_Pin|DISPLAY_CS_Pin|SD_CS_Pin; | ||||
|     GPIO_InitStruct.Pin = NFC_CS_Pin | VIBRO_Pin | DISPLAY_CS_Pin | SD_CS_Pin; | ||||
|     GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; | ||||
|     GPIO_InitStruct.Pull = GPIO_NOPULL; | ||||
|     GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; | ||||
|     HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); | ||||
| 
 | ||||
|     /*Configure GPIO pins : BUTTON_UP_Pin BUTTON_RIGHT_Pin BUTTON_OK_Pin */ | ||||
|   GPIO_InitStruct.Pin = BUTTON_UP_Pin|BUTTON_RIGHT_Pin|BUTTON_OK_Pin; | ||||
|     GPIO_InitStruct.Pin = BUTTON_UP_Pin | BUTTON_RIGHT_Pin | BUTTON_OK_Pin; | ||||
|     GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING; | ||||
|     GPIO_InitStruct.Pull = GPIO_PULLDOWN; | ||||
|     HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); | ||||
| 
 | ||||
|     /*Configure GPIO pins : LED_BLUE_Pin LED_GREEN_Pin */ | ||||
|   GPIO_InitStruct.Pin = LED_BLUE_Pin|LED_GREEN_Pin; | ||||
|     GPIO_InitStruct.Pin = LED_BLUE_Pin | LED_GREEN_Pin; | ||||
|     GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_OD; | ||||
|     GPIO_InitStruct.Pull = GPIO_NOPULL; | ||||
|     GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM; | ||||
|     HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); | ||||
| 
 | ||||
|     /*Configure GPIO pins : PB2 PB12 */ | ||||
|   GPIO_InitStruct.Pin = GPIO_PIN_2|GPIO_PIN_12; | ||||
|     GPIO_InitStruct.Pin = GPIO_PIN_2 | GPIO_PIN_12; | ||||
|     GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; | ||||
|     GPIO_InitStruct.Pull = GPIO_NOPULL; | ||||
|     HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); | ||||
| 
 | ||||
|     /*Configure GPIO pins : DISPLAY_RST_Pin IR_TX_Pin DISPLAY_BACKLIGHT_Pin */ | ||||
|   GPIO_InitStruct.Pin = DISPLAY_RST_Pin|IR_TX_Pin|DISPLAY_BACKLIGHT_Pin; | ||||
|     GPIO_InitStruct.Pin = DISPLAY_RST_Pin | IR_TX_Pin | DISPLAY_BACKLIGHT_Pin; | ||||
|     GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; | ||||
|     GPIO_InitStruct.Pull = GPIO_NOPULL; | ||||
|     GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; | ||||
| @ -759,7 +706,6 @@ static void MX_GPIO_Init(void) | ||||
| 
 | ||||
|     HAL_NVIC_SetPriority(EXTI9_5_IRQn, 5, 0); | ||||
|     HAL_NVIC_EnableIRQ(EXTI9_5_IRQn); | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| /* USER CODE BEGIN 4 */ | ||||
| @ -773,16 +719,14 @@ void app(); | ||||
|   * @retval None | ||||
|   */ | ||||
| /* USER CODE END Header_StartDefaultTask */ | ||||
| void StartDefaultTask(void const * argument) | ||||
| { | ||||
| void StartDefaultTask(void const* argument) { | ||||
|     /* init code for USB_DEVICE */ | ||||
|     MX_USB_DEVICE_Init(); | ||||
|     /* USER CODE BEGIN 5 */ | ||||
|     /* Infinite loop */ | ||||
|     app(); | ||||
| 
 | ||||
|   for(;;) | ||||
|   { | ||||
|     for(;;) { | ||||
|         osDelay(1); | ||||
|     } | ||||
|     /* USER CODE END 5 */ | ||||
| @ -792,8 +736,7 @@ void StartDefaultTask(void const * argument) | ||||
|   * @brief  This function is executed in case of error occurrence. | ||||
|   * @retval None | ||||
|   */ | ||||
| void Error_Handler(void) | ||||
| { | ||||
| void Error_Handler(void) { | ||||
|     /* USER CODE BEGIN Error_Handler_Debug */ | ||||
|     /* User can add his own implementation to report the HAL error return state */ | ||||
| 
 | ||||
| @ -808,8 +751,7 @@ void Error_Handler(void) | ||||
|   * @param  line: assert_param error line source number | ||||
|   * @retval None | ||||
|   */ | ||||
| void assert_failed(char *file, uint32_t line) | ||||
| {  | ||||
| void assert_failed(char* file, uint32_t line) { | ||||
|     /* USER CODE BEGIN 6 */ | ||||
|     /* User can add his own implementation to report the file name and line number,
 | ||||
|      tex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ | ||||
|  | ||||
| @ -59,12 +59,11 @@ | ||||
| 
 | ||||
| /* 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) | ||||
| { | ||||
| void HAL_MspInit(void) { | ||||
|     /* USER CODE BEGIN MspInit 0 */ | ||||
| 
 | ||||
|     /* USER CODE END MspInit 0 */ | ||||
| @ -87,11 +86,9 @@ void HAL_MspInit(void) | ||||
| * @param hadc: ADC handle pointer | ||||
| * @retval None | ||||
| */ | ||||
| void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc) | ||||
| { | ||||
| void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc) { | ||||
|     GPIO_InitTypeDef GPIO_InitStruct = {0}; | ||||
|   if(hadc->Instance==ADC1) | ||||
|   { | ||||
|     if(hadc->Instance == ADC1) { | ||||
|         /* USER CODE BEGIN ADC1_MspInit 0 */ | ||||
| 
 | ||||
|         /* USER CODE END ADC1_MspInit 0 */ | ||||
| @ -118,7 +115,6 @@ void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc) | ||||
| 
 | ||||
|         /* USER CODE END ADC1_MspInit 1 */ | ||||
|     } | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -127,10 +123,8 @@ 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) | ||||
|   { | ||||
| void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc) { | ||||
|     if(hadc->Instance == ADC1) { | ||||
|         /* USER CODE BEGIN ADC1_MspDeInit 0 */ | ||||
| 
 | ||||
|         /* USER CODE END ADC1_MspDeInit 0 */ | ||||
| @ -149,7 +143,6 @@ void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc) | ||||
| 
 | ||||
|         /* USER CODE END ADC1_MspDeInit 1 */ | ||||
|     } | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -158,11 +151,9 @@ void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc) | ||||
| * @param hcomp: COMP handle pointer | ||||
| * @retval None | ||||
| */ | ||||
| void HAL_COMP_MspInit(COMP_HandleTypeDef* hcomp) | ||||
| { | ||||
| void HAL_COMP_MspInit(COMP_HandleTypeDef* hcomp) { | ||||
|     GPIO_InitTypeDef GPIO_InitStruct = {0}; | ||||
|   if(hcomp->Instance==COMP1) | ||||
|   { | ||||
|     if(hcomp->Instance == COMP1) { | ||||
|         /* USER CODE BEGIN COMP1_MspInit 0 */ | ||||
| 
 | ||||
|         /* USER CODE END COMP1_MspInit 0 */ | ||||
| @ -180,7 +171,6 @@ void HAL_COMP_MspInit(COMP_HandleTypeDef* hcomp) | ||||
| 
 | ||||
|         /* USER CODE END COMP1_MspInit 1 */ | ||||
|     } | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -189,10 +179,8 @@ 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) | ||||
|   { | ||||
| void HAL_COMP_MspDeInit(COMP_HandleTypeDef* hcomp) { | ||||
|     if(hcomp->Instance == COMP1) { | ||||
|         /* USER CODE BEGIN COMP1_MspDeInit 0 */ | ||||
| 
 | ||||
|         /* USER CODE END COMP1_MspDeInit 0 */ | ||||
| @ -206,7 +194,6 @@ void HAL_COMP_MspDeInit(COMP_HandleTypeDef* hcomp) | ||||
| 
 | ||||
|         /* USER CODE END COMP1_MspDeInit 1 */ | ||||
|     } | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -215,11 +202,9 @@ void HAL_COMP_MspDeInit(COMP_HandleTypeDef* hcomp) | ||||
| * @param hspi: SPI handle pointer | ||||
| * @retval None | ||||
| */ | ||||
| void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi) | ||||
| { | ||||
| void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi) { | ||||
|     GPIO_InitTypeDef GPIO_InitStruct = {0}; | ||||
|   if(hspi->Instance==SPI1) | ||||
|   { | ||||
|     if(hspi->Instance == SPI1) { | ||||
|         /* USER CODE BEGIN SPI1_MspInit 0 */ | ||||
| 
 | ||||
|         /* USER CODE END SPI1_MspInit 0 */ | ||||
| @ -231,7 +216,7 @@ void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi) | ||||
|     PB3 (JTDO-TRACESWO)     ------> SPI1_SCK | ||||
|     PB5     ------> SPI1_MOSI  | ||||
|     */ | ||||
|     GPIO_InitStruct.Pin = GPIO_PIN_3|GPIO_PIN_5; | ||||
|         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; | ||||
| @ -241,9 +226,7 @@ void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi) | ||||
|         /* USER CODE BEGIN SPI1_MspInit 1 */ | ||||
| 
 | ||||
|         /* USER CODE END SPI1_MspInit 1 */ | ||||
|   } | ||||
|   else if(hspi->Instance==SPI3) | ||||
|   { | ||||
|     } else if(hspi->Instance == SPI3) { | ||||
|         /* USER CODE BEGIN SPI3_MspInit 0 */ | ||||
| 
 | ||||
|         /* USER CODE END SPI3_MspInit 0 */ | ||||
| @ -256,7 +239,7 @@ void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi) | ||||
|     PC11     ------> SPI3_MISO | ||||
|     PC12     ------> SPI3_MOSI  | ||||
|     */ | ||||
|     GPIO_InitStruct.Pin = GPIO_PIN_10|GPIO_PIN_11|GPIO_PIN_12; | ||||
|         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; | ||||
| @ -267,7 +250,6 @@ void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi) | ||||
| 
 | ||||
|         /* USER CODE END SPI3_MspInit 1 */ | ||||
|     } | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -276,10 +258,8 @@ 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) | ||||
|   { | ||||
| void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi) { | ||||
|     if(hspi->Instance == SPI1) { | ||||
|         /* USER CODE BEGIN SPI1_MspDeInit 0 */ | ||||
| 
 | ||||
|         /* USER CODE END SPI1_MspDeInit 0 */ | ||||
| @ -290,14 +270,12 @@ void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi) | ||||
|     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 END SPI1_MspDeInit 1 */ | ||||
|   } | ||||
|   else if(hspi->Instance==SPI3) | ||||
|   { | ||||
|     } else if(hspi->Instance == SPI3) { | ||||
|         /* USER CODE BEGIN SPI3_MspDeInit 0 */ | ||||
| 
 | ||||
|         /* USER CODE END SPI3_MspDeInit 0 */ | ||||
| @ -309,13 +287,12 @@ void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi) | ||||
|     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 */ | ||||
|     } | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -324,10 +301,8 @@ 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) | ||||
|   { | ||||
| 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 */ | ||||
| @ -337,7 +312,6 @@ void HAL_TIM_PWM_MspInit(TIM_HandleTypeDef* htim_pwm) | ||||
| 
 | ||||
|         /* USER CODE END TIM5_MspInit 1 */ | ||||
|     } | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -346,11 +320,9 @@ 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) | ||||
| { | ||||
| void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base) { | ||||
|     GPIO_InitTypeDef GPIO_InitStruct = {0}; | ||||
|   if(htim_base->Instance==TIM8) | ||||
|   { | ||||
|     if(htim_base->Instance == TIM8) { | ||||
|         /* USER CODE BEGIN TIM8_MspInit 0 */ | ||||
| 
 | ||||
|         /* USER CODE END TIM8_MspInit 0 */ | ||||
| @ -375,7 +347,6 @@ void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base) | ||||
| 
 | ||||
|         /* USER CODE END TIM8_MspInit 1 */ | ||||
|     } | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -384,10 +355,8 @@ 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) | ||||
|   { | ||||
| 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 */ | ||||
| @ -397,14 +366,11 @@ void HAL_TIM_OC_MspInit(TIM_HandleTypeDef* htim_oc) | ||||
| 
 | ||||
|         /* USER CODE END TIM15_MspInit 1 */ | ||||
|     } | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim) | ||||
| { | ||||
| void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim) { | ||||
|     GPIO_InitTypeDef GPIO_InitStruct = {0}; | ||||
|   if(htim->Instance==TIM5) | ||||
|   { | ||||
|     if(htim->Instance == TIM5) { | ||||
|         /* USER CODE BEGIN TIM5_MspPostInit 0 */ | ||||
| 
 | ||||
|         /* USER CODE END TIM5_MspPostInit 0 */ | ||||
| @ -422,9 +388,7 @@ void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim) | ||||
|         /* USER CODE BEGIN TIM5_MspPostInit 1 */ | ||||
| 
 | ||||
|         /* USER CODE END TIM5_MspPostInit 1 */ | ||||
|   } | ||||
|   else if(htim->Instance==TIM15) | ||||
|   { | ||||
|     } else if(htim->Instance == TIM15) { | ||||
|         /* USER CODE BEGIN TIM15_MspPostInit 0 */ | ||||
| 
 | ||||
|         /* USER CODE END TIM15_MspPostInit 0 */ | ||||
| @ -434,7 +398,7 @@ void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim) | ||||
|     PB13     ------> TIM15_CH1N | ||||
|     PB15     ------> TIM15_CH2  | ||||
|     */ | ||||
|     GPIO_InitStruct.Pin = RFID_OUT_Pin|RFID_PULL_Pin; | ||||
|         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; | ||||
| @ -445,7 +409,6 @@ void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim) | ||||
| 
 | ||||
|         /* USER CODE END TIM15_MspPostInit 1 */ | ||||
|     } | ||||
| 
 | ||||
| } | ||||
| /**
 | ||||
| * @brief TIM_PWM MSP De-Initialization | ||||
| @ -453,10 +416,8 @@ 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) | ||||
|   { | ||||
| 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 */ | ||||
| @ -466,7 +427,6 @@ void HAL_TIM_PWM_MspDeInit(TIM_HandleTypeDef* htim_pwm) | ||||
| 
 | ||||
|         /* USER CODE END TIM5_MspDeInit 1 */ | ||||
|     } | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -475,10 +435,8 @@ 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) | ||||
|   { | ||||
| 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 */ | ||||
| @ -496,7 +454,6 @@ void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* htim_base) | ||||
| 
 | ||||
|         /* USER CODE END TIM8_MspDeInit 1 */ | ||||
|     } | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -505,10 +462,8 @@ 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) | ||||
|   { | ||||
| 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 */ | ||||
| @ -518,7 +473,6 @@ void HAL_TIM_OC_MspDeInit(TIM_HandleTypeDef* htim_oc) | ||||
| 
 | ||||
|         /* USER CODE END TIM15_MspDeInit 1 */ | ||||
|     } | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -527,11 +481,9 @@ void HAL_TIM_OC_MspDeInit(TIM_HandleTypeDef* htim_oc) | ||||
| * @param huart: UART handle pointer | ||||
| * @retval None | ||||
| */ | ||||
| void HAL_UART_MspInit(UART_HandleTypeDef* huart) | ||||
| { | ||||
| void HAL_UART_MspInit(UART_HandleTypeDef* huart) { | ||||
|     GPIO_InitTypeDef GPIO_InitStruct = {0}; | ||||
|   if(huart->Instance==USART1) | ||||
|   { | ||||
|     if(huart->Instance == USART1) { | ||||
|         /* USER CODE BEGIN USART1_MspInit 0 */ | ||||
| 
 | ||||
|         /* USER CODE END USART1_MspInit 0 */ | ||||
| @ -543,7 +495,7 @@ void HAL_UART_MspInit(UART_HandleTypeDef* huart) | ||||
|     PA9     ------> USART1_TX | ||||
|     PA10     ------> USART1_RX  | ||||
|     */ | ||||
|     GPIO_InitStruct.Pin = GPIO_PIN_9|GPIO_PIN_10; | ||||
|         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; | ||||
| @ -554,7 +506,6 @@ void HAL_UART_MspInit(UART_HandleTypeDef* huart) | ||||
| 
 | ||||
|         /* USER CODE END USART1_MspInit 1 */ | ||||
|     } | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -563,10 +514,8 @@ 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) | ||||
|   { | ||||
| void HAL_UART_MspDeInit(UART_HandleTypeDef* huart) { | ||||
|     if(huart->Instance == USART1) { | ||||
|         /* USER CODE BEGIN USART1_MspDeInit 0 */ | ||||
| 
 | ||||
|         /* USER CODE END USART1_MspDeInit 0 */ | ||||
| @ -577,13 +526,12 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef* huart) | ||||
|     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 1 */ | ||||
|  | ||||
| @ -70,8 +70,7 @@ extern TIM_HandleTypeDef htim8; | ||||
| /**
 | ||||
|   * @brief This function handles Non maskable interrupt. | ||||
|   */ | ||||
| void NMI_Handler(void) | ||||
| { | ||||
| void NMI_Handler(void) { | ||||
|     /* USER CODE BEGIN NonMaskableInt_IRQn 0 */ | ||||
| 
 | ||||
|     /* USER CODE END NonMaskableInt_IRQn 0 */ | ||||
| @ -83,13 +82,11 @@ void NMI_Handler(void) | ||||
| /**
 | ||||
|   * @brief This function handles Hard fault interrupt. | ||||
|   */ | ||||
| void HardFault_Handler(void) | ||||
| { | ||||
| void HardFault_Handler(void) { | ||||
|     /* USER CODE BEGIN HardFault_IRQn 0 */ | ||||
| 
 | ||||
|     /* USER CODE END HardFault_IRQn 0 */ | ||||
|   while (1) | ||||
|   { | ||||
|     while(1) { | ||||
|         /* USER CODE BEGIN W1_HardFault_IRQn 0 */ | ||||
|         /* USER CODE END W1_HardFault_IRQn 0 */ | ||||
|     } | ||||
| @ -98,13 +95,11 @@ void HardFault_Handler(void) | ||||
| /**
 | ||||
|   * @brief This function handles Memory management fault. | ||||
|   */ | ||||
| void MemManage_Handler(void) | ||||
| { | ||||
| void MemManage_Handler(void) { | ||||
|     /* USER CODE BEGIN MemoryManagement_IRQn 0 */ | ||||
| 
 | ||||
|     /* USER CODE END MemoryManagement_IRQn 0 */ | ||||
|   while (1) | ||||
|   { | ||||
|     while(1) { | ||||
|         /* USER CODE BEGIN W1_MemoryManagement_IRQn 0 */ | ||||
|         /* USER CODE END W1_MemoryManagement_IRQn 0 */ | ||||
|     } | ||||
| @ -113,13 +108,11 @@ void MemManage_Handler(void) | ||||
| /**
 | ||||
|   * @brief This function handles Prefetch fault, memory access fault. | ||||
|   */ | ||||
| void BusFault_Handler(void) | ||||
| { | ||||
| void BusFault_Handler(void) { | ||||
|     /* USER CODE BEGIN BusFault_IRQn 0 */ | ||||
| 
 | ||||
|     /* USER CODE END BusFault_IRQn 0 */ | ||||
|   while (1) | ||||
|   { | ||||
|     while(1) { | ||||
|         /* USER CODE BEGIN W1_BusFault_IRQn 0 */ | ||||
|         /* USER CODE END W1_BusFault_IRQn 0 */ | ||||
|     } | ||||
| @ -128,13 +121,11 @@ void BusFault_Handler(void) | ||||
| /**
 | ||||
|   * @brief This function handles Undefined instruction or illegal state. | ||||
|   */ | ||||
| void UsageFault_Handler(void) | ||||
| { | ||||
| void UsageFault_Handler(void) { | ||||
|     /* USER CODE BEGIN UsageFault_IRQn 0 */ | ||||
| 
 | ||||
|     /* USER CODE END UsageFault_IRQn 0 */ | ||||
|   while (1) | ||||
|   { | ||||
|     while(1) { | ||||
|         /* USER CODE BEGIN W1_UsageFault_IRQn 0 */ | ||||
|         /* USER CODE END W1_UsageFault_IRQn 0 */ | ||||
|     } | ||||
| @ -143,8 +134,7 @@ void UsageFault_Handler(void) | ||||
| /**
 | ||||
|   * @brief This function handles Debug monitor. | ||||
|   */ | ||||
| void DebugMon_Handler(void) | ||||
| { | ||||
| void DebugMon_Handler(void) { | ||||
|     /* USER CODE BEGIN DebugMonitor_IRQn 0 */ | ||||
| 
 | ||||
|     /* USER CODE END DebugMonitor_IRQn 0 */ | ||||
| @ -156,18 +146,16 @@ void DebugMon_Handler(void) | ||||
| /**
 | ||||
|   * @brief This function handles System tick timer. | ||||
|   */ | ||||
| void SysTick_Handler(void) | ||||
| { | ||||
| 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) | ||||
|   { | ||||
| #if(INCLUDE_xTaskGetSchedulerState == 1) | ||||
|     if(xTaskGetSchedulerState() != taskSCHEDULER_NOT_STARTED) { | ||||
| #endif /* INCLUDE_xTaskGetSchedulerState */ | ||||
|         xPortSysTickHandler(); | ||||
| #if (INCLUDE_xTaskGetSchedulerState == 1 ) | ||||
| #if(INCLUDE_xTaskGetSchedulerState == 1) | ||||
|     } | ||||
| #endif /* INCLUDE_xTaskGetSchedulerState */ | ||||
|     /* USER CODE BEGIN SysTick_IRQn 1 */ | ||||
| @ -185,8 +173,7 @@ void SysTick_Handler(void) | ||||
| /**
 | ||||
|   * @brief This function handles EXTI line0 interrupt. | ||||
|   */ | ||||
| void EXTI0_IRQHandler(void) | ||||
| { | ||||
| void EXTI0_IRQHandler(void) { | ||||
|     /* USER CODE BEGIN EXTI0_IRQn 0 */ | ||||
| 
 | ||||
|     /* USER CODE END EXTI0_IRQn 0 */ | ||||
| @ -199,8 +186,7 @@ void EXTI0_IRQHandler(void) | ||||
| /**
 | ||||
|   * @brief This function handles EXTI line1 interrupt. | ||||
|   */ | ||||
| void EXTI1_IRQHandler(void) | ||||
| { | ||||
| void EXTI1_IRQHandler(void) { | ||||
|     /* USER CODE BEGIN EXTI1_IRQn 0 */ | ||||
| 
 | ||||
|     /* USER CODE END EXTI1_IRQn 0 */ | ||||
| @ -213,8 +199,7 @@ void EXTI1_IRQHandler(void) | ||||
| /**
 | ||||
|   * @brief This function handles EXTI line2 interrupt. | ||||
|   */ | ||||
| void EXTI2_IRQHandler(void) | ||||
| { | ||||
| void EXTI2_IRQHandler(void) { | ||||
|     /* USER CODE BEGIN EXTI2_IRQn 0 */ | ||||
| 
 | ||||
|     /* USER CODE END EXTI2_IRQn 0 */ | ||||
| @ -227,8 +212,7 @@ void EXTI2_IRQHandler(void) | ||||
| /**
 | ||||
|   * @brief This function handles EXTI line4 interrupt. | ||||
|   */ | ||||
| void EXTI4_IRQHandler(void) | ||||
| { | ||||
| void EXTI4_IRQHandler(void) { | ||||
|     /* USER CODE BEGIN EXTI4_IRQn 0 */ | ||||
| 
 | ||||
|     /* USER CODE END EXTI4_IRQn 0 */ | ||||
| @ -241,8 +225,7 @@ void EXTI4_IRQHandler(void) | ||||
| /**
 | ||||
|   * @brief This function handles EXTI line[9:5] interrupts. | ||||
|   */ | ||||
| void EXTI9_5_IRQHandler(void) | ||||
| { | ||||
| void EXTI9_5_IRQHandler(void) { | ||||
|     /* USER CODE BEGIN EXTI9_5_IRQn 0 */ | ||||
| 
 | ||||
|     /* USER CODE END EXTI9_5_IRQn 0 */ | ||||
| @ -254,29 +237,25 @@ void EXTI9_5_IRQHandler(void) | ||||
|     /* 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)) { | ||||
| 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) | ||||
| { | ||||
| 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) | ||||
|     { | ||||
|     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((htim8.Instance->CCMR1 & TIM_CCMR1_CC2S) != 0x00U) { | ||||
|                 /*
 | ||||
| #if (USE_HAL_TIM_REGISTER_CALLBACKS == 1) | ||||
|         htim->IC_CaptureCallback(htim); | ||||
| #else | ||||
| @ -288,12 +267,11 @@ void TIM8_CC_IRQHandler(void) | ||||
|                 } | ||||
|             } | ||||
|             /* Output compare event */ | ||||
|       else | ||||
|       { | ||||
|             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); | ||||
| @ -307,7 +285,6 @@ void TIM8_CC_IRQHandler(void) | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
|     /* USER CODE END TIM8_CC_IRQn 0 */ | ||||
|     // HAL_TIM_IRQHandler(&htim8);
 | ||||
|     /* USER CODE BEGIN TIM8_CC_IRQn 1 */ | ||||
| @ -318,8 +295,7 @@ void TIM8_CC_IRQHandler(void) | ||||
| /**
 | ||||
|   * @brief This function handles USB OTG FS global interrupt. | ||||
|   */ | ||||
| void OTG_FS_IRQHandler(void) | ||||
| { | ||||
| void OTG_FS_IRQHandler(void) { | ||||
|     /* USER CODE BEGIN OTG_FS_IRQn 0 */ | ||||
| 
 | ||||
|     /* USER CODE END OTG_FS_IRQn 0 */ | ||||
|  | ||||
| @ -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,12 +188,11 @@ | ||||
|   * @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 */ | ||||
| @ -253,25 +263,20 @@ void SystemInit(void) | ||||
|   * @param  None | ||||
|   * @retval None | ||||
|   */ | ||||
| void SystemCoreClockUpdate(void) | ||||
| { | ||||
| 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 */ | ||||
|     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 */ | ||||
|     } 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) | ||||
|   { | ||||
|     switch(RCC->CFGR & RCC_CFGR_SWS) { | ||||
|     case 0x00: /* MSI used as system clock source */ | ||||
|         SystemCoreClock = msirange; | ||||
|         break; | ||||
| @ -289,10 +294,9 @@ void SystemCoreClockUpdate(void) | ||||
|          SYSCLK = PLL_VCO / PLLR | ||||
|          */ | ||||
|         pllsource = (RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC); | ||||
|       pllm = ((RCC->PLLCFGR & RCC_PLLCFGR_PLLM) >> 4U) + 1U ; | ||||
|         pllm = ((RCC->PLLCFGR & RCC_PLLCFGR_PLLM) >> 4U) + 1U; | ||||
| 
 | ||||
|       switch (pllsource) | ||||
|       { | ||||
|         switch(pllsource) { | ||||
|         case 0x02: /* HSI used as PLL clock source */ | ||||
|             pllvco = (HSI_VALUE / pllm); | ||||
|             break; | ||||
| @ -307,7 +311,7 @@ void SystemCoreClockUpdate(void) | ||||
|         } | ||||
|         pllvco = pllvco * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 8U); | ||||
|         pllr = (((RCC->PLLCFGR & RCC_PLLCFGR_PLLR) >> 25U) + 1U) * 2U; | ||||
|       SystemCoreClock = pllvco/pllr; | ||||
|         SystemCoreClock = pllvco / pllr; | ||||
|         break; | ||||
| 
 | ||||
|     default: | ||||
| @ -321,7 +325,6 @@ void SystemCoreClockUpdate(void) | ||||
|     SystemCoreClock >>= tmp; | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| /**
 | ||||
|   * @} | ||||
|   */ | ||||
|  | ||||
| @ -63,27 +63,22 @@ extern USBD_DescriptorsTypeDef FS_Desc; | ||||
|   * Init USB device Library, add supported class and start the library | ||||
|   * @retval None | ||||
|   */ | ||||
| void MX_USB_DEVICE_Init(void) | ||||
| { | ||||
| void MX_USB_DEVICE_Init(void) { | ||||
|     /* USER CODE BEGIN 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) | ||||
|   { | ||||
|     if(USBD_Init(&hUsbDeviceFS, &FS_Desc, DEVICE_FS) != USBD_OK) { | ||||
|         Error_Handler(); | ||||
|     } | ||||
|   if (USBD_RegisterClass(&hUsbDeviceFS, &USBD_CDC) != USBD_OK) | ||||
|   { | ||||
|     if(USBD_RegisterClass(&hUsbDeviceFS, &USBD_CDC) != USBD_OK) { | ||||
|         Error_Handler(); | ||||
|     } | ||||
|   if (USBD_CDC_RegisterInterface(&hUsbDeviceFS, &USBD_Interface_fops_FS) != USBD_OK) | ||||
|   { | ||||
|     if(USBD_CDC_RegisterInterface(&hUsbDeviceFS, &USBD_Interface_fops_FS) != USBD_OK) { | ||||
|         Error_Handler(); | ||||
|     } | ||||
|   if (USBD_Start(&hUsbDeviceFS) != USBD_OK) | ||||
|   { | ||||
|     if(USBD_Start(&hUsbDeviceFS) != USBD_OK) { | ||||
|         Error_Handler(); | ||||
|     } | ||||
|     /* USER CODE BEGIN USB_DEVICE_Init_PostTreatment */ | ||||
|  | ||||
| @ -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,21 +139,17 @@ static int8_t CDC_Receive_FS(uint8_t* pbuf, uint32_t *Len); | ||||
|   * @} | ||||
|   */ | ||||
| 
 | ||||
| USBD_CDC_ItfTypeDef USBD_Interface_fops_FS = | ||||
| { | ||||
|   CDC_Init_FS, | ||||
| USBD_CDC_ItfTypeDef USBD_Interface_fops_FS = {CDC_Init_FS, | ||||
|                                               CDC_DeInit_FS, | ||||
|                                               CDC_Control_FS, | ||||
|   CDC_Receive_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) | ||||
| { | ||||
| static int8_t CDC_Init_FS(void) { | ||||
|     /* USER CODE BEGIN 3 */ | ||||
|     /* Set Application Buffers */ | ||||
|     USBD_CDC_SetTxBuffer(&hUsbDeviceFS, UserTxBufferFS, 0); | ||||
| @ -166,8 +162,7 @@ static int8_t CDC_Init_FS(void) | ||||
|   * @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) | ||||
| { | ||||
| static int8_t CDC_DeInit_FS(void) { | ||||
|     /* USER CODE BEGIN 4 */ | ||||
|     return (USBD_OK); | ||||
|     /* USER CODE END 4 */ | ||||
| @ -180,11 +175,9 @@ 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) | ||||
| { | ||||
| static int8_t CDC_Control_FS(uint8_t cmd, uint8_t* pbuf, uint16_t length) { | ||||
|     /* USER CODE BEGIN 5 */ | ||||
|   switch(cmd) | ||||
|   { | ||||
|     switch(cmd) { | ||||
|     case CDC_SEND_ENCAPSULATED_COMMAND: | ||||
| 
 | ||||
|         break; | ||||
| @ -260,8 +253,7 @@ 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) | ||||
| { | ||||
| 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); | ||||
| @ -280,12 +272,11 @@ 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 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){ | ||||
|     USBD_CDC_HandleTypeDef* hcdc = (USBD_CDC_HandleTypeDef*)hUsbDeviceFS.pClassData; | ||||
|     if(hcdc->TxState != 0) { | ||||
|         return USBD_BUSY; | ||||
|     } | ||||
|     USBD_CDC_SetTxBuffer(&hUsbDeviceFS, Buf, Len); | ||||
|  | ||||
| @ -47,7 +47,7 @@ void Error_Handler(void); | ||||
| /* USER CODE END 0 */ | ||||
| 
 | ||||
| /* Exported function prototypes ----------------------------------------------*/ | ||||
| extern USBD_StatusTypeDef USBD_LL_BatteryCharging(USBD_HandleTypeDef *pdev); | ||||
| extern USBD_StatusTypeDef USBD_LL_BatteryCharging(USBD_HandleTypeDef* pdev); | ||||
| 
 | ||||
| /* USER CODE BEGIN PFP */ | ||||
| /* Private function prototypes -----------------------------------------------*/ | ||||
| @ -67,11 +67,9 @@ extern void SystemClock_Config(void); | ||||
| *******************************************************************************/ | ||||
| /* MSP Init */ | ||||
| 
 | ||||
| void HAL_PCD_MspInit(PCD_HandleTypeDef* pcdHandle) | ||||
| { | ||||
| void HAL_PCD_MspInit(PCD_HandleTypeDef* pcdHandle) { | ||||
|     GPIO_InitTypeDef GPIO_InitStruct = {0}; | ||||
|   if(pcdHandle->Instance==USB_OTG_FS) | ||||
|   { | ||||
|     if(pcdHandle->Instance == USB_OTG_FS) { | ||||
|         /* USER CODE BEGIN USB_OTG_FS_MspInit 0 */ | ||||
| 
 | ||||
|         /* USER CODE END USB_OTG_FS_MspInit 0 */ | ||||
| @ -81,7 +79,7 @@ void HAL_PCD_MspInit(PCD_HandleTypeDef* pcdHandle) | ||||
|     PA11     ------> USB_OTG_FS_DM | ||||
|     PA12     ------> USB_OTG_FS_DP  | ||||
|     */ | ||||
|     GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_12; | ||||
|         GPIO_InitStruct.Pin = 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; | ||||
| @ -92,14 +90,11 @@ void HAL_PCD_MspInit(PCD_HandleTypeDef* pcdHandle) | ||||
|         __HAL_RCC_USB_OTG_FS_CLK_ENABLE(); | ||||
| 
 | ||||
|         /* Enable VDDUSB */ | ||||
|     if(__HAL_RCC_PWR_IS_CLK_DISABLED()) | ||||
|     { | ||||
|         if(__HAL_RCC_PWR_IS_CLK_DISABLED()) { | ||||
|             __HAL_RCC_PWR_CLK_ENABLE(); | ||||
|             HAL_PWREx_EnableVddUSB(); | ||||
|             __HAL_RCC_PWR_CLK_DISABLE(); | ||||
|     } | ||||
|     else | ||||
|     { | ||||
|         } else { | ||||
|             HAL_PWREx_EnableVddUSB(); | ||||
|         } | ||||
| 
 | ||||
| @ -112,10 +107,8 @@ void HAL_PCD_MspInit(PCD_HandleTypeDef* pcdHandle) | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void HAL_PCD_MspDeInit(PCD_HandleTypeDef* pcdHandle) | ||||
| { | ||||
|   if(pcdHandle->Instance==USB_OTG_FS) | ||||
|   { | ||||
| void HAL_PCD_MspDeInit(PCD_HandleTypeDef* pcdHandle) { | ||||
|     if(pcdHandle->Instance == USB_OTG_FS) { | ||||
|         /* USER CODE BEGIN USB_OTG_FS_MspDeInit 0 */ | ||||
| 
 | ||||
|         /* USER CODE END USB_OTG_FS_MspDeInit 0 */ | ||||
| @ -126,17 +119,14 @@ void HAL_PCD_MspDeInit(PCD_HandleTypeDef* pcdHandle) | ||||
|     PA11     ------> USB_OTG_FS_DM | ||||
|     PA12     ------> USB_OTG_FS_DP  | ||||
|     */ | ||||
|     HAL_GPIO_DeInit(GPIOA, GPIO_PIN_11|GPIO_PIN_12); | ||||
|         HAL_GPIO_DeInit(GPIOA, GPIO_PIN_11 | GPIO_PIN_12); | ||||
| 
 | ||||
|         /* Disable VDDUSB */ | ||||
|     if(__HAL_RCC_PWR_IS_CLK_DISABLED()) | ||||
|     { | ||||
|         if(__HAL_RCC_PWR_IS_CLK_DISABLED()) { | ||||
|             __HAL_RCC_PWR_CLK_ENABLE(); | ||||
|             HAL_PWREx_DisableVddUSB(); | ||||
|             __HAL_RCC_PWR_CLK_DISABLE(); | ||||
|     } | ||||
|     else | ||||
|     { | ||||
|         } else { | ||||
|             HAL_PWREx_DisableVddUSB(); | ||||
|         } | ||||
| 
 | ||||
| @ -154,13 +144,13 @@ void HAL_PCD_MspDeInit(PCD_HandleTypeDef* pcdHandle) | ||||
|   * @param  hpcd: PCD handle | ||||
|   * @retval None | ||||
|   */ | ||||
| #if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) | ||||
| static void PCD_SetupStageCallback(PCD_HandleTypeDef *hpcd) | ||||
| #if(USE_HAL_PCD_REGISTER_CALLBACKS == 1U) | ||||
| static void PCD_SetupStageCallback(PCD_HandleTypeDef* hpcd) | ||||
| #else | ||||
| void HAL_PCD_SetupStageCallback(PCD_HandleTypeDef *hpcd) | ||||
| void HAL_PCD_SetupStageCallback(PCD_HandleTypeDef* hpcd) | ||||
| #endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ | ||||
| { | ||||
|   USBD_LL_SetupStage((USBD_HandleTypeDef*)hpcd->pData, (uint8_t *)hpcd->Setup); | ||||
|     USBD_LL_SetupStage((USBD_HandleTypeDef*)hpcd->pData, (uint8_t*)hpcd->Setup); | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -169,10 +159,10 @@ void HAL_PCD_SetupStageCallback(PCD_HandleTypeDef *hpcd) | ||||
|   * @param  epnum: Endpoint number | ||||
|   * @retval None | ||||
|   */ | ||||
| #if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) | ||||
| static void PCD_DataOutStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) | ||||
| #if(USE_HAL_PCD_REGISTER_CALLBACKS == 1U) | ||||
| static void PCD_DataOutStageCallback(PCD_HandleTypeDef* hpcd, uint8_t epnum) | ||||
| #else | ||||
| void HAL_PCD_DataOutStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) | ||||
| void HAL_PCD_DataOutStageCallback(PCD_HandleTypeDef* hpcd, uint8_t epnum) | ||||
| #endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ | ||||
| { | ||||
|     USBD_LL_DataOutStage((USBD_HandleTypeDef*)hpcd->pData, epnum, hpcd->OUT_ep[epnum].xfer_buff); | ||||
| @ -184,10 +174,10 @@ void HAL_PCD_DataOutStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) | ||||
|   * @param  epnum: Endpoint number | ||||
|   * @retval None | ||||
|   */ | ||||
| #if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) | ||||
| static void PCD_DataInStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) | ||||
| #if(USE_HAL_PCD_REGISTER_CALLBACKS == 1U) | ||||
| static void PCD_DataInStageCallback(PCD_HandleTypeDef* hpcd, uint8_t epnum) | ||||
| #else | ||||
| void HAL_PCD_DataInStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) | ||||
| void HAL_PCD_DataInStageCallback(PCD_HandleTypeDef* hpcd, uint8_t epnum) | ||||
| #endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ | ||||
| { | ||||
|     USBD_LL_DataInStage((USBD_HandleTypeDef*)hpcd->pData, epnum, hpcd->IN_ep[epnum].xfer_buff); | ||||
| @ -198,10 +188,10 @@ void HAL_PCD_DataInStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) | ||||
|   * @param  hpcd: PCD handle | ||||
|   * @retval None | ||||
|   */ | ||||
| #if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) | ||||
| static void PCD_SOFCallback(PCD_HandleTypeDef *hpcd) | ||||
| #if(USE_HAL_PCD_REGISTER_CALLBACKS == 1U) | ||||
| static void PCD_SOFCallback(PCD_HandleTypeDef* hpcd) | ||||
| #else | ||||
| void HAL_PCD_SOFCallback(PCD_HandleTypeDef *hpcd) | ||||
| void HAL_PCD_SOFCallback(PCD_HandleTypeDef* hpcd) | ||||
| #endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ | ||||
| { | ||||
|     USBD_LL_SOF((USBD_HandleTypeDef*)hpcd->pData); | ||||
| @ -212,16 +202,15 @@ void HAL_PCD_SOFCallback(PCD_HandleTypeDef *hpcd) | ||||
|   * @param  hpcd: PCD handle | ||||
|   * @retval None | ||||
|   */ | ||||
| #if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) | ||||
| static void PCD_ResetCallback(PCD_HandleTypeDef *hpcd) | ||||
| #if(USE_HAL_PCD_REGISTER_CALLBACKS == 1U) | ||||
| static void PCD_ResetCallback(PCD_HandleTypeDef* hpcd) | ||||
| #else | ||||
| void HAL_PCD_ResetCallback(PCD_HandleTypeDef *hpcd) | ||||
| void HAL_PCD_ResetCallback(PCD_HandleTypeDef* hpcd) | ||||
| #endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ | ||||
| { | ||||
|     USBD_SpeedTypeDef speed = USBD_SPEED_FULL; | ||||
| 
 | ||||
|   if ( hpcd->Init.speed != PCD_SPEED_FULL) | ||||
|   { | ||||
|     if(hpcd->Init.speed != PCD_SPEED_FULL) { | ||||
|         Error_Handler(); | ||||
|     } | ||||
|     /* Set Speed. */ | ||||
| @ -237,10 +226,10 @@ void HAL_PCD_ResetCallback(PCD_HandleTypeDef *hpcd) | ||||
|   * @param  hpcd: PCD handle | ||||
|   * @retval None | ||||
|   */ | ||||
| #if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) | ||||
| static void PCD_SuspendCallback(PCD_HandleTypeDef *hpcd) | ||||
| #if(USE_HAL_PCD_REGISTER_CALLBACKS == 1U) | ||||
| static void PCD_SuspendCallback(PCD_HandleTypeDef* hpcd) | ||||
| #else | ||||
| void HAL_PCD_SuspendCallback(PCD_HandleTypeDef *hpcd) | ||||
| void HAL_PCD_SuspendCallback(PCD_HandleTypeDef* hpcd) | ||||
| #endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ | ||||
| { | ||||
|     __HAL_PCD_GATE_PHYCLOCK(hpcd); | ||||
| @ -248,8 +237,7 @@ void HAL_PCD_SuspendCallback(PCD_HandleTypeDef *hpcd) | ||||
|     USBD_LL_Suspend((USBD_HandleTypeDef*)hpcd->pData); | ||||
|     /* Enter in STOP mode. */ | ||||
|     /* USER CODE BEGIN 2 */ | ||||
|   if (hpcd->Init.low_power_enable) | ||||
|   { | ||||
|     if(hpcd->Init.low_power_enable) { | ||||
|         /* Set SLEEPDEEP bit and SleepOnExit of Cortex System Control Register. */ | ||||
|         SCB->SCR |= (uint32_t)((uint32_t)(SCB_SCR_SLEEPDEEP_Msk | SCB_SCR_SLEEPONEXIT_Msk)); | ||||
|     } | ||||
| @ -262,19 +250,18 @@ void HAL_PCD_SuspendCallback(PCD_HandleTypeDef *hpcd) | ||||
|   * @param  hpcd: PCD handle | ||||
|   * @retval None | ||||
|   */ | ||||
| #if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) | ||||
| static void PCD_ResumeCallback(PCD_HandleTypeDef *hpcd) | ||||
| #if(USE_HAL_PCD_REGISTER_CALLBACKS == 1U) | ||||
| static void PCD_ResumeCallback(PCD_HandleTypeDef* hpcd) | ||||
| #else | ||||
| void HAL_PCD_ResumeCallback(PCD_HandleTypeDef *hpcd) | ||||
| void HAL_PCD_ResumeCallback(PCD_HandleTypeDef* hpcd) | ||||
| #endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ | ||||
| { | ||||
|     __HAL_PCD_UNGATE_PHYCLOCK(hpcd); | ||||
| 
 | ||||
|     /* USER CODE BEGIN 3 */ | ||||
|   if (hpcd->Init.low_power_enable) | ||||
|   { | ||||
|     if(hpcd->Init.low_power_enable) { | ||||
|         /* Reset SLEEPDEEP bit of Cortex System Control Register. */ | ||||
|     SCB->SCR &= (uint32_t)~((uint32_t)(SCB_SCR_SLEEPDEEP_Msk | SCB_SCR_SLEEPONEXIT_Msk)); | ||||
|         SCB->SCR &= (uint32_t) ~((uint32_t)(SCB_SCR_SLEEPDEEP_Msk | SCB_SCR_SLEEPONEXIT_Msk)); | ||||
|         SystemClockConfig_Resume(); | ||||
|     } | ||||
|     /* USER CODE END 3 */ | ||||
| @ -287,10 +274,10 @@ void HAL_PCD_ResumeCallback(PCD_HandleTypeDef *hpcd) | ||||
|   * @param  epnum: Endpoint number | ||||
|   * @retval None | ||||
|   */ | ||||
| #if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) | ||||
| static void PCD_ISOOUTIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) | ||||
| #if(USE_HAL_PCD_REGISTER_CALLBACKS == 1U) | ||||
| static void PCD_ISOOUTIncompleteCallback(PCD_HandleTypeDef* hpcd, uint8_t epnum) | ||||
| #else | ||||
| void HAL_PCD_ISOOUTIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) | ||||
| void HAL_PCD_ISOOUTIncompleteCallback(PCD_HandleTypeDef* hpcd, uint8_t epnum) | ||||
| #endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ | ||||
| { | ||||
|     USBD_LL_IsoOUTIncomplete((USBD_HandleTypeDef*)hpcd->pData, epnum); | ||||
| @ -302,10 +289,10 @@ void HAL_PCD_ISOOUTIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) | ||||
|   * @param  epnum: Endpoint number | ||||
|   * @retval None | ||||
|   */ | ||||
| #if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) | ||||
| static void PCD_ISOINIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) | ||||
| #if(USE_HAL_PCD_REGISTER_CALLBACKS == 1U) | ||||
| static void PCD_ISOINIncompleteCallback(PCD_HandleTypeDef* hpcd, uint8_t epnum) | ||||
| #else | ||||
| void HAL_PCD_ISOINIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) | ||||
| void HAL_PCD_ISOINIncompleteCallback(PCD_HandleTypeDef* hpcd, uint8_t epnum) | ||||
| #endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ | ||||
| { | ||||
|     USBD_LL_IsoINIncomplete((USBD_HandleTypeDef*)hpcd->pData, epnum); | ||||
| @ -316,10 +303,10 @@ void HAL_PCD_ISOINIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) | ||||
|   * @param  hpcd: PCD handle | ||||
|   * @retval None | ||||
|   */ | ||||
| #if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) | ||||
| static void PCD_ConnectCallback(PCD_HandleTypeDef *hpcd) | ||||
| #if(USE_HAL_PCD_REGISTER_CALLBACKS == 1U) | ||||
| static void PCD_ConnectCallback(PCD_HandleTypeDef* hpcd) | ||||
| #else | ||||
| void HAL_PCD_ConnectCallback(PCD_HandleTypeDef *hpcd) | ||||
| void HAL_PCD_ConnectCallback(PCD_HandleTypeDef* hpcd) | ||||
| #endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ | ||||
| { | ||||
|     // TODO send UsbConnect event to FURI
 | ||||
| @ -332,10 +319,10 @@ void HAL_PCD_ConnectCallback(PCD_HandleTypeDef *hpcd) | ||||
|   * @param  hpcd: PCD handle | ||||
|   * @retval None | ||||
|   */ | ||||
| #if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) | ||||
| static void PCD_DisconnectCallback(PCD_HandleTypeDef *hpcd) | ||||
| #if(USE_HAL_PCD_REGISTER_CALLBACKS == 1U) | ||||
| static void PCD_DisconnectCallback(PCD_HandleTypeDef* hpcd) | ||||
| #else | ||||
| void HAL_PCD_DisconnectCallback(PCD_HandleTypeDef *hpcd) | ||||
| void HAL_PCD_DisconnectCallback(PCD_HandleTypeDef* hpcd) | ||||
| #endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ | ||||
| { | ||||
|     // TODO send UsbDisconnect event to FURI
 | ||||
| @ -352,10 +339,9 @@ void HAL_PCD_DisconnectCallback(PCD_HandleTypeDef *hpcd) | ||||
|   * @param  pdev: Device handle | ||||
|   * @retval USBD status | ||||
|   */ | ||||
| USBD_StatusTypeDef USBD_LL_Init(USBD_HandleTypeDef *pdev) | ||||
| { | ||||
| USBD_StatusTypeDef USBD_LL_Init(USBD_HandleTypeDef* pdev) { | ||||
|     /* Init USB Ip. */ | ||||
|   if (pdev->id == DEVICE_FS) { | ||||
|     if(pdev->id == DEVICE_FS) { | ||||
|         /* Enable USB power on Pwrctrl CR2 register. */ | ||||
|         /* Link the driver to the stack. */ | ||||
|         hpcd_USB_OTG_FS.pData = pdev; | ||||
| @ -371,20 +357,21 @@ USBD_StatusTypeDef USBD_LL_Init(USBD_HandleTypeDef *pdev) | ||||
|         hpcd_USB_OTG_FS.Init.battery_charging_enable = DISABLE; | ||||
|         hpcd_USB_OTG_FS.Init.use_dedicated_ep1 = DISABLE; | ||||
|         hpcd_USB_OTG_FS.Init.vbus_sensing_enable = DISABLE; | ||||
|   if (HAL_PCD_Init(&hpcd_USB_OTG_FS) != HAL_OK) | ||||
|   { | ||||
|     Error_Handler( ); | ||||
|         if(HAL_PCD_Init(&hpcd_USB_OTG_FS) != HAL_OK) { | ||||
|             Error_Handler(); | ||||
|         } | ||||
| 
 | ||||
| #if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) | ||||
| #if(USE_HAL_PCD_REGISTER_CALLBACKS == 1U) | ||||
|         /* Register USB PCD CallBacks */ | ||||
|         HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_SOF_CB_ID, PCD_SOFCallback); | ||||
|   HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_SETUPSTAGE_CB_ID, PCD_SetupStageCallback); | ||||
|         HAL_PCD_RegisterCallback( | ||||
|             &hpcd_USB_OTG_FS, HAL_PCD_SETUPSTAGE_CB_ID, PCD_SetupStageCallback); | ||||
|         HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_RESET_CB_ID, PCD_ResetCallback); | ||||
|         HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_SUSPEND_CB_ID, PCD_SuspendCallback); | ||||
|         HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_RESUME_CB_ID, PCD_ResumeCallback); | ||||
|         HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_CONNECT_CB_ID, PCD_ConnectCallback); | ||||
|   HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_DISCONNECT_CB_ID, PCD_DisconnectCallback); | ||||
|         HAL_PCD_RegisterCallback( | ||||
|             &hpcd_USB_OTG_FS, HAL_PCD_DISCONNECT_CB_ID, PCD_DisconnectCallback); | ||||
| 
 | ||||
|         HAL_PCD_RegisterDataOutStageCallback(&hpcd_USB_OTG_FS, PCD_DataOutStageCallback); | ||||
|         HAL_PCD_RegisterDataInStageCallback(&hpcd_USB_OTG_FS, PCD_DataInStageCallback); | ||||
| @ -403,27 +390,26 @@ USBD_StatusTypeDef USBD_LL_Init(USBD_HandleTypeDef *pdev) | ||||
|   * @param  pdev: Device handle | ||||
|   * @retval USBD status | ||||
|   */ | ||||
| USBD_StatusTypeDef USBD_LL_DeInit(USBD_HandleTypeDef *pdev) | ||||
| { | ||||
| USBD_StatusTypeDef USBD_LL_DeInit(USBD_HandleTypeDef* pdev) { | ||||
|     HAL_StatusTypeDef hal_status = HAL_OK; | ||||
|     USBD_StatusTypeDef usb_status = USBD_OK; | ||||
| 
 | ||||
|     hal_status = HAL_PCD_DeInit(pdev->pData); | ||||
| 
 | ||||
|   switch (hal_status) { | ||||
|     case HAL_OK : | ||||
|     switch(hal_status) { | ||||
|     case HAL_OK: | ||||
|         usb_status = USBD_OK; | ||||
|         break; | ||||
|     case HAL_ERROR : | ||||
|     case HAL_ERROR: | ||||
|         usb_status = USBD_FAIL; | ||||
|         break; | ||||
|     case HAL_BUSY : | ||||
|     case HAL_BUSY: | ||||
|         usb_status = USBD_BUSY; | ||||
|         break; | ||||
|     case HAL_TIMEOUT : | ||||
|     case HAL_TIMEOUT: | ||||
|         usb_status = USBD_FAIL; | ||||
|         break; | ||||
|     default : | ||||
|     default: | ||||
|         usb_status = USBD_FAIL; | ||||
|         break; | ||||
|     } | ||||
| @ -435,27 +421,26 @@ USBD_StatusTypeDef USBD_LL_DeInit(USBD_HandleTypeDef *pdev) | ||||
|   * @param  pdev: Device handle | ||||
|   * @retval USBD status | ||||
|   */ | ||||
| USBD_StatusTypeDef USBD_LL_Start(USBD_HandleTypeDef *pdev) | ||||
| { | ||||
| USBD_StatusTypeDef USBD_LL_Start(USBD_HandleTypeDef* pdev) { | ||||
|     HAL_StatusTypeDef hal_status = HAL_OK; | ||||
|     USBD_StatusTypeDef usb_status = USBD_OK; | ||||
| 
 | ||||
|     hal_status = HAL_PCD_Start(pdev->pData); | ||||
| 
 | ||||
|   switch (hal_status) { | ||||
|     case HAL_OK : | ||||
|     switch(hal_status) { | ||||
|     case HAL_OK: | ||||
|         usb_status = USBD_OK; | ||||
|         break; | ||||
|     case HAL_ERROR : | ||||
|     case HAL_ERROR: | ||||
|         usb_status = USBD_FAIL; | ||||
|         break; | ||||
|     case HAL_BUSY : | ||||
|     case HAL_BUSY: | ||||
|         usb_status = USBD_BUSY; | ||||
|         break; | ||||
|     case HAL_TIMEOUT : | ||||
|     case HAL_TIMEOUT: | ||||
|         usb_status = USBD_FAIL; | ||||
|         break; | ||||
|     default : | ||||
|     default: | ||||
|         usb_status = USBD_FAIL; | ||||
|         break; | ||||
|     } | ||||
| @ -467,27 +452,26 @@ USBD_StatusTypeDef USBD_LL_Start(USBD_HandleTypeDef *pdev) | ||||
|   * @param  pdev: Device handle | ||||
|   * @retval USBD status | ||||
|   */ | ||||
| USBD_StatusTypeDef USBD_LL_Stop(USBD_HandleTypeDef *pdev) | ||||
| { | ||||
| USBD_StatusTypeDef USBD_LL_Stop(USBD_HandleTypeDef* pdev) { | ||||
|     HAL_StatusTypeDef hal_status = HAL_OK; | ||||
|     USBD_StatusTypeDef usb_status = USBD_OK; | ||||
| 
 | ||||
|     hal_status = HAL_PCD_Stop(pdev->pData); | ||||
| 
 | ||||
|   switch (hal_status) { | ||||
|     case HAL_OK : | ||||
|     switch(hal_status) { | ||||
|     case HAL_OK: | ||||
|         usb_status = USBD_OK; | ||||
|         break; | ||||
|     case HAL_ERROR : | ||||
|     case HAL_ERROR: | ||||
|         usb_status = USBD_FAIL; | ||||
|         break; | ||||
|     case HAL_BUSY : | ||||
|     case HAL_BUSY: | ||||
|         usb_status = USBD_BUSY; | ||||
|         break; | ||||
|     case HAL_TIMEOUT : | ||||
|     case HAL_TIMEOUT: | ||||
|         usb_status = USBD_FAIL; | ||||
|         break; | ||||
|     default : | ||||
|     default: | ||||
|         usb_status = USBD_FAIL; | ||||
|         break; | ||||
|     } | ||||
| @ -502,27 +486,27 @@ USBD_StatusTypeDef USBD_LL_Stop(USBD_HandleTypeDef *pdev) | ||||
|   * @param  ep_mps: Endpoint max packet size | ||||
|   * @retval USBD status | ||||
|   */ | ||||
| USBD_StatusTypeDef USBD_LL_OpenEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr, uint8_t ep_type, uint16_t ep_mps) | ||||
| { | ||||
| USBD_StatusTypeDef | ||||
| USBD_LL_OpenEP(USBD_HandleTypeDef* pdev, uint8_t ep_addr, uint8_t ep_type, uint16_t ep_mps) { | ||||
|     HAL_StatusTypeDef hal_status = HAL_OK; | ||||
|     USBD_StatusTypeDef usb_status = USBD_OK; | ||||
| 
 | ||||
|     hal_status = HAL_PCD_EP_Open(pdev->pData, ep_addr, ep_mps, ep_type); | ||||
| 
 | ||||
|   switch (hal_status) { | ||||
|     case HAL_OK : | ||||
|     switch(hal_status) { | ||||
|     case HAL_OK: | ||||
|         usb_status = USBD_OK; | ||||
|         break; | ||||
|     case HAL_ERROR : | ||||
|     case HAL_ERROR: | ||||
|         usb_status = USBD_FAIL; | ||||
|         break; | ||||
|     case HAL_BUSY : | ||||
|     case HAL_BUSY: | ||||
|         usb_status = USBD_BUSY; | ||||
|         break; | ||||
|     case HAL_TIMEOUT : | ||||
|     case HAL_TIMEOUT: | ||||
|         usb_status = USBD_FAIL; | ||||
|         break; | ||||
|     default : | ||||
|     default: | ||||
|         usb_status = USBD_FAIL; | ||||
|         break; | ||||
|     } | ||||
| @ -535,27 +519,26 @@ USBD_StatusTypeDef USBD_LL_OpenEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr, uin | ||||
|   * @param  ep_addr: Endpoint number | ||||
|   * @retval USBD status | ||||
|   */ | ||||
| USBD_StatusTypeDef USBD_LL_CloseEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) | ||||
| { | ||||
| USBD_StatusTypeDef USBD_LL_CloseEP(USBD_HandleTypeDef* pdev, uint8_t ep_addr) { | ||||
|     HAL_StatusTypeDef hal_status = HAL_OK; | ||||
|     USBD_StatusTypeDef usb_status = USBD_OK; | ||||
| 
 | ||||
|     hal_status = HAL_PCD_EP_Close(pdev->pData, ep_addr); | ||||
| 
 | ||||
|   switch (hal_status) { | ||||
|     case HAL_OK : | ||||
|     switch(hal_status) { | ||||
|     case HAL_OK: | ||||
|         usb_status = USBD_OK; | ||||
|         break; | ||||
|     case HAL_ERROR : | ||||
|     case HAL_ERROR: | ||||
|         usb_status = USBD_FAIL; | ||||
|         break; | ||||
|     case HAL_BUSY : | ||||
|     case HAL_BUSY: | ||||
|         usb_status = USBD_BUSY; | ||||
|         break; | ||||
|     case HAL_TIMEOUT : | ||||
|     case HAL_TIMEOUT: | ||||
|         usb_status = USBD_FAIL; | ||||
|         break; | ||||
|     default : | ||||
|     default: | ||||
|         usb_status = USBD_FAIL; | ||||
|         break; | ||||
|     } | ||||
| @ -568,27 +551,26 @@ USBD_StatusTypeDef USBD_LL_CloseEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) | ||||
|   * @param  ep_addr: Endpoint number | ||||
|   * @retval USBD status | ||||
|   */ | ||||
| USBD_StatusTypeDef USBD_LL_FlushEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) | ||||
| { | ||||
| USBD_StatusTypeDef USBD_LL_FlushEP(USBD_HandleTypeDef* pdev, uint8_t ep_addr) { | ||||
|     HAL_StatusTypeDef hal_status = HAL_OK; | ||||
|     USBD_StatusTypeDef usb_status = USBD_OK; | ||||
| 
 | ||||
|     hal_status = HAL_PCD_EP_Flush(pdev->pData, ep_addr); | ||||
| 
 | ||||
|   switch (hal_status) { | ||||
|     case HAL_OK : | ||||
|     switch(hal_status) { | ||||
|     case HAL_OK: | ||||
|         usb_status = USBD_OK; | ||||
|         break; | ||||
|     case HAL_ERROR : | ||||
|     case HAL_ERROR: | ||||
|         usb_status = USBD_FAIL; | ||||
|         break; | ||||
|     case HAL_BUSY : | ||||
|     case HAL_BUSY: | ||||
|         usb_status = USBD_BUSY; | ||||
|         break; | ||||
|     case HAL_TIMEOUT : | ||||
|     case HAL_TIMEOUT: | ||||
|         usb_status = USBD_FAIL; | ||||
|         break; | ||||
|     default : | ||||
|     default: | ||||
|         usb_status = USBD_FAIL; | ||||
|         break; | ||||
|     } | ||||
| @ -601,27 +583,26 @@ USBD_StatusTypeDef USBD_LL_FlushEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) | ||||
|   * @param  ep_addr: Endpoint number | ||||
|   * @retval USBD status | ||||
|   */ | ||||
| USBD_StatusTypeDef USBD_LL_StallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) | ||||
| { | ||||
| USBD_StatusTypeDef USBD_LL_StallEP(USBD_HandleTypeDef* pdev, uint8_t ep_addr) { | ||||
|     HAL_StatusTypeDef hal_status = HAL_OK; | ||||
|     USBD_StatusTypeDef usb_status = USBD_OK; | ||||
| 
 | ||||
|     hal_status = HAL_PCD_EP_SetStall(pdev->pData, ep_addr); | ||||
| 
 | ||||
|   switch (hal_status) { | ||||
|     case HAL_OK : | ||||
|     switch(hal_status) { | ||||
|     case HAL_OK: | ||||
|         usb_status = USBD_OK; | ||||
|         break; | ||||
|     case HAL_ERROR : | ||||
|     case HAL_ERROR: | ||||
|         usb_status = USBD_FAIL; | ||||
|         break; | ||||
|     case HAL_BUSY : | ||||
|     case HAL_BUSY: | ||||
|         usb_status = USBD_BUSY; | ||||
|         break; | ||||
|     case HAL_TIMEOUT : | ||||
|     case HAL_TIMEOUT: | ||||
|         usb_status = USBD_FAIL; | ||||
|         break; | ||||
|     default : | ||||
|     default: | ||||
|         usb_status = USBD_FAIL; | ||||
|         break; | ||||
|     } | ||||
| @ -634,27 +615,26 @@ USBD_StatusTypeDef USBD_LL_StallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) | ||||
|   * @param  ep_addr: Endpoint number | ||||
|   * @retval USBD status | ||||
|   */ | ||||
| USBD_StatusTypeDef USBD_LL_ClearStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) | ||||
| { | ||||
| USBD_StatusTypeDef USBD_LL_ClearStallEP(USBD_HandleTypeDef* pdev, uint8_t ep_addr) { | ||||
|     HAL_StatusTypeDef hal_status = HAL_OK; | ||||
|     USBD_StatusTypeDef usb_status = USBD_OK; | ||||
| 
 | ||||
|     hal_status = HAL_PCD_EP_ClrStall(pdev->pData, ep_addr); | ||||
| 
 | ||||
|   switch (hal_status) { | ||||
|     case HAL_OK : | ||||
|     switch(hal_status) { | ||||
|     case HAL_OK: | ||||
|         usb_status = USBD_OK; | ||||
|         break; | ||||
|     case HAL_ERROR : | ||||
|     case HAL_ERROR: | ||||
|         usb_status = USBD_FAIL; | ||||
|         break; | ||||
|     case HAL_BUSY : | ||||
|     case HAL_BUSY: | ||||
|         usb_status = USBD_BUSY; | ||||
|         break; | ||||
|     case HAL_TIMEOUT : | ||||
|     case HAL_TIMEOUT: | ||||
|         usb_status = USBD_FAIL; | ||||
|         break; | ||||
|     default : | ||||
|     default: | ||||
|         usb_status = USBD_FAIL; | ||||
|         break; | ||||
|     } | ||||
| @ -667,16 +647,12 @@ USBD_StatusTypeDef USBD_LL_ClearStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_add | ||||
|   * @param  ep_addr: Endpoint number | ||||
|   * @retval Stall (1: Yes, 0: No) | ||||
|   */ | ||||
| uint8_t USBD_LL_IsStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) | ||||
| { | ||||
|   PCD_HandleTypeDef *hpcd = (PCD_HandleTypeDef*) pdev->pData; | ||||
| uint8_t USBD_LL_IsStallEP(USBD_HandleTypeDef* pdev, uint8_t ep_addr) { | ||||
|     PCD_HandleTypeDef* hpcd = (PCD_HandleTypeDef*)pdev->pData; | ||||
| 
 | ||||
|   if((ep_addr & 0x80) == 0x80) | ||||
|   { | ||||
|     if((ep_addr & 0x80) == 0x80) { | ||||
|         return hpcd->IN_ep[ep_addr & 0x7F].is_stall; | ||||
|   } | ||||
|   else | ||||
|   { | ||||
|     } else { | ||||
|         return hpcd->OUT_ep[ep_addr & 0x7F].is_stall; | ||||
|     } | ||||
| } | ||||
| @ -687,27 +663,26 @@ uint8_t USBD_LL_IsStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) | ||||
|   * @param  dev_addr: Device address | ||||
|   * @retval USBD status | ||||
|   */ | ||||
| USBD_StatusTypeDef USBD_LL_SetUSBAddress(USBD_HandleTypeDef *pdev, uint8_t dev_addr) | ||||
| { | ||||
| USBD_StatusTypeDef USBD_LL_SetUSBAddress(USBD_HandleTypeDef* pdev, uint8_t dev_addr) { | ||||
|     HAL_StatusTypeDef hal_status = HAL_OK; | ||||
|     USBD_StatusTypeDef usb_status = USBD_OK; | ||||
| 
 | ||||
|     hal_status = HAL_PCD_SetAddress(pdev->pData, dev_addr); | ||||
| 
 | ||||
|   switch (hal_status) { | ||||
|     case HAL_OK : | ||||
|     switch(hal_status) { | ||||
|     case HAL_OK: | ||||
|         usb_status = USBD_OK; | ||||
|         break; | ||||
|     case HAL_ERROR : | ||||
|     case HAL_ERROR: | ||||
|         usb_status = USBD_FAIL; | ||||
|         break; | ||||
|     case HAL_BUSY : | ||||
|     case HAL_BUSY: | ||||
|         usb_status = USBD_BUSY; | ||||
|         break; | ||||
|     case HAL_TIMEOUT : | ||||
|     case HAL_TIMEOUT: | ||||
|         usb_status = USBD_FAIL; | ||||
|         break; | ||||
|     default : | ||||
|     default: | ||||
|         usb_status = USBD_FAIL; | ||||
|         break; | ||||
|     } | ||||
| @ -722,27 +697,27 @@ USBD_StatusTypeDef USBD_LL_SetUSBAddress(USBD_HandleTypeDef *pdev, uint8_t dev_a | ||||
|   * @param  size: Data size     | ||||
|   * @retval USBD status | ||||
|   */ | ||||
| USBD_StatusTypeDef USBD_LL_Transmit(USBD_HandleTypeDef *pdev, uint8_t ep_addr, uint8_t *pbuf, uint16_t size) | ||||
| { | ||||
| USBD_StatusTypeDef | ||||
| USBD_LL_Transmit(USBD_HandleTypeDef* pdev, uint8_t ep_addr, uint8_t* pbuf, uint16_t size) { | ||||
|     HAL_StatusTypeDef hal_status = HAL_OK; | ||||
|     USBD_StatusTypeDef usb_status = USBD_OK; | ||||
| 
 | ||||
|     hal_status = HAL_PCD_EP_Transmit(pdev->pData, ep_addr, pbuf, size); | ||||
| 
 | ||||
|   switch (hal_status) { | ||||
|     case HAL_OK : | ||||
|     switch(hal_status) { | ||||
|     case HAL_OK: | ||||
|         usb_status = USBD_OK; | ||||
|         break; | ||||
|     case HAL_ERROR : | ||||
|     case HAL_ERROR: | ||||
|         usb_status = USBD_FAIL; | ||||
|         break; | ||||
|     case HAL_BUSY : | ||||
|     case HAL_BUSY: | ||||
|         usb_status = USBD_BUSY; | ||||
|         break; | ||||
|     case HAL_TIMEOUT : | ||||
|     case HAL_TIMEOUT: | ||||
|         usb_status = USBD_FAIL; | ||||
|         break; | ||||
|     default : | ||||
|     default: | ||||
|         usb_status = USBD_FAIL; | ||||
|         break; | ||||
|     } | ||||
| @ -757,27 +732,27 @@ USBD_StatusTypeDef USBD_LL_Transmit(USBD_HandleTypeDef *pdev, uint8_t ep_addr, u | ||||
|   * @param  size: Data size | ||||
|   * @retval USBD status | ||||
|   */ | ||||
| USBD_StatusTypeDef USBD_LL_PrepareReceive(USBD_HandleTypeDef *pdev, uint8_t ep_addr, uint8_t *pbuf, uint16_t size) | ||||
| { | ||||
| USBD_StatusTypeDef | ||||
| USBD_LL_PrepareReceive(USBD_HandleTypeDef* pdev, uint8_t ep_addr, uint8_t* pbuf, uint16_t size) { | ||||
|     HAL_StatusTypeDef hal_status = HAL_OK; | ||||
|     USBD_StatusTypeDef usb_status = USBD_OK; | ||||
| 
 | ||||
|     hal_status = HAL_PCD_EP_Receive(pdev->pData, ep_addr, pbuf, size); | ||||
| 
 | ||||
|   switch (hal_status) { | ||||
|     case HAL_OK : | ||||
|     switch(hal_status) { | ||||
|     case HAL_OK: | ||||
|         usb_status = USBD_OK; | ||||
|         break; | ||||
|     case HAL_ERROR : | ||||
|     case HAL_ERROR: | ||||
|         usb_status = USBD_FAIL; | ||||
|         break; | ||||
|     case HAL_BUSY : | ||||
|     case HAL_BUSY: | ||||
|         usb_status = USBD_BUSY; | ||||
|         break; | ||||
|     case HAL_TIMEOUT : | ||||
|     case HAL_TIMEOUT: | ||||
|         usb_status = USBD_FAIL; | ||||
|         break; | ||||
|     default : | ||||
|     default: | ||||
|         usb_status = USBD_FAIL; | ||||
|         break; | ||||
|     } | ||||
| @ -790,9 +765,8 @@ USBD_StatusTypeDef USBD_LL_PrepareReceive(USBD_HandleTypeDef *pdev, uint8_t ep_a | ||||
|   * @param  ep_addr: Endpoint number | ||||
|   * @retval Recived Data Size | ||||
|   */ | ||||
| uint32_t USBD_LL_GetRxDataSize(USBD_HandleTypeDef *pdev, uint8_t ep_addr) | ||||
| { | ||||
|   return HAL_PCD_EP_GetRxCount((PCD_HandleTypeDef*) pdev->pData, ep_addr); | ||||
| uint32_t USBD_LL_GetRxDataSize(USBD_HandleTypeDef* pdev, uint8_t ep_addr) { | ||||
|     return HAL_PCD_EP_GetRxCount((PCD_HandleTypeDef*)pdev->pData, ep_addr); | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -801,17 +775,14 @@ uint32_t USBD_LL_GetRxDataSize(USBD_HandleTypeDef *pdev, uint8_t ep_addr) | ||||
|   * @param  msg: LPM message | ||||
|   * @retval None | ||||
|   */ | ||||
| void HAL_PCDEx_LPM_Callback(PCD_HandleTypeDef *hpcd, PCD_LPM_MsgTypeDef msg) | ||||
| { | ||||
|   switch (msg) | ||||
|   { | ||||
| void HAL_PCDEx_LPM_Callback(PCD_HandleTypeDef* hpcd, PCD_LPM_MsgTypeDef msg) { | ||||
|     switch(msg) { | ||||
|     case PCD_LPM_L0_ACTIVE: | ||||
|     if (hpcd->Init.low_power_enable) | ||||
|     { | ||||
|         if(hpcd->Init.low_power_enable) { | ||||
|             SystemClockConfig_Resume(); | ||||
| 
 | ||||
|             /* Reset SLEEPDEEP bit of Cortex System Control Register. */ | ||||
|       SCB->SCR &= (uint32_t)~((uint32_t)(SCB_SCR_SLEEPDEEP_Msk | SCB_SCR_SLEEPONEXIT_Msk)); | ||||
|             SCB->SCR &= (uint32_t) ~((uint32_t)(SCB_SCR_SLEEPDEEP_Msk | SCB_SCR_SLEEPONEXIT_Msk)); | ||||
|         } | ||||
|         __HAL_PCD_UNGATE_PHYCLOCK(hpcd); | ||||
|         USBD_LL_Resume(hpcd->pData); | ||||
| @ -822,8 +793,7 @@ void HAL_PCDEx_LPM_Callback(PCD_HandleTypeDef *hpcd, PCD_LPM_MsgTypeDef msg) | ||||
|         USBD_LL_Suspend(hpcd->pData); | ||||
| 
 | ||||
|         /* Enter in STOP mode. */ | ||||
|     if (hpcd->Init.low_power_enable) | ||||
|     {    | ||||
|         if(hpcd->Init.low_power_enable) { | ||||
|             /* Set SLEEPDEEP bit and SleepOnExit of Cortex System Control Register. */ | ||||
|             SCB->SCR |= (uint32_t)((uint32_t)(SCB_SCR_SLEEPDEEP_Msk | SCB_SCR_SLEEPONEXIT_Msk)); | ||||
|         } | ||||
| @ -836,8 +806,7 @@ void HAL_PCDEx_LPM_Callback(PCD_HandleTypeDef *hpcd, PCD_LPM_MsgTypeDef msg) | ||||
|   * @param  Delay: Delay in ms | ||||
|   * @retval None | ||||
|   */ | ||||
| void USBD_LL_Delay(uint32_t Delay) | ||||
| { | ||||
| void USBD_LL_Delay(uint32_t Delay) { | ||||
|     HAL_Delay(Delay); | ||||
| } | ||||
| 
 | ||||
| @ -846,9 +815,8 @@ void USBD_LL_Delay(uint32_t Delay) | ||||
|   * @param  size: Size of allocated memory | ||||
|   * @retval None | ||||
|   */ | ||||
| void *USBD_static_malloc(uint32_t size) | ||||
| { | ||||
|   static uint32_t mem[(sizeof(USBD_CDC_HandleTypeDef)/4)+1];/* On 32-bit boundary */ | ||||
| void* USBD_static_malloc(uint32_t size) { | ||||
|     static uint32_t mem[(sizeof(USBD_CDC_HandleTypeDef) / 4) + 1]; /* On 32-bit boundary */ | ||||
|     return mem; | ||||
| } | ||||
| 
 | ||||
| @ -857,9 +825,7 @@ void *USBD_static_malloc(uint32_t size) | ||||
|   * @param  p: Pointer to allocated  memory address | ||||
|   * @retval None | ||||
|   */ | ||||
| void USBD_static_free(void *p) | ||||
| { | ||||
| 
 | ||||
| void USBD_static_free(void* p) { | ||||
| } | ||||
| 
 | ||||
| /* USER CODE BEGIN 5 */ | ||||
| @ -868,8 +834,7 @@ void USBD_static_free(void *p) | ||||
|   *         enable HSI, PLL and select PLL as system clock source. | ||||
|   * @retval None | ||||
|   */ | ||||
| static void SystemClockConfig_Resume(void) | ||||
| { | ||||
| static void SystemClockConfig_Resume(void) { | ||||
|     SystemClock_Config(); | ||||
| } | ||||
| /* USER CODE END 5 */ | ||||
|  | ||||
| @ -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,30 +135,29 @@ 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 = | ||||
| { | ||||
| __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
 | ||||
| #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 | ||||
| @ -184,12 +182,11 @@ __ALIGN_BEGIN uint8_t USBD_FS_DeviceDesc[USB_LEN_DEV_DESC] __ALIGN_END = | ||||
| 
 | ||||
| /* 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 = | ||||
| { | ||||
| __ALIGN_BEGIN uint8_t USBD_FS_BOSDesc[USB_SIZ_BOS_DESC] __ALIGN_END = { | ||||
|     0x5, | ||||
|     USB_DESC_TYPE_BOS, | ||||
|     0xC, | ||||
| @ -202,8 +199,7 @@ __ALIGN_BEGIN uint8_t USBD_FS_BOSDesc[USB_SIZ_BOS_DESC] __ALIGN_END = | ||||
|     0x2, /* LPM capability bit set*/ | ||||
|     0x0, | ||||
|     0x0, | ||||
|   0x0 | ||||
| }; | ||||
|     0x0}; | ||||
| #endif /* (USBD_LPM_ENABLED == 1) */ | ||||
| 
 | ||||
| /**
 | ||||
| @ -215,27 +211,25 @@ __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 = | ||||
| { | ||||
| __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) | ||||
| }; | ||||
|     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, | ||||
| @ -257,8 +251,7 @@ __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) | ||||
| { | ||||
| uint8_t* USBD_FS_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t* length) { | ||||
|     UNUSED(speed); | ||||
|     *length = sizeof(USBD_FS_DeviceDesc); | ||||
|     return USBD_FS_DeviceDesc; | ||||
| @ -270,8 +263,7 @@ 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) | ||||
| { | ||||
| uint8_t* USBD_FS_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t* length) { | ||||
|     UNUSED(speed); | ||||
|     *length = sizeof(USBD_LangIDDesc); | ||||
|     return USBD_LangIDDesc; | ||||
| @ -283,15 +275,11 @@ 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); | ||||
| 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,10 +290,9 @@ 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) | ||||
| { | ||||
| uint8_t* USBD_FS_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t* length) { | ||||
|     UNUSED(speed); | ||||
|   USBD_GetString((uint8_t *)USBD_MANUFACTURER_STRING, USBD_StrDesc, length); | ||||
|     USBD_GetString((uint8_t*)USBD_MANUFACTURER_STRING, USBD_StrDesc, length); | ||||
|     return USBD_StrDesc; | ||||
| } | ||||
| 
 | ||||
| @ -315,8 +302,7 @@ 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) | ||||
| { | ||||
| uint8_t* USBD_FS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t* length) { | ||||
|     UNUSED(speed); | ||||
|     *length = USB_SIZ_STRING_SERIAL; | ||||
| 
 | ||||
| @ -326,7 +312,7 @@ uint8_t * USBD_FS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) | ||||
|     /* USER CODE BEGIN USBD_FS_SerialStrDescriptor */ | ||||
| 
 | ||||
|     /* USER CODE END USBD_FS_SerialStrDescriptor */ | ||||
|   return (uint8_t *) USBD_StringSerial; | ||||
|     return (uint8_t*)USBD_StringSerial; | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
| @ -335,15 +321,11 @@ 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); | ||||
| 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,28 +336,23 @@ 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); | ||||
| 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) | ||||
| { | ||||
| 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; | ||||
| @ -387,18 +364,16 @@ uint8_t * USBD_FS_USR_BOSDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) | ||||
|   * @param  None  | ||||
|   * @retval None | ||||
|   */ | ||||
| static void Get_SerialNum(void) | ||||
| { | ||||
| 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; | ||||
| 
 | ||||
|   if (deviceserial0 != 0) | ||||
|   { | ||||
|     if(deviceserial0 != 0) { | ||||
|         IntToUnicode(deviceserial0, &USBD_StringSerial[2], 8); | ||||
|         IntToUnicode(deviceserial1, &USBD_StringSerial[18], 4); | ||||
|     } | ||||
| @ -411,18 +386,13 @@ static void Get_SerialNum(void) | ||||
|   * @param  len: buffer length | ||||
|   * @retval None | ||||
|   */ | ||||
| static void IntToUnicode(uint32_t value, uint8_t * pbuf, uint8_t len) | ||||
| { | ||||
| 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) | ||||
|     { | ||||
|     for(idx = 0; idx < len; idx++) { | ||||
|         if(((value >> 28)) < 0xA) { | ||||
|             pbuf[2 * idx] = (value >> 28) + '0'; | ||||
|     } | ||||
|     else | ||||
|     { | ||||
|         } else { | ||||
|             pbuf[2 * idx] = (value >> 28) + 'A' - 10; | ||||
|         } | ||||
| 
 | ||||
|  | ||||
| @ -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, | ||||
| TaskHandle_t xTaskCreateStatic(TaskFunction_t pxTaskCode, | ||||
|                                const char* const pcName, | ||||
|                                const uint32_t ulStackDepth, | ||||
|     void * const pvParameters, | ||||
|                                void* const pvParameters, | ||||
|                                UBaseType_t uxPriority, | ||||
|     StackType_t * const puxStackBuffer, | ||||
|     StaticTask_t * const pxTaskBuffer | ||||
| ); | ||||
|                                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, | ||||
| QueueHandle_t xQueueCreateStatic(UBaseType_t uxQueueLength, | ||||
|                                  UBaseType_t uxItemSize, | ||||
|                                  uint8_t* pucQueueStorageBuffer, | ||||
|     StaticQueue_t* pxQueueBuffer | ||||
| ); | ||||
|                                  StaticQueue_t* pxQueueBuffer); | ||||
| 
 | ||||
| SemaphoreHandle_t xSemaphoreCreateCountingStatic( | ||||
|     UBaseType_t uxMaxCount, | ||||
| SemaphoreHandle_t xSemaphoreCreateCountingStatic(UBaseType_t uxMaxCount, | ||||
|                                                  UBaseType_t uxInitialCount, | ||||
|     StaticSemaphore_t *pxSemaphoreBuffer | ||||
| ); | ||||
|                                                  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,7 +10,6 @@ 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); | ||||
| @ -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, | ||||
| TaskHandle_t xTaskCreateStatic(TaskFunction_t pxTaskCode, | ||||
|                                const char* const pcName, | ||||
|                                const uint32_t ulStackDepth, | ||||
|     void * const pvParameters, | ||||
|                                void* const pvParameters, | ||||
|                                UBaseType_t uxPriority, | ||||
|     StackType_t * const puxStackBuffer, | ||||
|     StaticTask_t * const pxTaskBuffer | ||||
| ) { | ||||
|                                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, | ||||
| QueueHandle_t xQueueCreateStatic(UBaseType_t uxQueueLength, | ||||
|                                  UBaseType_t uxItemSize, | ||||
|                                  uint8_t* pucQueueStorageBuffer, | ||||
|     StaticQueue_t *pxQueueBuffer | ||||
| ) { | ||||
|                                  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, | ||||
| SemaphoreHandle_t xSemaphoreCreateCountingStatic(UBaseType_t uxMaxCount, | ||||
|                                                  UBaseType_t uxInitialCount, | ||||
|     StaticSemaphore_t* pxSemaphoreBuffer | ||||
| ) { | ||||
|                                                  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