[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 |       - name: Build docker image | ||||||
|         uses: ./.github/actions/docker |         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 |       - name: Build target_lo in docker | ||||||
|         uses: ./.github/actions/docker |         uses: ./.github/actions/docker | ||||||
|         with: |         with: | ||||||
|  | |||||||
							
								
								
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							| @ -1,5 +1,4 @@ | |||||||
| .idea/ | .idea/ | ||||||
| target_lo/build/ |  | ||||||
| target_*/build/ | target_*/build/ | ||||||
| bindings/ | bindings/ | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -9,9 +9,7 @@ void coreglitch_demo_0(void* p) { | |||||||
|     fuprintf(log, "coreglitch demo!\n"); |     fuprintf(log, "coreglitch demo!\n"); | ||||||
| 
 | 
 | ||||||
|     // open record
 |     // open record
 | ||||||
|     FuriRecordSubscriber* fb_record = furi_open( |     FuriRecordSubscriber* fb_record = furi_open("u8g2_fb", false, false, NULL, NULL, NULL); | ||||||
|         "u8g2_fb", false, false, NULL, NULL, NULL |  | ||||||
|     ); |  | ||||||
| 
 | 
 | ||||||
|     if(fb_record == NULL) { |     if(fb_record == NULL) { | ||||||
|         fuprintf(log, "[widget] cannot create fb record\n"); |         fuprintf(log, "[widget] cannot create fb record\n"); | ||||||
| @ -33,18 +31,17 @@ void coreglitch_demo_0(void* p) { | |||||||
|         1.0, |         1.0, | ||||||
|         1.5, |         1.5, | ||||||
|         0.75, |         0.75, | ||||||
|         0.8 |         0.8, | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|     uint8_t cnt = 0; |     uint8_t cnt = 0; | ||||||
| 
 | 
 | ||||||
|     while(1) { |     while(1) { | ||||||
| 
 |  | ||||||
|         for(size_t note_idx = 0; note_idx < 400; note_idx++) { |         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 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) { |             if(note_idx % 8 == 0) { | ||||||
|                 freq = 0; |                 freq = 0; | ||||||
| @ -56,7 +53,6 @@ void coreglitch_demo_0(void* p) { | |||||||
| 
 | 
 | ||||||
|             cnt++; |             cnt++; | ||||||
| 
 | 
 | ||||||
|              |  | ||||||
|             u8g2_t* fb = furi_take(fb_record); |             u8g2_t* fb = furi_take(fb_record); | ||||||
|             if(fb != NULL) { |             if(fb != NULL) { | ||||||
|                 u8g2_SetDrawColor(fb, 0); |                 u8g2_SetDrawColor(fb, 0); | ||||||
|  | |||||||
| @ -7,104 +7,107 @@ extern SPI_HandleTypeDef hspi1; | |||||||
| 
 | 
 | ||||||
| // TODO rewrite u8g2 to pass thread-local context in this handlers
 | // 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) { |     switch(msg) { | ||||||
|         //Initialize SPI peripheral
 |     //Initialize SPI peripheral
 | ||||||
|         case U8X8_MSG_GPIO_AND_DELAY_INIT: |     case U8X8_MSG_GPIO_AND_DELAY_INIT: | ||||||
|             /* HAL initialization contains all what we need so we can skip this part. */ |         /* HAL initialization contains all what we need so we can skip this part. */ | ||||||
|         break; |         break; | ||||||
| 
 | 
 | ||||||
|         //Function which implements a delay, arg_int contains the amount of ms
 |     //Function which implements a delay, arg_int contains the amount of ms
 | ||||||
|         case U8X8_MSG_DELAY_MILLI: |     case U8X8_MSG_DELAY_MILLI: | ||||||
|             osDelay(arg_int); |         osDelay(arg_int); | ||||||
|         break; |         break; | ||||||
| 
 | 
 | ||||||
|         //Function which delays 10us
 |     //Function which delays 10us
 | ||||||
|         case U8X8_MSG_DELAY_10MICRO: |     case U8X8_MSG_DELAY_10MICRO: | ||||||
|             delay_us(10); |         delay_us(10); | ||||||
|         break; |         break; | ||||||
| 
 | 
 | ||||||
|         //Function which delays 100ns
 |     //Function which delays 100ns
 | ||||||
|         case U8X8_MSG_DELAY_100NANO: |     case U8X8_MSG_DELAY_100NANO: | ||||||
|             asm("nop"); |         asm("nop"); | ||||||
|         break; |         break; | ||||||
| 
 | 
 | ||||||
|         // Function to define the logic level of the RESET line
 |     // Function to define the logic level of the RESET line
 | ||||||
|         case U8X8_MSG_GPIO_RESET: |     case U8X8_MSG_GPIO_RESET: | ||||||
|             #ifdef DEBUG | #ifdef DEBUG | ||||||
|                 fuprintf(log, "[u8g2] rst %d\n", arg_int); |         fuprintf(log, "[u8g2] rst %d\n", arg_int); | ||||||
|             #endif | #endif | ||||||
| 
 | 
 | ||||||
|             // TODO change it to FuriRecord pin
 |         // 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; |         break; | ||||||
| 
 | 
 | ||||||
|         default: |     default: | ||||||
|             #ifdef DEBUG | #ifdef DEBUG | ||||||
|                 fufuprintf(log, "[u8g2] unknown io %d\n", msg); |         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
 |         return 0; //A message was received which is not implemented, return 0 to indicate an error
 | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     return 1; // command processed successfully.
 |     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){ | static uint8_t u8x8_hw_spi_stm32(u8x8_t* u8x8, uint8_t msg, uint8_t arg_int, void* arg_ptr) { | ||||||
|     switch (msg) { |     switch(msg) { | ||||||
|         case U8X8_MSG_BYTE_SEND: |     case U8X8_MSG_BYTE_SEND: | ||||||
|             #ifdef DEBUG | #ifdef DEBUG | ||||||
|                 fuprintf(log, "[u8g2] send %d bytes %02X\n", arg_int, ((uint8_t*)arg_ptr)[0]); |         fuprintf(log, "[u8g2] send %d bytes %02X\n", arg_int, ((uint8_t*)arg_ptr)[0]); | ||||||
|             #endif | #endif | ||||||
| 
 | 
 | ||||||
|             // TODO change it to FuriRecord SPI
 |         // 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; |         break; | ||||||
| 
 | 
 | ||||||
|         case U8X8_MSG_BYTE_SET_DC: |     case U8X8_MSG_BYTE_SET_DC: | ||||||
|             #ifdef DEBUG | #ifdef DEBUG | ||||||
|                 fuprintf(log, "[u8g2] dc %d\n", arg_int); |         fuprintf(log, "[u8g2] dc %d\n", arg_int); | ||||||
|             #endif | #endif | ||||||
| 
 | 
 | ||||||
|             // TODO change it to FuriRecord pin
 |         // 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; |         break; | ||||||
| 
 | 
 | ||||||
|         case U8X8_MSG_BYTE_INIT: |     case U8X8_MSG_BYTE_INIT: | ||||||
|             #ifdef DEBUG | #ifdef DEBUG | ||||||
|                 fuprintf(log, "[u8g2] init\n"); |         fuprintf(log, "[u8g2] init\n"); | ||||||
|             #endif | #endif | ||||||
| 
 | 
 | ||||||
|             // TODO change it to FuriRecord pin
 |         // TODO change it to FuriRecord pin
 | ||||||
|             HAL_GPIO_WritePin(DISPLAY_CS_GPIO_Port, DISPLAY_CS_Pin, GPIO_PIN_RESET); |         HAL_GPIO_WritePin(DISPLAY_CS_GPIO_Port, DISPLAY_CS_Pin, GPIO_PIN_RESET); | ||||||
|         break; |         break; | ||||||
| 
 | 
 | ||||||
|         case U8X8_MSG_BYTE_START_TRANSFER: |     case U8X8_MSG_BYTE_START_TRANSFER: | ||||||
|             #ifdef DEBUG | #ifdef DEBUG | ||||||
|                 fuprintf(log, "[u8g2] start\n"); |         fuprintf(log, "[u8g2] start\n"); | ||||||
|             #endif | #endif | ||||||
| 
 | 
 | ||||||
|             // TODO change it to FuriRecord pin
 |         // TODO change it to FuriRecord pin
 | ||||||
|             HAL_GPIO_WritePin(DISPLAY_CS_GPIO_Port, DISPLAY_CS_Pin, GPIO_PIN_RESET); |         HAL_GPIO_WritePin(DISPLAY_CS_GPIO_Port, DISPLAY_CS_Pin, GPIO_PIN_RESET); | ||||||
|             asm("nop"); |         asm("nop"); | ||||||
|         break; |         break; | ||||||
| 
 | 
 | ||||||
|         case U8X8_MSG_BYTE_END_TRANSFER: |     case U8X8_MSG_BYTE_END_TRANSFER: | ||||||
|             #ifdef DEBUG | #ifdef DEBUG | ||||||
|                 fuprintf(log, "[u8g2] end\n"); |         fuprintf(log, "[u8g2] end\n"); | ||||||
|             #endif | #endif | ||||||
| 
 | 
 | ||||||
|             asm("nop"); |         asm("nop"); | ||||||
|             // TODO change it to FuriRecord pin
 |         // TODO change it to FuriRecord pin
 | ||||||
|             HAL_GPIO_WritePin(DISPLAY_CS_GPIO_Port, DISPLAY_CS_Pin, GPIO_PIN_SET); |         HAL_GPIO_WritePin(DISPLAY_CS_GPIO_Port, DISPLAY_CS_Pin, GPIO_PIN_SET); | ||||||
|         break; |         break; | ||||||
| 
 | 
 | ||||||
|         default: |     default: | ||||||
|             #ifdef DEBUG | #ifdef DEBUG | ||||||
|                 fuprintf(log, "[u8g2] unknown xfer %d\n", msg); |         fuprintf(log, "[u8g2] unknown xfer %d\n", msg); | ||||||
|             #endif | #endif | ||||||
| 
 | 
 | ||||||
|             return 0; |         return 0; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     return 1; |     return 1; | ||||||
| @ -131,8 +134,10 @@ void display_u8g2(void* p) { | |||||||
|     HAL_GPIO_WritePin(DISPLAY_BACKLIGHT_GPIO_Port, DISPLAY_BACKLIGHT_Pin, GPIO_PIN_SET); |     HAL_GPIO_WritePin(DISPLAY_BACKLIGHT_GPIO_Port, DISPLAY_BACKLIGHT_Pin, GPIO_PIN_SET); | ||||||
| 
 | 
 | ||||||
|     u8g2_t _u8g2; |     u8g2_t _u8g2; | ||||||
|     u8g2_Setup_st7565_erc12864_alt_f(&_u8g2, U8G2_R0, u8x8_hw_spi_stm32, u8g2_gpio_and_delay_stm32); |     u8g2_Setup_st7565_erc12864_alt_f( | ||||||
|     u8g2_InitDisplay(&_u8g2); // send init sequence to the display, display is in sleep mode after this
 |         &_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); |     u8g2_SetContrast(&_u8g2, 36); | ||||||
| 
 | 
 | ||||||
|     if(!furi_create("u8g2_fb", (void*)&_u8g2, sizeof(_u8g2))) { |     if(!furi_create("u8g2_fb", (void*)&_u8g2, sizeof(_u8g2))) { | ||||||
| @ -153,9 +158,8 @@ void display_u8g2(void* p) { | |||||||
|     DisplayCtx ctx = {.update = update, .log = log}; |     DisplayCtx ctx = {.update = update, .log = log}; | ||||||
| 
 | 
 | ||||||
|     // subscribe to record. ctx will be passed to handle_fb_change
 |     // subscribe to record. ctx will be passed to handle_fb_change
 | ||||||
|     FuriRecordSubscriber* fb_record = furi_open( |     FuriRecordSubscriber* fb_record = | ||||||
|         "u8g2_fb", false, false, handle_fb_change, NULL, &ctx |         furi_open("u8g2_fb", false, false, handle_fb_change, NULL, &ctx); | ||||||
|     ); |  | ||||||
| 
 | 
 | ||||||
|     if(fb_record == NULL) { |     if(fb_record == NULL) { | ||||||
|         fuprintf(log, "[display] cannot open fb record\n"); |         fuprintf(log, "[display] cannot open fb record\n"); | ||||||
|  | |||||||
| @ -3,7 +3,7 @@ | |||||||
| void application_blink(void* p) { | void application_blink(void* p) { | ||||||
|     // create pin
 |     // create pin
 | ||||||
|     GpioPin led = {.pin = GPIO_PIN_8, .port = GPIOA}; |     GpioPin led = {.pin = GPIO_PIN_8, .port = GPIOA}; | ||||||
|      | 
 | ||||||
|     // configure pin
 |     // configure pin
 | ||||||
|     pinMode(led, GpioModeOpenDrain); |     pinMode(led, GpioModeOpenDrain); | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -25,7 +25,7 @@ static void handle_fb_change(const void* fb, size_t fb_size, void* raw_ctx) { | |||||||
| 
 | 
 | ||||||
| static void print_fb(char* fb, FuriRecordSubscriber* log) { | static void print_fb(char* fb, FuriRecordSubscriber* log) { | ||||||
|     if(fb == NULL) return; |     if(fb == NULL) return; | ||||||
|      | 
 | ||||||
|     /* draw framebuffer like this:
 |     /* draw framebuffer like this:
 | ||||||
|     +==========+ |     +==========+ | ||||||
|     |          | |     |          | | ||||||
| @ -78,57 +78,53 @@ void application_ipc_display(void* p) { | |||||||
|     IpcCtx ctx = {.events = events, .log = log}; |     IpcCtx ctx = {.events = events, .log = log}; | ||||||
| 
 | 
 | ||||||
|     // subscribe to record. ctx will be passed to handle_fb_change
 |     // subscribe to record. ctx will be passed to handle_fb_change
 | ||||||
|     FuriRecordSubscriber* fb_record = furi_open( |     FuriRecordSubscriber* fb_record = | ||||||
|         "test_fb", false, false, handle_fb_change, NULL, &ctx |         furi_open("test_fb", false, false, handle_fb_change, NULL, &ctx); | ||||||
|     ); |  | ||||||
| 
 | 
 | ||||||
|     if(fb_record == NULL) { |     if(fb_record == NULL) { | ||||||
|         fuprintf(log, "[display] cannot open fb record\n"); |         fuprintf(log, "[display] cannot open fb record\n"); | ||||||
|         furiac_exit(NULL); |         furiac_exit(NULL); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     #ifdef HW_DISPLAY | #ifdef HW_DISPLAY | ||||||
|     // on Flipper target -- open screen
 |     // on Flipper target -- open screen
 | ||||||
| 
 | 
 | ||||||
|     // draw border
 |     // draw border
 | ||||||
| 
 | 
 | ||||||
|     #else | #else | ||||||
|     // on Local target -- print "blank screen"
 |     // on Local target -- print "blank screen"
 | ||||||
|     { |     { | ||||||
|         void* fb = furi_take(fb_record); |         void* fb = furi_take(fb_record); | ||||||
|         print_fb((char*)fb, log); |         print_fb((char*)fb, log); | ||||||
|         furi_give(fb_record); |         furi_give(fb_record); | ||||||
|     } |     } | ||||||
|     #endif | #endif | ||||||
| 
 | 
 | ||||||
|     while(1) { |     while(1) { | ||||||
|         // wait for event
 |         // wait for event
 | ||||||
|         if(xSemaphoreTake(events, portMAX_DELAY) == pdTRUE) { |         if(xSemaphoreTake(events, portMAX_DELAY) == pdTRUE) { | ||||||
|             fuprintf(log, "[display] get fb update\n\n"); |             fuprintf(log, "[display] get fb update\n\n"); | ||||||
| 
 | 
 | ||||||
|             #ifdef HW_DISPLAY | #ifdef HW_DISPLAY | ||||||
|             // on Flipper target draw the screen
 | // on Flipper target draw the screen
 | ||||||
|             #else | #else | ||||||
|             // on local target just print
 |             // on local target just print
 | ||||||
|             { |             { | ||||||
|                 void* fb = furi_take(fb_record); |                 void* fb = furi_take(fb_record); | ||||||
|                 print_fb((char*)fb, log); |                 print_fb((char*)fb, log); | ||||||
|                 furi_give(fb_record); |                 furi_give(fb_record); | ||||||
|             } |             } | ||||||
|             #endif | #endif | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| // Widget application
 | // Widget application
 | ||||||
| void application_ipc_widget(void* p) { | void application_ipc_widget(void* p) { | ||||||
|     FuriRecordSubscriber* log = get_default_log(); |     FuriRecordSubscriber* log = get_default_log(); | ||||||
| 
 | 
 | ||||||
|     // open record
 |     // open record
 | ||||||
|     FuriRecordSubscriber* fb_record = furi_open( |     FuriRecordSubscriber* fb_record = furi_open("test_fb", false, false, NULL, NULL, NULL); | ||||||
|         "test_fb", false, false, NULL, NULL, NULL |  | ||||||
|     ); |  | ||||||
| 
 | 
 | ||||||
|     if(fb_record == NULL) { |     if(fb_record == NULL) { | ||||||
|         fuprintf(log, "[widget] cannot create fb record\n"); |         fuprintf(log, "[widget] cannot create fb record\n"); | ||||||
|  | |||||||
| @ -6,11 +6,9 @@ void u8g2_example(void* p) { | |||||||
| 
 | 
 | ||||||
|     // TODO try open record and retry on timeout (needs FURI behaviour change)
 |     // TODO try open record and retry on timeout (needs FURI behaviour change)
 | ||||||
|     delay(1000); |     delay(1000); | ||||||
|      | 
 | ||||||
|     // open record
 |     // open record
 | ||||||
|     FuriRecordSubscriber* fb_record = furi_open( |     FuriRecordSubscriber* fb_record = furi_open("u8g2_fb", false, false, NULL, NULL, NULL); | ||||||
|         "u8g2_fb", false, false, NULL, NULL, NULL |  | ||||||
|     ); |  | ||||||
| 
 | 
 | ||||||
|     if(fb_record == NULL) { |     if(fb_record == NULL) { | ||||||
|         fuprintf(log, "[widget] cannot create fb record\n"); |         fuprintf(log, "[widget] cannot create fb record\n"); | ||||||
|  | |||||||
| @ -23,25 +23,25 @@ void u8g2_example(void* p); | |||||||
| void coreglitch_demo_0(void* p); | void coreglitch_demo_0(void* p); | ||||||
| 
 | 
 | ||||||
| const FlipperStartupApp FLIPPER_STARTUP[] = { | const FlipperStartupApp FLIPPER_STARTUP[] = { | ||||||
|     #ifndef TEST | #ifndef TEST | ||||||
|     {.app = display_u8g2, .name = "display_u8g2"}, |     {.app = display_u8g2, .name = "display_u8g2"}, | ||||||
|     {.app = u8g2_example, .name = "u8g2_example"}, |     {.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"}, |     {.app = flipper_test_app, .name = "test app"}, | ||||||
|     #endif | #endif | ||||||
| 
 | 
 | ||||||
|     #ifdef EXAMPLE_BLINK | #ifdef EXAMPLE_BLINK | ||||||
|     {.app = application_blink, .name = "blink"}, |     {.app = application_blink, .name = "blink"}, | ||||||
|     #endif | #endif | ||||||
|     #ifdef EXAMPLE_UART_WRITE | #ifdef EXAMPLE_UART_WRITE | ||||||
|     {.app = application_uart_write, .name = "uart write"}, |     {.app = application_uart_write, .name = "uart write"}, | ||||||
|     #endif | #endif | ||||||
|     #ifdef EXAMPLE_IPC | #ifdef EXAMPLE_IPC | ||||||
|     {.app = application_ipc_display, .name = "ipc display"}, |     {.app = application_ipc_display, .name = "ipc display"}, | ||||||
|     {.app = application_ipc_widget, .name = "ipc widget"}, |     {.app = application_ipc_widget, .name = "ipc widget"}, | ||||||
|     #endif | #endif | ||||||
| }; | }; | ||||||
|  | |||||||
| @ -29,10 +29,9 @@ bool test_furi_pipe_record(FuriRecordSubscriber* log) { | |||||||
|         return false; |         return false; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     // 2. Open/subscribe to it 
 |     // 2. Open/subscribe to it
 | ||||||
|     FuriRecordSubscriber* pipe_record = furi_open( |     FuriRecordSubscriber* pipe_record = | ||||||
|         "test/pipe", false, false, pipe_record_cb, NULL, NULL |         furi_open("test/pipe", false, false, pipe_record_cb, NULL, NULL); | ||||||
|     ); |  | ||||||
|     if(pipe_record == NULL) { |     if(pipe_record == NULL) { | ||||||
|         fuprintf(log, "cannot open record\n"); |         fuprintf(log, "cannot open record\n"); | ||||||
|         return false; |         return false; | ||||||
| @ -97,9 +96,8 @@ bool test_furi_holding_data(FuriRecordSubscriber* log) { | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     // 2. Open/Subscribe on it
 |     // 2. Open/Subscribe on it
 | ||||||
|     FuriRecordSubscriber* holding_record = furi_open( |     FuriRecordSubscriber* holding_record = | ||||||
|         "test/holding", false, false, holding_record_cb, NULL, NULL |         furi_open("test/holding", false, false, holding_record_cb, NULL, NULL); | ||||||
|     ); |  | ||||||
|     if(holding_record == NULL) { |     if(holding_record == NULL) { | ||||||
|         fuprintf(log, "cannot open record\n"); |         fuprintf(log, "cannot open record\n"); | ||||||
|         return false; |         return false; | ||||||
| @ -163,9 +161,8 @@ typedef struct { | |||||||
| void furi_concurent_app(void* p) { | void furi_concurent_app(void* p) { | ||||||
|     FuriRecordSubscriber* log = (FuriRecordSubscriber*)p; |     FuriRecordSubscriber* log = (FuriRecordSubscriber*)p; | ||||||
| 
 | 
 | ||||||
|     FuriRecordSubscriber* holding_record = furi_open( |     FuriRecordSubscriber* holding_record = | ||||||
|         "test/concurrent", false, false, NULL, NULL, NULL |         furi_open("test/concurrent", false, false, NULL, NULL, NULL); | ||||||
|     ); |  | ||||||
|     if(holding_record == NULL) { |     if(holding_record == NULL) { | ||||||
|         fuprintf(log, "cannot open record\n"); |         fuprintf(log, "cannot open record\n"); | ||||||
|         furiac_exit(NULL); |         furiac_exit(NULL); | ||||||
| @ -202,18 +199,15 @@ bool test_furi_concurrent_access(FuriRecordSubscriber* log) { | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     // 2. Open it
 |     // 2. Open it
 | ||||||
|     FuriRecordSubscriber* holding_record = furi_open( |     FuriRecordSubscriber* holding_record = | ||||||
|         "test/concurrent", false, false, NULL, NULL, NULL |         furi_open("test/concurrent", false, false, NULL, NULL, NULL); | ||||||
|     ); |  | ||||||
|     if(holding_record == NULL) { |     if(holding_record == NULL) { | ||||||
|         fuprintf(log, "cannot open record\n"); |         fuprintf(log, "cannot open record\n"); | ||||||
|         return false; |         return false; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     // 3. Create second app for interact with it
 |     // 3. Create second app for interact with it
 | ||||||
|     FuriApp* second_app = furiac_start( |     FuriApp* second_app = furiac_start(furi_concurent_app, "furi concurent app", (void*)log); | ||||||
|         furi_concurent_app, "furi concurent app", (void*)log |  | ||||||
|     ); |  | ||||||
| 
 | 
 | ||||||
|     // 4. multiply ConcurrentValue::a
 |     // 4. multiply ConcurrentValue::a
 | ||||||
|     for(size_t i = 0; i < 4; i++) { |     for(size_t i = 0; i < 4; i++) { | ||||||
| @ -259,7 +253,6 @@ TEST: non-existent data | |||||||
| TODO: implement this test | TODO: implement this test | ||||||
| */ | */ | ||||||
| bool test_furi_nonexistent_data(FuriRecordSubscriber* log) { | bool test_furi_nonexistent_data(FuriRecordSubscriber* log) { | ||||||
| 
 |  | ||||||
|     return true; |     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
 |     // 2. Open watch handler: solo=false, no_mute=false, subscribe to data
 | ||||||
|     FuriRecordSubscriber* watch_handler = furi_open( |     FuriRecordSubscriber* watch_handler = | ||||||
|         "test/mute", false, false, mute_record_cb, NULL, NULL |         furi_open("test/mute", false, false, mute_record_cb, NULL, NULL); | ||||||
|     ); |  | ||||||
|     if(watch_handler == NULL) { |     if(watch_handler == NULL) { | ||||||
|         fuprintf(log, "cannot open watch handler\n"); |         fuprintf(log, "cannot open watch handler\n"); | ||||||
|         furiac_exit(NULL); |         furiac_exit(NULL); | ||||||
| @ -342,16 +334,13 @@ void furi_mute_parent_app(void* p) { | |||||||
| 
 | 
 | ||||||
| bool test_furi_mute_algorithm(FuriRecordSubscriber* log) { | bool test_furi_mute_algorithm(FuriRecordSubscriber* log) { | ||||||
|     // 1. Create "parent" application:
 |     // 1. Create "parent" application:
 | ||||||
|     FuriApp* parent_app = furiac_start( |     FuriApp* parent_app = furiac_start(furi_mute_parent_app, "parent app", (void*)log); | ||||||
|         furi_mute_parent_app, "parent app", (void*)log |  | ||||||
|     ); |  | ||||||
| 
 | 
 | ||||||
|     delay(2); // wait creating record
 |     delay(2); // wait creating record
 | ||||||
| 
 | 
 | ||||||
|     // 2. Open handler A: solo=false, no_mute=false, NULL subscriber. Subscribe to state.
 |     // 2. Open handler A: solo=false, no_mute=false, NULL subscriber. Subscribe to state.
 | ||||||
|     FuriRecordSubscriber* handler_a = furi_open( |     FuriRecordSubscriber* handler_a = | ||||||
|         "test/mute", false, false, NULL, mute_record_state_cb, NULL |         furi_open("test/mute", false, false, NULL, mute_record_state_cb, NULL); | ||||||
|     ); |  | ||||||
|     if(handler_a == NULL) { |     if(handler_a == NULL) { | ||||||
|         fuprintf(log, "cannot open handler A\n"); |         fuprintf(log, "cannot open handler A\n"); | ||||||
|         return false; |         return false; | ||||||
| @ -371,9 +360,7 @@ bool test_furi_mute_algorithm(FuriRecordSubscriber* log) { | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     // 3. Open handler B: solo=true, no_mute=true, NULL subscriber.
 |     // 3. Open handler B: solo=true, no_mute=true, NULL subscriber.
 | ||||||
|     FuriRecordSubscriber* handler_b = furi_open( |     FuriRecordSubscriber* handler_b = furi_open("test/mute", true, true, NULL, NULL, NULL); | ||||||
|         "test/mute", true, true, NULL, NULL, NULL |  | ||||||
|     ); |  | ||||||
|     if(handler_b == NULL) { |     if(handler_b == NULL) { | ||||||
|         fuprintf(log, "cannot open handler B\n"); |         fuprintf(log, "cannot open handler B\n"); | ||||||
|         return false; |         return false; | ||||||
| @ -400,7 +387,6 @@ bool test_furi_mute_algorithm(FuriRecordSubscriber* log) { | |||||||
| 
 | 
 | ||||||
|     test_counter = 3; |     test_counter = 3; | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
|     // Try to write data to B and check that subscriber get data.
 |     // Try to write data to B and check that subscriber get data.
 | ||||||
|     if(!furi_write(handler_b, &test_counter, sizeof(uint8_t))) { |     if(!furi_write(handler_b, &test_counter, sizeof(uint8_t))) { | ||||||
|         fuprintf(log, "write to B failed\n"); |         fuprintf(log, "write to B failed\n"); | ||||||
| @ -412,11 +398,8 @@ bool test_furi_mute_algorithm(FuriRecordSubscriber* log) { | |||||||
|         return false; |         return false; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
|     // 4. Open hadler C: solo=true, no_mute=false, NULL subscriber.
 |     // 4. Open hadler C: solo=true, no_mute=false, NULL subscriber.
 | ||||||
|     FuriRecordSubscriber* handler_c = furi_open( |     FuriRecordSubscriber* handler_c = furi_open("test/mute", true, false, NULL, NULL, NULL); | ||||||
|         "test/mute", true, false, NULL, NULL, NULL |  | ||||||
|     ); |  | ||||||
|     if(handler_c == NULL) { |     if(handler_c == NULL) { | ||||||
|         fuprintf(log, "cannot open handler C\n"); |         fuprintf(log, "cannot open handler C\n"); | ||||||
|         return false; |         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.
 |     // TODO: Try to write data to C and check that subscriber get data.
 | ||||||
| 
 | 
 | ||||||
|     // 5. Open handler D: solo=false, no_mute=false, NULL subscriber.
 |     // 5. Open handler D: solo=false, no_mute=false, NULL subscriber.
 | ||||||
|     FuriRecordSubscriber* handler_d = furi_open( |     FuriRecordSubscriber* handler_d = furi_open("test/mute", false, false, NULL, NULL, NULL); | ||||||
|         "test/mute", false, false, NULL, NULL, NULL |  | ||||||
|     ); |  | ||||||
|     if(handler_d == NULL) { |     if(handler_d == NULL) { | ||||||
|         fuprintf(log, "cannot open handler D\n"); |         fuprintf(log, "cannot open handler D\n"); | ||||||
|         return false; |         return false; | ||||||
|  | |||||||
| @ -78,7 +78,7 @@ typedef struct { | |||||||
| void task_a(void*); | void task_a(void*); | ||||||
| void task_b(void*); | void task_b(void*); | ||||||
| 
 | 
 | ||||||
| void task_a(void *p) { | void task_a(void* p) { | ||||||
|     // simply starts, add 'A' letter to sequence and switch
 |     // simply starts, add 'A' letter to sequence and switch
 | ||||||
|     // if sequence counter = 0, call task B, exit otherwise
 |     // if sequence counter = 0, call task B, exit otherwise
 | ||||||
| 
 | 
 | ||||||
| @ -118,7 +118,7 @@ bool test_furi_ac_switch_exit(FuriRecordSubscriber* log) { | |||||||
| 
 | 
 | ||||||
|     furiac_start(task_a, "task A", (void*)&seq); |     furiac_start(task_a, "task A", (void*)&seq); | ||||||
|     // TODO how to check that all child task ends?
 |     // TODO how to check that all child task ends?
 | ||||||
|      | 
 | ||||||
|     delay(10); // wait while task do its work
 |     delay(10); // wait while task do its work
 | ||||||
| 
 | 
 | ||||||
|     seq.sequence[seq.count] = '\0'; |     seq.sequence[seq.count] = '\0'; | ||||||
|  | |||||||
| @ -15,7 +15,7 @@ bool test_furi_mute_algorithm(FuriRecordSubscriber* log); | |||||||
| 
 | 
 | ||||||
| void flipper_test_app(void* p) { | void flipper_test_app(void* p) { | ||||||
|     FuriRecordSubscriber* log = get_default_log(); |     FuriRecordSubscriber* log = get_default_log(); | ||||||
|      | 
 | ||||||
|     if(test_furi_ac_create_kill(log)) { |     if(test_furi_ac_create_kill(log)) { | ||||||
|         fuprintf(log, "[TEST] test_furi_ac_create_kill PASSED\n"); |         fuprintf(log, "[TEST] test_furi_ac_create_kill PASSED\n"); | ||||||
|     } else { |     } else { | ||||||
| @ -66,6 +66,5 @@ void flipper_test_app(void* p) { | |||||||
| 
 | 
 | ||||||
|     rust_uart_write(); |     rust_uart_write(); | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
|     furiac_exit(NULL); |     furiac_exit(NULL); | ||||||
| } | } | ||||||
| @ -8,6 +8,8 @@ fn main() { | |||||||
|     cbindgen::generate(&crate_dir) |     cbindgen::generate(&crate_dir) | ||||||
|         .expect("Unable to generate cbindgen bindings") |         .expect("Unable to generate cbindgen bindings") | ||||||
|         .write_to_file( |         .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] | #![no_std] | ||||||
| 
 | 
 | ||||||
| #[cfg(target_arch = "arm")] | #[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] | #[no_mangle] | ||||||
| pub extern "C" fn add(a: u32, b: u32) -> u32 { | pub extern "C" fn add(a: u32, b: u32) -> u32 { | ||||||
|     a + b |     a + b | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| #[no_mangle] | #[no_mangle] | ||||||
| pub extern "C" fn rust_uart_write() { | pub extern "C" fn rust_uart_write() { | ||||||
|     let string = "Rust test string\n"; |     let string = "Rust test string\n"; | ||||||
| @ -28,12 +27,13 @@ pub extern "C" fn rust_uart_write() { | |||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| mod aux { | mod aux { | ||||||
|     use core::panic::PanicInfo; |     use core::panic::PanicInfo; | ||||||
| 
 | 
 | ||||||
|     #[panic_handler] |     #[panic_handler] | ||||||
|     fn panic(_info: &PanicInfo) -> ! { |     fn panic(_info: &PanicInfo) -> ! { | ||||||
|         loop { continue } |         loop { | ||||||
|  |             continue; | ||||||
|  |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  | |||||||
| @ -54,7 +54,7 @@ impl BindingsGenerator { | |||||||
|             "Middlewares/ST/STM32_USB_Device_Library/Core/Inc", |             "Middlewares/ST/STM32_USB_Device_Library/Core/Inc", | ||||||
|             "Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Inc", |             "Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Inc", | ||||||
|         ]; |         ]; | ||||||
|     
 | 
 | ||||||
|         let stm32_sdk_includes = stm32_sdk_includes |         let stm32_sdk_includes = stm32_sdk_includes | ||||||
|             .iter() |             .iter() | ||||||
|             .map(|stm32_include| format!("{}/{}", self.clib_dir.to_string_lossy(), stm32_include)); |             .map(|stm32_include| format!("{}/{}", self.clib_dir.to_string_lossy(), stm32_include)); | ||||||
| @ -64,28 +64,23 @@ impl BindingsGenerator { | |||||||
|         let includes = [ |         let includes = [ | ||||||
|             // This are bindings generated by cbindgen nearby
 |             // This are bindings generated by cbindgen nearby
 | ||||||
|             &flipper_core_bindings.to_string_lossy(), |             &flipper_core_bindings.to_string_lossy(), | ||||||
| 
 |  | ||||||
|             &self.gcc_include_dir.to_string_lossy(), |             &self.gcc_include_dir.to_string_lossy(), | ||||||
|         ]; |         ]; | ||||||
| 
 | 
 | ||||||
|         #[rustfmt::skip] |         #[rustfmt::skip] | ||||||
|         return bindgen::Builder::default() |         return bindgen::Builder::default() | ||||||
|             .use_core() |             .use_core() | ||||||
|     
 |  | ||||||
|             .ctypes_prefix("self") |             .ctypes_prefix("self") | ||||||
|             .blacklist_type("__uint8_t") |             .blacklist_type("__uint8_t") | ||||||
|             .blacklist_type("__uint32_t") |             .blacklist_type("__uint32_t") | ||||||
|             .blacklist_type("c_int") |             .blacklist_type("c_int") | ||||||
|             .blacklist_type("__int32_t") |             .blacklist_type("__int32_t") | ||||||
|     
 |  | ||||||
|             // TODO there's no .no_debug method, to disable only for specific type
 |             // TODO there's no .no_debug method, to disable only for specific type
 | ||||||
|             .derive_debug(false) |             .derive_debug(false) | ||||||
|     
 |  | ||||||
|             .clang_arg("-DUSE_HAL_DRIVER") |             .clang_arg("-DUSE_HAL_DRIVER") | ||||||
|             .clang_arg("-DSTM32L476xx") |             .clang_arg("-DSTM32L476xx") | ||||||
|             .clang_arg("-DBUTON_INVERT=false") |             .clang_arg("-DBUTON_INVERT=false") | ||||||
|             .clang_arg("-DDEBUG_UART=huart1") |             .clang_arg("-DDEBUG_UART=huart1") | ||||||
|     
 |  | ||||||
|             .clang_args( |             .clang_args( | ||||||
|                 (includes.iter().map(|x| From::from(x as &str)).chain(stm32_sdk_includes)) |                 (includes.iter().map(|x| From::from(x as &str)).chain(stm32_sdk_includes)) | ||||||
|                     .map(|include| format!("-I{}", include)) |                     .map(|include| format!("-I{}", include)) | ||||||
| @ -268,7 +263,7 @@ impl BindingsGenerator { | |||||||
|         bindings |         bindings | ||||||
|             .write_to_file(result_path) |             .write_to_file(result_path) | ||||||
|             .expect("Couldn't write bindings!"); |             .expect("Couldn't write bindings!"); | ||||||
|     }    
 |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| fn detect_gcc_inclide_dir() -> PathBuf { | fn detect_gcc_inclide_dir() -> PathBuf { | ||||||
|  | |||||||
| @ -1,5 +1,4 @@ | |||||||
| #![no_std] | #![no_std] | ||||||
| 
 |  | ||||||
| #![allow(dead_code)] | #![allow(dead_code)] | ||||||
| #![allow(non_camel_case_types)] | #![allow(non_camel_case_types)] | ||||||
| #![allow(non_upper_case_globals)] | #![allow(non_upper_case_globals)] | ||||||
| @ -17,4 +16,4 @@ pub mod cmsis_os { | |||||||
| pub mod hal { | pub mod hal { | ||||||
|     include!(concat!(env!("OUT_DIR"), "/stm32_hal_bindings.rs")); |     include!(concat!(env!("OUT_DIR"), "/stm32_hal_bindings.rs")); | ||||||
|     include!(concat!(env!("OUT_DIR"), "/stm32_hal_statics.rs")); |     include!(concat!(env!("OUT_DIR"), "/stm32_hal_statics.rs")); | ||||||
| } | } | ||||||
|  | |||||||
							
								
								
									
										14
									
								
								core/app.cpp
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								core/app.cpp
									
									
									
									
									
								
							| @ -2,10 +2,10 @@ | |||||||
| #include <stdio.h> | #include <stdio.h> | ||||||
| 
 | 
 | ||||||
| extern "C" { | extern "C" { | ||||||
|     #include "startup.h" | #include "startup.h" | ||||||
|     #include "furi.h" | #include "furi.h" | ||||||
|     #include "log.h" | #include "log.h" | ||||||
|     #include "tty_uart.h" | #include "tty_uart.h" | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| extern "C" void app() { | extern "C" void app() { | ||||||
| @ -15,16 +15,16 @@ extern "C" void app() { | |||||||
|     fuprintf(log, "\n=== Welcome to Flipper Zero! ===\n\n"); |     fuprintf(log, "\n=== Welcome to Flipper Zero! ===\n\n"); | ||||||
| 
 | 
 | ||||||
|     // FURI startup
 |     // 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); |         handlers[i] = furiac_start(FLIPPER_STARTUP[i].app, FLIPPER_STARTUP[i].name, NULL); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     bool is_alive = false; |     bool is_alive = false; | ||||||
|     do { |     do { | ||||||
|         is_alive = false; |         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) { |             if(handlers[i]->handler != NULL) { | ||||||
|                 is_alive = true; |                 is_alive = true; | ||||||
|             } |             } | ||||||
|  | |||||||
| @ -4,11 +4,11 @@ | |||||||
| extern "C" { | extern "C" { | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
|     #include "main.h" | #include "main.h" | ||||||
|     #include "flipper_hal.h" | #include "flipper_hal.h" | ||||||
|     #include "cmsis_os.h" | #include "cmsis_os.h" | ||||||
|     #include "furi.h" | #include "furi.h" | ||||||
|     #include "log.h" | #include "log.h" | ||||||
| 
 | 
 | ||||||
| #ifdef __cplusplus | #ifdef __cplusplus | ||||||
| } | } | ||||||
|  | |||||||
							
								
								
									
										126
									
								
								core/furi.c
									
									
									
									
									
								
							
							
						
						
									
										126
									
								
								core/furi.c
									
									
									
									
									
								
							| @ -29,16 +29,16 @@ static FuriRecord* find_record(const char* name) { | |||||||
| 
 | 
 | ||||||
| // TODO: change open-create to only open
 | // TODO: change open-create to only open
 | ||||||
| bool furi_create(const char* name, void* value, size_t size) { | bool furi_create(const char* name, void* value, size_t size) { | ||||||
|     #ifdef FURI_DEBUG | #ifdef FURI_DEBUG | ||||||
|         printf("[FURI] creating %s record\n", name); |     printf("[FURI] creating %s record\n", name); | ||||||
|     #endif | #endif | ||||||
| 
 | 
 | ||||||
|     FuriRecord* record = find_record(name); |     FuriRecord* record = find_record(name); | ||||||
| 
 | 
 | ||||||
|     if(record != NULL) { |     if(record != NULL) { | ||||||
|         #ifdef FURI_DEBUG | #ifdef FURI_DEBUG | ||||||
|             printf("[FURI] record already exist\n"); |         printf("[FURI] record already exist\n"); | ||||||
|         #endif | #endif | ||||||
| 
 | 
 | ||||||
|         record->value = value; |         record->value = value; | ||||||
|         record->size = size; |         record->size = size; | ||||||
| @ -49,17 +49,16 @@ bool furi_create(const char* name, void* value, size_t size) { | |||||||
|     // record not exist, create new
 |     // record not exist, create new
 | ||||||
| 
 | 
 | ||||||
|     if(current_buffer_idx >= MAX_RECORD_COUNT) { |     if(current_buffer_idx >= MAX_RECORD_COUNT) { | ||||||
|         // max record count exceed
 | // max record count exceed
 | ||||||
|         #ifdef FURI_DEBUG | #ifdef FURI_DEBUG | ||||||
|             printf("[FURI] create: max record count exceed\n"); |         printf("[FURI] create: max record count exceed\n"); | ||||||
|         #endif | #endif | ||||||
|         return NULL; |         return NULL; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     records[current_buffer_idx].mute_counter = 0; |     records[current_buffer_idx].mute_counter = 0; | ||||||
|     records[current_buffer_idx].mutex = xSemaphoreCreateMutexStatic( |     records[current_buffer_idx].mutex = | ||||||
|         &records[current_buffer_idx].mutex_buffer |         xSemaphoreCreateMutexStatic(&records[current_buffer_idx].mutex_buffer); | ||||||
|     ); |  | ||||||
|     records[current_buffer_idx].value = value; |     records[current_buffer_idx].value = value; | ||||||
|     records[current_buffer_idx].size = size; |     records[current_buffer_idx].size = size; | ||||||
|     records[current_buffer_idx].name = name; |     records[current_buffer_idx].name = name; | ||||||
| @ -74,26 +73,24 @@ bool furi_create(const char* name, void* value, size_t size) { | |||||||
|     return true; |     return true; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| FuriRecordSubscriber* furi_open( | FuriRecordSubscriber* furi_open(const char* name, | ||||||
|     const char* name, |                                 bool solo, | ||||||
|     bool solo, |                                 bool no_mute, | ||||||
|     bool no_mute, |                                 FlipperRecordCallback value_callback, | ||||||
|     FlipperRecordCallback value_callback, |                                 FlipperRecordStateCallback state_callback, | ||||||
|     FlipperRecordStateCallback state_callback, |                                 void* ctx) { | ||||||
|     void* ctx | #ifdef FURI_DEBUG | ||||||
| ) { |     printf("[FURI] opening %s record\n", name); | ||||||
|     #ifdef FURI_DEBUG | #endif | ||||||
|         printf("[FURI] opening %s record\n", name); |  | ||||||
|     #endif |  | ||||||
| 
 | 
 | ||||||
|     // get furi record by name
 |     // get furi record by name
 | ||||||
|     FuriRecord* record = find_record(name); |     FuriRecord* record = find_record(name); | ||||||
| 
 | 
 | ||||||
|     if(record == NULL) { |     if(record == NULL) { | ||||||
|         // cannot find record
 | // cannot find record
 | ||||||
|         #ifdef FURI_DEBUG | #ifdef FURI_DEBUG | ||||||
|             printf("[FURI] cannot find record %s\n", name); |         printf("[FURI] cannot find record %s\n", name); | ||||||
|         #endif | #endif | ||||||
| 
 | 
 | ||||||
|         // create record if not exist
 |         // create record if not exist
 | ||||||
|         if(!furi_create(name, NULL, 0)) { |         if(!furi_create(name, NULL, 0)) { | ||||||
| @ -118,11 +115,11 @@ FuriRecordSubscriber* furi_open( | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     if(subscriber == NULL) { |     if(subscriber == NULL) { | ||||||
|         // cannot add subscriber (full)
 | // cannot add subscriber (full)
 | ||||||
|         #ifdef FURI_DEBUG | #ifdef FURI_DEBUG | ||||||
|             printf("[FURI] open: cannot add subscriber (full)\n"); |         printf("[FURI] open: cannot add subscriber (full)\n"); | ||||||
|         #endif | #endif | ||||||
|          | 
 | ||||||
|         return NULL; |         return NULL; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -147,19 +144,18 @@ FuriRecordSubscriber* furi_open( | |||||||
|         current_task->records[current_task->records_count] = record; |         current_task->records[current_task->records_count] = record; | ||||||
|         current_task->records_count++; |         current_task->records_count++; | ||||||
|     } else { |     } else { | ||||||
|         #ifdef FURI_DEBUG | #ifdef FURI_DEBUG | ||||||
|             printf("[FURI] open: no current task\n"); |         printf("[FURI] open: no current task\n"); | ||||||
|         #endif | #endif | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     return subscriber; |     return subscriber; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| void furi_close(FuriRecordSubscriber* handler) { | void furi_close(FuriRecordSubscriber* handler) { | ||||||
|     #ifdef FURI_DEBUG | #ifdef FURI_DEBUG | ||||||
|         printf("[FURI] closing %s record\n", handler->record->name); |     printf("[FURI] closing %s record\n", handler->record->name); | ||||||
|     #endif | #endif | ||||||
| 
 | 
 | ||||||
|     // deallocate subscriber
 |     // deallocate subscriber
 | ||||||
|     handler->allocated = false; |     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].allocated) { | ||||||
|             if(handler->record->subscribers[i].cb != NULL) { |             if(handler->record->subscribers[i].cb != NULL) { | ||||||
|                 handler->record->subscribers[i].cb( |                 handler->record->subscribers[i].cb( | ||||||
|                     value, |                     value, size, handler->record->subscribers[i].ctx); | ||||||
|                     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) { | void* furi_take(FuriRecordSubscriber* handler) { | ||||||
|     if(handler == NULL || handler->record == NULL) return NULL; |     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; |         return handler->record->value; | ||||||
|     } else { |     } else { | ||||||
|         return NULL; |         return NULL; | ||||||
| @ -214,9 +207,9 @@ void furi_commit(FuriRecordSubscriber* handler) { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| bool furi_read(FuriRecordSubscriber* handler, void* value, size_t size) { | 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); |     printf("[FURI] read from %s\n", handler->record->name); | ||||||
|     #endif | #endif | ||||||
| 
 | 
 | ||||||
|     if(handler == NULL || handler->record == NULL || value == NULL) return false; |     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) { | 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); |     printf("[FURI] write to %s\n", handler->record->name); | ||||||
|     #endif | #endif | ||||||
| 
 | 
 | ||||||
|     if(handler == NULL || handler->record == NULL || value == NULL) { |     if(handler == NULL || handler->record == NULL || value == NULL) { | ||||||
|         #ifdef FURI_DEBUG | #ifdef FURI_DEBUG | ||||||
|             printf("[FURI] write: null param %x %x\n", (uint32_t)(size_t)handler, (uint32_t)(size_t)value); |         printf("[FURI] write: null param %x %x\n", | ||||||
|         #endif |                (uint32_t)(size_t)handler, | ||||||
|  |                (uint32_t)(size_t)value); | ||||||
|  | #endif | ||||||
| 
 | 
 | ||||||
|         return false; |         return false; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     // check if closed
 |     // check if closed
 | ||||||
|     if(!handler->allocated) { |     if(!handler->allocated) { | ||||||
|         #ifdef FURI_DEBUG | #ifdef FURI_DEBUG | ||||||
|             printf("[FURI] write: handler closed\n"); |         printf("[FURI] write: handler closed\n"); | ||||||
|         #endif | #endif | ||||||
|         return false; |         return false; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     if(handler->record->value != NULL && size > handler->record->size) { |     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); |         printf("[FURI] write: wrong size %d\n", (uint32_t)size); | ||||||
|         #endif | #endif | ||||||
|         return false; |         return false; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     // check mute
 |     // check mute
 | ||||||
|     if( |     if(handler->record->mute_counter != handler->mute_counter && !handler->no_mute) { | ||||||
|         handler->record->mute_counter != handler->mute_counter | #ifdef FURI_DEBUG | ||||||
|         && !handler->no_mute |         printf("[FURI] write: muted\n"); | ||||||
|     ) { | #endif | ||||||
|         #ifdef FURI_DEBUG |  | ||||||
|             printf("[FURI] write: muted\n"); |  | ||||||
|         #endif |  | ||||||
|         return false; |         return false; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | |||||||
							
								
								
									
										21
									
								
								core/furi.h
									
									
									
									
									
								
							
							
						
						
									
										21
									
								
								core/furi.h
									
									
									
									
									
								
							| @ -8,10 +8,10 @@ | |||||||
| #define MAX_RECORD_SUBSCRIBERS 8 | #define MAX_RECORD_SUBSCRIBERS 8 | ||||||
| 
 | 
 | ||||||
| /// application is just a function
 | /// application is just a function
 | ||||||
| typedef void(*FlipperApplication)(void*); | typedef void (*FlipperApplication)(void*); | ||||||
| 
 | 
 | ||||||
| /// pointer to value callback function
 | /// pointer to value callback function
 | ||||||
| typedef void(*FlipperRecordCallback)(const void*, size_t, void*); | typedef void (*FlipperRecordCallback)(const void*, size_t, void*); | ||||||
| 
 | 
 | ||||||
| typedef enum { | typedef enum { | ||||||
|     FlipperRecordStateMute, ///< record open and mute this handler
 |     FlipperRecordStateMute, ///< record open and mute this handler
 | ||||||
| @ -20,7 +20,7 @@ typedef enum { | |||||||
| } FlipperRecordState; | } FlipperRecordState; | ||||||
| 
 | 
 | ||||||
| /// pointer to state callback function
 | /// pointer to state callback function
 | ||||||
| typedef void(*FlipperRecordStateCallback)(FlipperRecordState, void*); | typedef void (*FlipperRecordStateCallback)(FlipperRecordState, void*); | ||||||
| 
 | 
 | ||||||
| struct _FuriRecord; | struct _FuriRecord; | ||||||
| 
 | 
 | ||||||
| @ -90,7 +90,6 @@ bool furiac_kill(FuriApp* app); | |||||||
| // find task pointer by handle
 | // find task pointer by handle
 | ||||||
| FuriApp* find_task(TaskHandle_t handler); | FuriApp* find_task(TaskHandle_t handler); | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| /*!
 | /*!
 | ||||||
| Creates named FURI record. | Creates named FURI record. | ||||||
| \param[in] name you can open this record anywhere | \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. | 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. | \param[in] no_mute if true, another applications cannot mute this handler. | ||||||
| */ | */ | ||||||
| FuriRecordSubscriber* furi_open( | FuriRecordSubscriber* furi_open(const char* name, | ||||||
|     const char* name, |                                 bool solo, | ||||||
|     bool solo, |                                 bool no_mute, | ||||||
|     bool no_mute, |                                 FlipperRecordCallback value_callback, | ||||||
|     FlipperRecordCallback value_callback, |                                 FlipperRecordStateCallback state_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) { | FuriApp* furiac_start(FlipperApplication app, const char* name, void* param) { | ||||||
|     #ifdef FURI_DEBUG | #ifdef FURI_DEBUG | ||||||
|         printf("[FURIAC] start %s\n", name); |     printf("[FURIAC] start %s\n", name); | ||||||
|     #endif | #endif | ||||||
| 
 | 
 | ||||||
|     // TODO check first free item (.handler == NULL) and use it
 |     // TODO check first free item (.handler == NULL) and use it
 | ||||||
| 
 | 
 | ||||||
|     if(current_buffer_idx >= MAX_TASK_COUNT) { |     if(current_buffer_idx >= MAX_TASK_COUNT) { | ||||||
|         // max task count exceed
 | // max task count exceed
 | ||||||
|         #ifdef FURI_DEBUG | #ifdef FURI_DEBUG | ||||||
|             printf("[FURIAC] max task count exceed\n"); |         printf("[FURIAC] max task count exceed\n"); | ||||||
|         #endif | #endif | ||||||
|         return NULL; |         return NULL; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     // create task on static stack memory
 |     // create task on static stack memory
 | ||||||
|     task_buffer[current_buffer_idx].handler = xTaskCreateStatic( |     task_buffer[current_buffer_idx].handler = | ||||||
|         (TaskFunction_t)app, |         xTaskCreateStatic((TaskFunction_t)app, | ||||||
|         (const char * const)name, |                           (const char* const)name, | ||||||
|         DEFAULT_STACK_SIZE / 4, // freertos specify stack size in words
 |                           DEFAULT_STACK_SIZE / 4, // freertos specify stack size in words
 | ||||||
|         (void * const) param, |                           (void* const)param, | ||||||
|         tskIDLE_PRIORITY + 3, // normal priority
 |                           tskIDLE_PRIORITY + 3, // normal priority
 | ||||||
|         stack_buffer[current_buffer_idx], |                           stack_buffer[current_buffer_idx], | ||||||
|         &task_info_buffer[current_buffer_idx] |                           &task_info_buffer[current_buffer_idx]); | ||||||
|     ); |  | ||||||
| 
 | 
 | ||||||
|     // save task
 |     // save task
 | ||||||
|     task_buffer[current_buffer_idx].application = app; |     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) { | bool furiac_kill(FuriApp* app) { | ||||||
|     #ifdef FURI_DEBUG | #ifdef FURI_DEBUG | ||||||
|         printf("[FURIAC] kill %s\n", app->name); |     printf("[FURIAC] kill %s\n", app->name); | ||||||
|     #endif | #endif | ||||||
| 
 | 
 | ||||||
|     // check handler
 |     // check handler
 | ||||||
|     if(app == NULL || app->handler == NULL) return false; |     if(app == NULL || app->handler == NULL) return false; | ||||||
| @ -90,16 +89,16 @@ void furiac_exit(void* param) { | |||||||
| 
 | 
 | ||||||
|     // run prev
 |     // run prev
 | ||||||
|     if(current_task != NULL) { |     if(current_task != NULL) { | ||||||
|         #ifdef FURI_DEBUG | #ifdef FURI_DEBUG | ||||||
|             printf("[FURIAC] exit %s\n", current_task->name); |         printf("[FURIAC] exit %s\n", current_task->name); | ||||||
|         #endif | #endif | ||||||
| 
 | 
 | ||||||
|         if(current_task->prev != NULL) { |         if(current_task->prev != NULL) { | ||||||
|             furiac_start(current_task->prev, current_task->prev_name, param); |             furiac_start(current_task->prev, current_task->prev_name, param); | ||||||
|         } else { |         } else { | ||||||
|             #ifdef FURI_DEBUG | #ifdef FURI_DEBUG | ||||||
|                 printf("[FURIAC] no prev\n"); |             printf("[FURIAC] no prev\n"); | ||||||
|             #endif | #endif | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         // cleanup registry
 |         // cleanup registry
 | ||||||
| @ -108,7 +107,7 @@ void furiac_exit(void* param) { | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     // kill itself
 |     // kill itself
 | ||||||
|      vTaskDelete(NULL); |     vTaskDelete(NULL); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void furiac_switch(FlipperApplication app, char* name, void* param) { | void furiac_switch(FlipperApplication app, char* name, void* param) { | ||||||
| @ -116,14 +115,14 @@ void furiac_switch(FlipperApplication app, char* name, void* param) { | |||||||
|     FuriApp* current_task = find_task(xTaskGetCurrentTaskHandle()); |     FuriApp* current_task = find_task(xTaskGetCurrentTaskHandle()); | ||||||
| 
 | 
 | ||||||
|     if(current_task == NULL) { |     if(current_task == NULL) { | ||||||
|         #ifdef FURI_DEBUG | #ifdef FURI_DEBUG | ||||||
|             printf("[FURIAC] no current task found\n"); |         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); |     printf("[FURIAC] switch %s to %s\n", current_task->name, name); | ||||||
|     #endif | #endif | ||||||
| 
 | 
 | ||||||
|     // run next
 |     // run next
 | ||||||
|     FuriApp* next = furiac_start(app, name, param); |     FuriApp* next = furiac_start(app, name, param); | ||||||
|  | |||||||
| @ -9,7 +9,7 @@ | |||||||
| 
 | 
 | ||||||
| #define PRINT_STR_SIZE 64 | #define PRINT_STR_SIZE 64 | ||||||
| 
 | 
 | ||||||
| void fuprintf(FuriRecordSubscriber* f, const char * format, ...) { | void fuprintf(FuriRecordSubscriber* f, const char* format, ...) { | ||||||
|     char buffer[PRINT_STR_SIZE]; |     char buffer[PRINT_STR_SIZE]; | ||||||
| 
 | 
 | ||||||
|     va_list args; |     va_list args; | ||||||
|  | |||||||
| @ -3,4 +3,4 @@ | |||||||
| #include "furi.h" | #include "furi.h" | ||||||
| 
 | 
 | ||||||
| FuriRecordSubscriber* get_default_log(); | FuriRecordSubscriber* get_default_log(); | ||||||
| void fuprintf(FuriRecordSubscriber* f, const char * format, ...); | void fuprintf(FuriRecordSubscriber* f, const char* format, ...); | ||||||
|  | |||||||
| @ -6,19 +6,19 @@ | |||||||
| extern UART_HandleTypeDef DEBUG_UART; | extern UART_HandleTypeDef DEBUG_UART; | ||||||
| 
 | 
 | ||||||
| void handle_uart_write(const void* data, size_t size, void* ctx) { | void handle_uart_write(const void* data, size_t size, void* ctx) { | ||||||
| 	HAL_UART_Transmit(&DEBUG_UART, (uint8_t*)data, (uint16_t)size, HAL_MAX_DELAY); |     HAL_UART_Transmit(&DEBUG_UART, (uint8_t*)data, (uint16_t)size, HAL_MAX_DELAY); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static ssize_t stdout_write(void *_cookie, const char *buf, size_t n) { | static ssize_t stdout_write(void* _cookie, const char* buf, size_t n) { | ||||||
|     FuriRecordSubscriber *log = pvTaskGetThreadLocalStoragePointer(NULL, 0); |     FuriRecordSubscriber* log = pvTaskGetThreadLocalStoragePointer(NULL, 0); | ||||||
|     if (log == NULL) { |     if(log == NULL) { | ||||||
|         log = furi_open("tty", false, false, NULL, NULL, NULL); |         log = furi_open("tty", false, false, NULL, NULL, NULL); | ||||||
|         if (log == NULL) { |         if(log == NULL) { | ||||||
|             return -1; |             return -1; | ||||||
|         } |         } | ||||||
|         vTaskSetThreadLocalStoragePointer(NULL, 0, log); |         vTaskSetThreadLocalStoragePointer(NULL, 0, log); | ||||||
|     } |     } | ||||||
|     if (buf == 0) { |     if(buf == 0) { | ||||||
|         /*
 |         /*
 | ||||||
|          * This means that we should flush internal buffers.  Since we |          * This means that we should flush internal buffers.  Since we | ||||||
|          * don't we just return.  (Remember, "handle" == -1 means that all |          * don't we just return.  (Remember, "handle" == -1 means that all | ||||||
| @ -33,22 +33,24 @@ static ssize_t stdout_write(void *_cookie, const char *buf, size_t n) { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| bool register_tty_uart() { | bool register_tty_uart() { | ||||||
| 	if(!furi_create("tty", NULL, 0)) { |     if(!furi_create("tty", NULL, 0)) { | ||||||
| 		return false; |         return false; | ||||||
| 	} |     } | ||||||
| 
 | 
 | ||||||
| 	if(furi_open("tty", false, false, handle_uart_write, NULL, NULL) == NULL) { |     if(furi_open("tty", false, false, handle_uart_write, NULL, NULL) == NULL) { | ||||||
| 		return false; |         return false; | ||||||
| 	} |     } | ||||||
| 
 | 
 | ||||||
|     FILE* fp = fopencookie(NULL, "w", (cookie_io_functions_t) { |     FILE* fp = fopencookie(NULL, | ||||||
|         .read = NULL, |                            "w", | ||||||
|         .write = stdout_write, |                            (cookie_io_functions_t){ | ||||||
|         .seek = NULL, |                                .read = NULL, | ||||||
|         .close = NULL, |                                .write = stdout_write, | ||||||
|     }); |                                .seek = NULL, | ||||||
|  |                                .close = NULL, | ||||||
|  |                            }); | ||||||
|     setvbuf(fp, NULL, _IONBF, 0); |     setvbuf(fp, NULL, _IONBF, 0); | ||||||
|     stdout = fp; |     stdout = fp; | ||||||
| 
 | 
 | ||||||
| 	return true; |     return true; | ||||||
| } | } | ||||||
|  | |||||||
| @ -12,4 +12,5 @@ services: | |||||||
|     working_dir: "/project" |     working_dir: "/project" | ||||||
|     environment: |     environment: | ||||||
|       DISPLAY: $DISPLAY |       DISPLAY: $DISPLAY | ||||||
|  |       TERM: xterm-256color | ||||||
|       PATH: /root/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin |       PATH: /root/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin | ||||||
|  | |||||||
| @ -1,6 +1,8 @@ | |||||||
| FROM ubuntu:18.04 | FROM ubuntu:18.04 | ||||||
| 
 | 
 | ||||||
| RUN apt-get update && \ | ENV PATH /root/.cargo/bin:$PATH | ||||||
|  | 
 | ||||||
|  | RUN apt update && \ | ||||||
|     apt install -y --no-install-recommends \ |     apt install -y --no-install-recommends \ | ||||||
|         make \ |         make \ | ||||||
|         gcc-arm-none-eabi \ |         gcc-arm-none-eabi \ | ||||||
| @ -17,10 +19,15 @@ RUN apt-get update && \ | |||||||
|         python \ |         python \ | ||||||
|         python-pip \ |         python-pip \ | ||||||
|         libstdc++-arm-none-eabi-newlib \ |         libstdc++-arm-none-eabi-newlib \ | ||||||
|         libclang-10-dev && \ |         libclang-10-dev \ | ||||||
|     apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* |         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"] | 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! |  * 1 tab == 4 spaces! | ||||||
|  */ |  */ | ||||||
|  /* USER CODE END Header */ | /* USER CODE END Header */ | ||||||
| 
 | 
 | ||||||
| #ifndef FREERTOS_CONFIG_H | #ifndef FREERTOS_CONFIG_H | ||||||
| #define FREERTOS_CONFIG_H | #define FREERTOS_CONFIG_H | ||||||
| @ -42,15 +42,15 @@ | |||||||
|  * See http://www.freertos.org/a00110.html
 |  * See http://www.freertos.org/a00110.html
 | ||||||
|  *----------------------------------------------------------*/ |  *----------------------------------------------------------*/ | ||||||
| 
 | 
 | ||||||
| /* USER CODE BEGIN Includes */   	       | /* USER CODE BEGIN Includes */ | ||||||
| /* Section where include file can be added */ | /* Section where include file can be added */ | ||||||
| /* USER CODE END Includes */  | /* USER CODE END Includes */ | ||||||
| 
 | 
 | ||||||
| /* Ensure definitions are only used by the compiler, and not by the assembler. */ | /* Ensure definitions are only used by the compiler, and not by the assembler. */ | ||||||
| #if defined(__ICCARM__) || defined(__CC_ARM) || defined(__GNUC__) | #if defined(__ICCARM__) || defined(__CC_ARM) || defined(__GNUC__) | ||||||
|   #include <stdint.h> | #include <stdint.h> | ||||||
|   extern uint32_t SystemCoreClock; | extern uint32_t SystemCoreClock; | ||||||
|   void xPortSysTickHandler(void); | void xPortSysTickHandler(void); | ||||||
| #endif | #endif | ||||||
| #define configUSE_PREEMPTION                     1 | #define configUSE_PREEMPTION                     1 | ||||||
| #define configSUPPORT_STATIC_ALLOCATION          1 | #define configSUPPORT_STATIC_ALLOCATION          1 | ||||||
| @ -71,37 +71,37 @@ | |||||||
| #define configNUM_THREAD_LOCAL_STORAGE_POINTERS  1 | #define configNUM_THREAD_LOCAL_STORAGE_POINTERS  1 | ||||||
| 
 | 
 | ||||||
| /* Co-routine definitions. */ | /* Co-routine definitions. */ | ||||||
| #define configUSE_CO_ROUTINES                    0 | #define configUSE_CO_ROUTINES 0 | ||||||
| #define configMAX_CO_ROUTINE_PRIORITIES          ( 2 ) | #define configMAX_CO_ROUTINE_PRIORITIES (2) | ||||||
| 
 | 
 | ||||||
| /* Software timer definitions. */ | /* Software timer definitions. */ | ||||||
| #define configUSE_TIMERS                         1 | #define configUSE_TIMERS 1 | ||||||
| #define configTIMER_TASK_PRIORITY                ( 2 ) | #define configTIMER_TASK_PRIORITY (2) | ||||||
| #define configTIMER_QUEUE_LENGTH                 10 | #define configTIMER_QUEUE_LENGTH 10 | ||||||
| #define configTIMER_TASK_STACK_DEPTH             256 | #define configTIMER_TASK_STACK_DEPTH 256 | ||||||
| 
 | 
 | ||||||
| /* Set the following definitions to 1 to include the API function, or zero
 | /* Set the following definitions to 1 to include the API function, or zero
 | ||||||
| to exclude the API function. */ | to exclude the API function. */ | ||||||
| #define INCLUDE_vTaskPrioritySet            1 | #define INCLUDE_vTaskPrioritySet 1 | ||||||
| #define INCLUDE_uxTaskPriorityGet           1 | #define INCLUDE_uxTaskPriorityGet 1 | ||||||
| #define INCLUDE_vTaskDelete                 1 | #define INCLUDE_vTaskDelete 1 | ||||||
| #define INCLUDE_vTaskCleanUpResources       0 | #define INCLUDE_vTaskCleanUpResources 0 | ||||||
| #define INCLUDE_vTaskSuspend                1 | #define INCLUDE_vTaskSuspend 1 | ||||||
| #define INCLUDE_vTaskDelayUntil             0 | #define INCLUDE_vTaskDelayUntil 0 | ||||||
| #define INCLUDE_vTaskDelay                  1 | #define INCLUDE_vTaskDelay 1 | ||||||
| #define INCLUDE_xTaskGetSchedulerState      1 | #define INCLUDE_xTaskGetSchedulerState 1 | ||||||
| 
 | 
 | ||||||
| /* Cortex-M specific definitions. */ | /* Cortex-M specific definitions. */ | ||||||
| #ifdef __NVIC_PRIO_BITS | #ifdef __NVIC_PRIO_BITS | ||||||
|  /* __BVIC_PRIO_BITS will be specified when CMSIS is being used. */ | /* __BVIC_PRIO_BITS will be specified when CMSIS is being used. */ | ||||||
|  #define configPRIO_BITS         __NVIC_PRIO_BITS | #define configPRIO_BITS __NVIC_PRIO_BITS | ||||||
| #else | #else | ||||||
|  #define configPRIO_BITS         4 | #define configPRIO_BITS 4 | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| /* The lowest interrupt priority that can be used in a call to a "set priority"
 | /* The lowest interrupt priority that can be used in a call to a "set priority"
 | ||||||
| function. */ | function. */ | ||||||
| #define configLIBRARY_LOWEST_INTERRUPT_PRIORITY   15 | #define configLIBRARY_LOWEST_INTERRUPT_PRIORITY 15 | ||||||
| 
 | 
 | ||||||
| /* The highest interrupt priority that can be used by any interrupt service
 | /* The highest interrupt priority that can be used by any interrupt service
 | ||||||
| routine that makes calls to interrupt safe FreeRTOS API functions.  DO NOT CALL | routine that makes calls to interrupt safe FreeRTOS API functions.  DO NOT CALL | ||||||
| @ -111,29 +111,36 @@ PRIORITY THAN THIS! (higher priorities are lower numeric values. */ | |||||||
| 
 | 
 | ||||||
| /* Interrupt priorities used by the kernel port layer itself.  These are generic
 | /* 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. */ | 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 !!!!
 | /* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!!
 | ||||||
| See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */
 | 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
 | /* Normal assert() semantics without relying on the provision of an assert.h
 | ||||||
| header file. */ | header file. */ | ||||||
| /* USER CODE BEGIN 1 */ | /* 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 */ | /* USER CODE END 1 */ | ||||||
| 
 | 
 | ||||||
| /* Definitions that map the FreeRTOS port interrupt handlers to their CMSIS
 | /* Definitions that map the FreeRTOS port interrupt handlers to their CMSIS
 | ||||||
| standard names. */ | standard names. */ | ||||||
| #define vPortSVCHandler    SVC_Handler | #define vPortSVCHandler SVC_Handler | ||||||
| #define xPortPendSVHandler PendSV_Handler | #define xPortPendSVHandler PendSV_Handler | ||||||
| 
 | 
 | ||||||
| /* IMPORTANT: This define is commented when used with STM32Cube firmware, when the timebase source is SysTick,
 | /* IMPORTANT: This define is commented when used with STM32Cube firmware, when the timebase source is SysTick,
 | ||||||
|               to prevent overwriting SysTick_Handler defined within STM32Cube HAL */ |               to prevent overwriting SysTick_Handler defined within STM32Cube HAL */ | ||||||
|   | 
 | ||||||
| /* #define xPortSysTickHandler SysTick_Handler */ | /* #define xPortSysTickHandler SysTick_Handler */ | ||||||
| 
 | 
 | ||||||
| /* USER CODE BEGIN Defines */   	       | /* USER CODE BEGIN Defines */ | ||||||
| /* Section where parameter definitions can be added (for instance, to override default ones in FreeRTOS.h) */ | /* Section where parameter definitions can be added (for instance, to override default ones in FreeRTOS.h) */ | ||||||
| /* USER CODE END Defines */  | /* USER CODE END Defines */ | ||||||
| 
 | 
 | ||||||
| #endif /* FREERTOS_CONFIG_H */ | #endif /* FREERTOS_CONFIG_H */ | ||||||
|  | |||||||
| @ -9,11 +9,7 @@ GPIO and HAL implementations | |||||||
| #include <stdbool.h> | #include <stdbool.h> | ||||||
| #include "main.h" | #include "main.h" | ||||||
| 
 | 
 | ||||||
| typedef enum { | typedef enum { GpioModeInput, GpioModeOutput, GpioModeOpenDrain } GpioMode; | ||||||
|     GpioModeInput, |  | ||||||
|     GpioModeOutput, |  | ||||||
|     GpioModeOpenDrain |  | ||||||
| } GpioMode; |  | ||||||
| 
 | 
 | ||||||
| typedef struct { | typedef struct { | ||||||
|     GPIO_TypeDef* port; |     GPIO_TypeDef* port; | ||||||
| @ -50,7 +46,8 @@ inline void app_tim_ic_init(bool both) { | |||||||
|     HAL_TIM_OC_Stop(&htim8, TIM_CHANNEL_2); |     HAL_TIM_OC_Stop(&htim8, TIM_CHANNEL_2); | ||||||
| 
 | 
 | ||||||
|     TIM_IC_InitTypeDef sConfigIC = {0}; |     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.ICSelection = TIM_ICSELECTION_DIRECTTI; | ||||||
|     sConfigIC.ICPrescaler = TIM_ICPSC_DIV1; |     sConfigIC.ICPrescaler = TIM_ICPSC_DIV1; | ||||||
|     sConfigIC.ICFilter = 0; |     sConfigIC.ICFilter = 0; | ||||||
|  | |||||||
| @ -38,10 +38,7 @@ extern "C" { | |||||||
| /* Exported types ------------------------------------------------------------*/ | /* Exported types ------------------------------------------------------------*/ | ||||||
| /* USER CODE BEGIN ET */ | /* USER CODE BEGIN ET */ | ||||||
| 
 | 
 | ||||||
| typedef enum { | typedef enum { TimerEventInputCapture, TimerEventEndOfPulse } TimerEvent; | ||||||
|   TimerEventInputCapture, |  | ||||||
|   TimerEventEndOfPulse |  | ||||||
| } TimerEvent; |  | ||||||
| 
 | 
 | ||||||
| /* USER CODE END ET */ | /* USER CODE END ET */ | ||||||
| 
 | 
 | ||||||
| @ -55,14 +52,14 @@ typedef enum { | |||||||
| 
 | 
 | ||||||
| /* USER CODE END EM */ | /* USER CODE END EM */ | ||||||
| 
 | 
 | ||||||
| void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim); | void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim); | ||||||
| 
 | 
 | ||||||
| /* Exported functions prototypes ---------------------------------------------*/ | /* Exported functions prototypes ---------------------------------------------*/ | ||||||
| void Error_Handler(void); | void Error_Handler(void); | ||||||
| 
 | 
 | ||||||
| /* USER CODE BEGIN EFP */ | /* 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 */ | /* 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_GPIO_Port RFID_OUT_GPIO_Port | ||||||
| #define EM_PIN_Pin RFID_OUT_Pin | #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 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
 | //2 main, 5 remote, 3 M16
 | ||||||
| #define GDO2     GpioPin{.port = NULL, .pin = 0} | #define GDO2                   \ | ||||||
| #define GDO0     GpioPin{.port = CC1101_G0_GPIO_Port, .pin = CC1101_G0_Pin} |     GpioPin {                  \ | ||||||
|  |         .port = NULL, .pin = 0 \ | ||||||
|  |     } | ||||||
|  | #define GDO0                                              \ | ||||||
|  |     GpioPin {                                             \ | ||||||
|  |         .port = CC1101_G0_GPIO_Port, .pin = CC1101_G0_Pin \ | ||||||
|  |     } | ||||||
| 
 | 
 | ||||||
| /* USER CODE END Private defines */ | /* USER CODE END Private defines */ | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -30,14 +30,14 @@ | |||||||
|   * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |   * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||||
|   * |   * | ||||||
|   ****************************************************************************** |   ****************************************************************************** | ||||||
|   */  |   */ | ||||||
| 
 | 
 | ||||||
| /* Define to prevent recursive inclusion -------------------------------------*/ | /* Define to prevent recursive inclusion -------------------------------------*/ | ||||||
| #ifndef __STM32L4xx_HAL_CONF_H | #ifndef __STM32L4xx_HAL_CONF_H | ||||||
| #define __STM32L4xx_HAL_CONF_H | #define __STM32L4xx_HAL_CONF_H | ||||||
| 
 | 
 | ||||||
| #ifdef __cplusplus | #ifdef __cplusplus | ||||||
|  extern "C" { | extern "C" { | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| /* Exported types ------------------------------------------------------------*/ | /* Exported types ------------------------------------------------------------*/ | ||||||
| @ -48,7 +48,7 @@ | |||||||
|   * @brief This is the list of modules to be used in the HAL driver  |   * @brief This is the list of modules to be used in the HAL driver  | ||||||
|   */ |   */ | ||||||
| 
 | 
 | ||||||
| #define HAL_MODULE_ENABLED   | #define HAL_MODULE_ENABLED | ||||||
| #define HAL_ADC_MODULE_ENABLED | #define HAL_ADC_MODULE_ENABLED | ||||||
| /*#define HAL_CRYP_MODULE_ENABLED   */ | /*#define HAL_CRYP_MODULE_ENABLED   */ | ||||||
| /*#define HAL_CAN_MODULE_ENABLED   */ | /*#define HAL_CAN_MODULE_ENABLED   */ | ||||||
| @ -95,7 +95,7 @@ | |||||||
| /*#define HAL_WWDG_MODULE_ENABLED   */ | /*#define HAL_WWDG_MODULE_ENABLED   */ | ||||||
| /*#define HAL_EXTI_MODULE_ENABLED   */ | /*#define HAL_EXTI_MODULE_ENABLED   */ | ||||||
| #define HAL_GPIO_MODULE_ENABLED | #define HAL_GPIO_MODULE_ENABLED | ||||||
| #define HAL_EXTI_MODULE_ENABLED  | #define HAL_EXTI_MODULE_ENABLED | ||||||
| #define HAL_I2C_MODULE_ENABLED | #define HAL_I2C_MODULE_ENABLED | ||||||
| #define HAL_DMA_MODULE_ENABLED | #define HAL_DMA_MODULE_ENABLED | ||||||
| #define HAL_RCC_MODULE_ENABLED | #define HAL_RCC_MODULE_ENABLED | ||||||
| @ -109,28 +109,28 @@ | |||||||
|   *        This value is used by the RCC HAL module to compute the system frequency |   *        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).   |   *        (when HSE is used as system clock source, directly or through the PLL).   | ||||||
|   */ |   */ | ||||||
| #if !defined  (HSE_VALUE)  | #if !defined(HSE_VALUE) | ||||||
|   #define HSE_VALUE    ((uint32_t)16000000U) /*!< Value of the External oscillator in Hz */ | #define HSE_VALUE ((uint32_t)16000000U) /*!< Value of the External oscillator in Hz */ | ||||||
| #endif /* HSE_VALUE */ | #endif /* HSE_VALUE */ | ||||||
| 
 | 
 | ||||||
| #if !defined  (HSE_STARTUP_TIMEOUT) | #if !defined(HSE_STARTUP_TIMEOUT) | ||||||
|   #define HSE_STARTUP_TIMEOUT    ((uint32_t)100U)   /*!< Time out for HSE start up, in ms */ | #define HSE_STARTUP_TIMEOUT ((uint32_t)100U) /*!< Time out for HSE start up, in ms */ | ||||||
| #endif /* HSE_STARTUP_TIMEOUT */ | #endif /* HSE_STARTUP_TIMEOUT */ | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
|   * @brief Internal Multiple Speed oscillator (MSI) default value. |   * @brief Internal Multiple Speed oscillator (MSI) default value. | ||||||
|   *        This value is the default MSI range value after Reset. |   *        This value is the default MSI range value after Reset. | ||||||
|   */ |   */ | ||||||
| #if !defined  (MSI_VALUE) | #if !defined(MSI_VALUE) | ||||||
|   #define MSI_VALUE    ((uint32_t)4000000U) /*!< Value of the Internal oscillator in Hz*/ | #define MSI_VALUE ((uint32_t)4000000U) /*!< Value of the Internal oscillator in Hz*/ | ||||||
| #endif /* MSI_VALUE */ | #endif /* MSI_VALUE */ | ||||||
| /**
 | /**
 | ||||||
|   * @brief Internal High Speed oscillator (HSI) value. |   * @brief Internal High Speed oscillator (HSI) value. | ||||||
|   *        This value is used by the RCC HAL module to compute the system frequency |   *        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).  |   *        (when HSI is used as system clock source, directly or through the PLL).  | ||||||
|   */ |   */ | ||||||
| #if !defined  (HSI_VALUE) | #if !defined(HSI_VALUE) | ||||||
|   #define HSI_VALUE    ((uint32_t)16000000U) /*!< Value of the Internal oscillator in Hz*/ | #define HSI_VALUE ((uint32_t)16000000U) /*!< Value of the Internal oscillator in Hz*/ | ||||||
| #endif /* HSI_VALUE */ | #endif /* HSI_VALUE */ | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
| @ -140,17 +140,18 @@ | |||||||
|   *        When the CRS is not used, the HSI48 RC oscillator runs on it default frequency |   *        When the CRS is not used, the HSI48 RC oscillator runs on it default frequency | ||||||
|   *        which is subject to manufacturing process variations. |   *        which is subject to manufacturing process variations. | ||||||
|   */ |   */ | ||||||
| #if !defined  (HSI48_VALUE)  | #if !defined(HSI48_VALUE) | ||||||
|  #define HSI48_VALUE   ((uint32_t)48000000U) /*!< Value of the Internal High Speed oscillator for USB FS/SDMMC/RNG in Hz. | #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.*/ |                                               The real value my vary depending on manufacturing process variations.*/ | ||||||
| #endif /* HSI48_VALUE */ | #endif /* HSI48_VALUE */ | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
|   * @brief Internal Low Speed oscillator (LSI) value. |   * @brief Internal Low Speed oscillator (LSI) value. | ||||||
|   */ |   */ | ||||||
| #if !defined  (LSI_VALUE)  | #if !defined(LSI_VALUE) | ||||||
|  #define LSI_VALUE  ((uint32_t)32000U)       /*!< LSI Typical Value in Hz*/ | #define LSI_VALUE ((uint32_t)32000U) /*!< LSI Typical Value in Hz*/ | ||||||
| #endif /* LSI_VALUE */                      /*!< Value of the Internal Low Speed oscillator in Hz | #endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz | ||||||
|                                              The real value may vary depending on the variations |                                              The real value may vary depending on the variations | ||||||
|                                              in voltage and temperature.*/ |                                              in voltage and temperature.*/ | ||||||
| 
 | 
 | ||||||
| @ -158,12 +159,12 @@ | |||||||
|   * @brief External Low Speed oscillator (LSE) value. |   * @brief External Low Speed oscillator (LSE) value. | ||||||
|   *        This value is used by the UART, RTC HAL module to compute the system frequency |   *        This value is used by the UART, RTC HAL module to compute the system frequency | ||||||
|   */ |   */ | ||||||
| #if !defined  (LSE_VALUE) | #if !defined(LSE_VALUE) | ||||||
|   #define LSE_VALUE    ((uint32_t)32768U) /*!< Value of the External oscillator in Hz*/ | #define LSE_VALUE ((uint32_t)32768U) /*!< Value of the External oscillator in Hz*/ | ||||||
| #endif /* LSE_VALUE */ | #endif /* LSE_VALUE */ | ||||||
| 
 | 
 | ||||||
| #if !defined  (LSE_STARTUP_TIMEOUT) | #if !defined(LSE_STARTUP_TIMEOUT) | ||||||
|   #define LSE_STARTUP_TIMEOUT    ((uint32_t)5000U)   /*!< Time out for LSE start up, in ms */ | #define LSE_STARTUP_TIMEOUT ((uint32_t)5000U) /*!< Time out for LSE start up, in ms */ | ||||||
| #endif /* HSE_STARTUP_TIMEOUT */ | #endif /* HSE_STARTUP_TIMEOUT */ | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
| @ -171,8 +172,9 @@ | |||||||
|   *        This value is used by the RCC HAL module to compute the SAI1 & SAI2 clock source  |   *        This value is used by the RCC HAL module to compute the SAI1 & SAI2 clock source  | ||||||
|   *        frequency. |   *        frequency. | ||||||
|   */ |   */ | ||||||
| #if !defined  (EXTERNAL_SAI1_CLOCK_VALUE) | #if !defined(EXTERNAL_SAI1_CLOCK_VALUE) | ||||||
|   #define EXTERNAL_SAI1_CLOCK_VALUE    ((uint32_t)2097000U) /*!< Value of the SAI1 External clock source in Hz*/ | #define EXTERNAL_SAI1_CLOCK_VALUE \ | ||||||
|  |     ((uint32_t)2097000U) /*!< Value of the SAI1 External clock source in Hz*/ | ||||||
| #endif /* EXTERNAL_SAI1_CLOCK_VALUE */ | #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  |   *        This value is used by the RCC HAL module to compute the SAI1 & SAI2 clock source  | ||||||
|   *        frequency. |   *        frequency. | ||||||
|   */ |   */ | ||||||
| #if !defined  (EXTERNAL_SAI2_CLOCK_VALUE) | #if !defined(EXTERNAL_SAI2_CLOCK_VALUE) | ||||||
|   #define EXTERNAL_SAI2_CLOCK_VALUE    ((uint32_t)2097000U) /*!< Value of the SAI2 External clock source in Hz*/ | #define EXTERNAL_SAI2_CLOCK_VALUE \ | ||||||
|  |     ((uint32_t)2097000U) /*!< Value of the SAI2 External clock source in Hz*/ | ||||||
| #endif /* EXTERNAL_SAI2_CLOCK_VALUE */ | #endif /* EXTERNAL_SAI2_CLOCK_VALUE */ | ||||||
| 
 | 
 | ||||||
| /* Tip: To avoid modifying this file each time you need to use different HSE,
 | /* Tip: To avoid modifying this file each time you need to use different HSE,
 | ||||||
| @ -190,14 +193,14 @@ | |||||||
| /* ########################### System Configuration ######################### */ | /* ########################### System Configuration ######################### */ | ||||||
| /**
 | /**
 | ||||||
|   * @brief This is the HAL system configuration section |   * @brief This is the HAL system configuration section | ||||||
|   */      |   */ | ||||||
|    | 
 | ||||||
| #define  VDD_VALUE					  ((uint32_t)3300U) /*!< Value of VDD in mv */            | #define VDD_VALUE ((uint32_t)3300U) /*!< Value of VDD in mv */ | ||||||
| #define  TICK_INT_PRIORITY            ((uint32_t)15U)    /*!< tick interrupt priority */             | #define TICK_INT_PRIORITY ((uint32_t)15U) /*!< tick interrupt priority */ | ||||||
| #define  USE_RTOS                     0U      | #define USE_RTOS 0U | ||||||
| #define  PREFETCH_ENABLE              1U | #define PREFETCH_ENABLE 1U | ||||||
| #define  INSTRUCTION_CACHE_ENABLE     1U | #define INSTRUCTION_CACHE_ENABLE 1U | ||||||
| #define  DATA_CACHE_ENABLE            1U | #define DATA_CACHE_ENABLE 1U | ||||||
| 
 | 
 | ||||||
| /* ########################## Assert Selection ############################## */ | /* ########################## Assert Selection ############################## */ | ||||||
| /**
 | /**
 | ||||||
| @ -213,7 +216,7 @@ | |||||||
|  * Deactivated: CRC code cleaned from driver |  * Deactivated: CRC code cleaned from driver | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| #define USE_SPI_CRC                   0U | #define USE_SPI_CRC 0U | ||||||
| 
 | 
 | ||||||
| /* Includes ------------------------------------------------------------------*/ | /* Includes ------------------------------------------------------------------*/ | ||||||
| /**
 | /**
 | ||||||
| @ -221,201 +224,201 @@ | |||||||
|   */ |   */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_RCC_MODULE_ENABLED | #ifdef HAL_RCC_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_rcc.h" | #include "stm32l4xx_hal_rcc.h" | ||||||
|   #include "stm32l4xx_hal_rcc_ex.h" | #include "stm32l4xx_hal_rcc_ex.h" | ||||||
| #endif /* HAL_RCC_MODULE_ENABLED */ | #endif /* HAL_RCC_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_EXTI_MODULE_ENABLED | #ifdef HAL_EXTI_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_exti.h" | #include "stm32l4xx_hal_exti.h" | ||||||
| #endif /* HAL_EXTI_MODULE_ENABLED */ | #endif /* HAL_EXTI_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_GPIO_MODULE_ENABLED | #ifdef HAL_GPIO_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_gpio.h" | #include "stm32l4xx_hal_gpio.h" | ||||||
| #endif /* HAL_GPIO_MODULE_ENABLED */ | #endif /* HAL_GPIO_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_DMA_MODULE_ENABLED | #ifdef HAL_DMA_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_dma.h" | #include "stm32l4xx_hal_dma.h" | ||||||
|   #include "stm32l4xx_hal_dma_ex.h" | #include "stm32l4xx_hal_dma_ex.h" | ||||||
| #endif /* HAL_DMA_MODULE_ENABLED */ | #endif /* HAL_DMA_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_DFSDM_MODULE_ENABLED | #ifdef HAL_DFSDM_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_dfsdm.h" | #include "stm32l4xx_hal_dfsdm.h" | ||||||
| #endif /* HAL_DFSDM_MODULE_ENABLED */ | #endif /* HAL_DFSDM_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_CORTEX_MODULE_ENABLED | #ifdef HAL_CORTEX_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_cortex.h" | #include "stm32l4xx_hal_cortex.h" | ||||||
| #endif /* HAL_CORTEX_MODULE_ENABLED */ | #endif /* HAL_CORTEX_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_ADC_MODULE_ENABLED | #ifdef HAL_ADC_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_adc.h" | #include "stm32l4xx_hal_adc.h" | ||||||
| #endif /* HAL_ADC_MODULE_ENABLED */ | #endif /* HAL_ADC_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_CAN_MODULE_ENABLED | #ifdef HAL_CAN_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_can.h" | #include "stm32l4xx_hal_can.h" | ||||||
| #endif /* HAL_CAN_MODULE_ENABLED */ | #endif /* HAL_CAN_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_COMP_MODULE_ENABLED | #ifdef HAL_COMP_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_comp.h" | #include "stm32l4xx_hal_comp.h" | ||||||
| #endif /* HAL_COMP_MODULE_ENABLED */ | #endif /* HAL_COMP_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_CRC_MODULE_ENABLED | #ifdef HAL_CRC_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_crc.h" | #include "stm32l4xx_hal_crc.h" | ||||||
| #endif /* HAL_CRC_MODULE_ENABLED */ | #endif /* HAL_CRC_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_CRYP_MODULE_ENABLED | #ifdef HAL_CRYP_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_cryp.h" | #include "stm32l4xx_hal_cryp.h" | ||||||
| #endif /* HAL_CRYP_MODULE_ENABLED */ | #endif /* HAL_CRYP_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_DAC_MODULE_ENABLED | #ifdef HAL_DAC_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_dac.h" | #include "stm32l4xx_hal_dac.h" | ||||||
| #endif /* HAL_DAC_MODULE_ENABLED */ | #endif /* HAL_DAC_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_DCMI_MODULE_ENABLED | #ifdef HAL_DCMI_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_dcmi.h" | #include "stm32l4xx_hal_dcmi.h" | ||||||
| #endif /* HAL_DCMI_MODULE_ENABLED */ | #endif /* HAL_DCMI_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_DMA2D_MODULE_ENABLED | #ifdef HAL_DMA2D_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_dma2d.h" | #include "stm32l4xx_hal_dma2d.h" | ||||||
| #endif /* HAL_DMA2D_MODULE_ENABLED */ | #endif /* HAL_DMA2D_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_DSI_MODULE_ENABLED | #ifdef HAL_DSI_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_dsi.h" | #include "stm32l4xx_hal_dsi.h" | ||||||
| #endif /* HAL_DSI_MODULE_ENABLED */ | #endif /* HAL_DSI_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_FIREWALL_MODULE_ENABLED | #ifdef HAL_FIREWALL_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_firewall.h" | #include "stm32l4xx_hal_firewall.h" | ||||||
| #endif /* HAL_FIREWALL_MODULE_ENABLED */ | #endif /* HAL_FIREWALL_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_FLASH_MODULE_ENABLED | #ifdef HAL_FLASH_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_flash.h" | #include "stm32l4xx_hal_flash.h" | ||||||
| #endif /* HAL_FLASH_MODULE_ENABLED */ | #endif /* HAL_FLASH_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_HASH_MODULE_ENABLED | #ifdef HAL_HASH_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_hash.h" | #include "stm32l4xx_hal_hash.h" | ||||||
| #endif /* HAL_HASH_MODULE_ENABLED */ | #endif /* HAL_HASH_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_SRAM_MODULE_ENABLED | #ifdef HAL_SRAM_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_sram.h" | #include "stm32l4xx_hal_sram.h" | ||||||
| #endif /* HAL_SRAM_MODULE_ENABLED */ | #endif /* HAL_SRAM_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_MMC_MODULE_ENABLED | #ifdef HAL_MMC_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_mmc.h" | #include "stm32l4xx_hal_mmc.h" | ||||||
| #endif /* HAL_MMC_MODULE_ENABLED */ | #endif /* HAL_MMC_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_NOR_MODULE_ENABLED | #ifdef HAL_NOR_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_nor.h" | #include "stm32l4xx_hal_nor.h" | ||||||
| #endif /* HAL_NOR_MODULE_ENABLED */ | #endif /* HAL_NOR_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_NAND_MODULE_ENABLED | #ifdef HAL_NAND_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_nand.h" | #include "stm32l4xx_hal_nand.h" | ||||||
| #endif /* HAL_NAND_MODULE_ENABLED */ | #endif /* HAL_NAND_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_I2C_MODULE_ENABLED | #ifdef HAL_I2C_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_i2c.h" | #include "stm32l4xx_hal_i2c.h" | ||||||
| #endif /* HAL_I2C_MODULE_ENABLED */ | #endif /* HAL_I2C_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_IWDG_MODULE_ENABLED | #ifdef HAL_IWDG_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_iwdg.h" | #include "stm32l4xx_hal_iwdg.h" | ||||||
| #endif /* HAL_IWDG_MODULE_ENABLED */ | #endif /* HAL_IWDG_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_LCD_MODULE_ENABLED | #ifdef HAL_LCD_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_lcd.h" | #include "stm32l4xx_hal_lcd.h" | ||||||
| #endif /* HAL_LCD_MODULE_ENABLED */ | #endif /* HAL_LCD_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_LPTIM_MODULE_ENABLED | #ifdef HAL_LPTIM_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_lptim.h" | #include "stm32l4xx_hal_lptim.h" | ||||||
| #endif /* HAL_LPTIM_MODULE_ENABLED */ | #endif /* HAL_LPTIM_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_LTDC_MODULE_ENABLED | #ifdef HAL_LTDC_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_ltdc.h" | #include "stm32l4xx_hal_ltdc.h" | ||||||
| #endif /* HAL_LTDC_MODULE_ENABLED */ | #endif /* HAL_LTDC_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_OPAMP_MODULE_ENABLED | #ifdef HAL_OPAMP_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_opamp.h" | #include "stm32l4xx_hal_opamp.h" | ||||||
| #endif /* HAL_OPAMP_MODULE_ENABLED */ | #endif /* HAL_OPAMP_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_OSPI_MODULE_ENABLED | #ifdef HAL_OSPI_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_ospi.h" | #include "stm32l4xx_hal_ospi.h" | ||||||
| #endif /* HAL_OSPI_MODULE_ENABLED */ | #endif /* HAL_OSPI_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_PWR_MODULE_ENABLED | #ifdef HAL_PWR_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_pwr.h" | #include "stm32l4xx_hal_pwr.h" | ||||||
| #endif /* HAL_PWR_MODULE_ENABLED */ | #endif /* HAL_PWR_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_QSPI_MODULE_ENABLED | #ifdef HAL_QSPI_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_qspi.h" | #include "stm32l4xx_hal_qspi.h" | ||||||
| #endif /* HAL_QSPI_MODULE_ENABLED */ | #endif /* HAL_QSPI_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_RNG_MODULE_ENABLED | #ifdef HAL_RNG_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_rng.h" | #include "stm32l4xx_hal_rng.h" | ||||||
| #endif /* HAL_RNG_MODULE_ENABLED */ | #endif /* HAL_RNG_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_RTC_MODULE_ENABLED | #ifdef HAL_RTC_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_rtc.h" | #include "stm32l4xx_hal_rtc.h" | ||||||
| #endif /* HAL_RTC_MODULE_ENABLED */ | #endif /* HAL_RTC_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_SAI_MODULE_ENABLED | #ifdef HAL_SAI_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_sai.h" | #include "stm32l4xx_hal_sai.h" | ||||||
| #endif /* HAL_SAI_MODULE_ENABLED */ | #endif /* HAL_SAI_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_SD_MODULE_ENABLED | #ifdef HAL_SD_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_sd.h" | #include "stm32l4xx_hal_sd.h" | ||||||
| #endif /* HAL_SD_MODULE_ENABLED */ | #endif /* HAL_SD_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_SMBUS_MODULE_ENABLED | #ifdef HAL_SMBUS_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_smbus.h" | #include "stm32l4xx_hal_smbus.h" | ||||||
| #endif /* HAL_SMBUS_MODULE_ENABLED */ | #endif /* HAL_SMBUS_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_SPI_MODULE_ENABLED | #ifdef HAL_SPI_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_spi.h" | #include "stm32l4xx_hal_spi.h" | ||||||
| #endif /* HAL_SPI_MODULE_ENABLED */ | #endif /* HAL_SPI_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_SWPMI_MODULE_ENABLED | #ifdef HAL_SWPMI_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_swpmi.h" | #include "stm32l4xx_hal_swpmi.h" | ||||||
| #endif /* HAL_SWPMI_MODULE_ENABLED */ | #endif /* HAL_SWPMI_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_TIM_MODULE_ENABLED | #ifdef HAL_TIM_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_tim.h" | #include "stm32l4xx_hal_tim.h" | ||||||
| #endif /* HAL_TIM_MODULE_ENABLED */ | #endif /* HAL_TIM_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_TSC_MODULE_ENABLED | #ifdef HAL_TSC_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_tsc.h" | #include "stm32l4xx_hal_tsc.h" | ||||||
| #endif /* HAL_TSC_MODULE_ENABLED */ | #endif /* HAL_TSC_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_UART_MODULE_ENABLED | #ifdef HAL_UART_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_uart.h" | #include "stm32l4xx_hal_uart.h" | ||||||
| #endif /* HAL_UART_MODULE_ENABLED */ | #endif /* HAL_UART_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_USART_MODULE_ENABLED | #ifdef HAL_USART_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_usart.h" | #include "stm32l4xx_hal_usart.h" | ||||||
| #endif /* HAL_USART_MODULE_ENABLED */ | #endif /* HAL_USART_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_IRDA_MODULE_ENABLED | #ifdef HAL_IRDA_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_irda.h" | #include "stm32l4xx_hal_irda.h" | ||||||
| #endif /* HAL_IRDA_MODULE_ENABLED */ | #endif /* HAL_IRDA_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_SMARTCARD_MODULE_ENABLED | #ifdef HAL_SMARTCARD_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_smartcard.h" | #include "stm32l4xx_hal_smartcard.h" | ||||||
| #endif /* HAL_SMARTCARD_MODULE_ENABLED */ | #endif /* HAL_SMARTCARD_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_WWDG_MODULE_ENABLED | #ifdef HAL_WWDG_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_wwdg.h" | #include "stm32l4xx_hal_wwdg.h" | ||||||
| #endif /* HAL_WWDG_MODULE_ENABLED */ | #endif /* HAL_WWDG_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_PCD_MODULE_ENABLED | #ifdef HAL_PCD_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_pcd.h" | #include "stm32l4xx_hal_pcd.h" | ||||||
| #endif /* HAL_PCD_MODULE_ENABLED */ | #endif /* HAL_PCD_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_HCD_MODULE_ENABLED | #ifdef HAL_HCD_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_hcd.h" | #include "stm32l4xx_hal_hcd.h" | ||||||
| #endif /* HAL_HCD_MODULE_ENABLED */ | #endif /* HAL_HCD_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_GFXMMU_MODULE_ENABLED | #ifdef HAL_GFXMMU_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_gfxmmu.h" | #include "stm32l4xx_hal_gfxmmu.h" | ||||||
| #endif /* HAL_GFXMMU_MODULE_ENABLED */ | #endif /* HAL_GFXMMU_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| /* Exported macro ------------------------------------------------------------*/ | /* Exported macro ------------------------------------------------------------*/ | ||||||
| #ifdef  USE_FULL_ASSERT | #ifdef USE_FULL_ASSERT | ||||||
| /**
 | /**
 | ||||||
|   * @brief  The assert_param macro is used for function's parameters check. |   * @brief  The assert_param macro is used for function's parameters check. | ||||||
|   * @param  expr: If expr is false, it calls assert_failed function |   * @param  expr: If expr is false, it calls assert_failed function | ||||||
| @ -424,11 +427,11 @@ | |||||||
|   *         If expr is true, it returns no value. |   *         If expr is true, it returns no value. | ||||||
|   * @retval None |   * @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 ------------------------------------------------------- */ | /* Exported functions ------------------------------------------------------- */ | ||||||
|   void assert_failed(char *file, uint32_t line); | void assert_failed(char* file, uint32_t line); | ||||||
| #else | #else | ||||||
|   #define assert_param(expr) ((void)0U) | #define assert_param(expr) ((void)0U) | ||||||
| #endif /* USE_FULL_ASSERT */ | #endif /* USE_FULL_ASSERT */ | ||||||
| 
 | 
 | ||||||
| #ifdef __cplusplus | #ifdef __cplusplus | ||||||
|  | |||||||
| @ -23,8 +23,8 @@ | |||||||
| #define __STM32L4xx_IT_H | #define __STM32L4xx_IT_H | ||||||
| 
 | 
 | ||||||
| #ifdef __cplusplus | #ifdef __cplusplus | ||||||
|  extern "C" { | extern "C" { | ||||||
| #endif  | #endif | ||||||
| 
 | 
 | ||||||
| /* Private includes ----------------------------------------------------------*/ | /* Private includes ----------------------------------------------------------*/ | ||||||
| /* USER CODE BEGIN Includes */ | /* USER CODE BEGIN Includes */ | ||||||
|  | |||||||
| @ -24,7 +24,7 @@ | |||||||
| #define __USB_DEVICE__H__ | #define __USB_DEVICE__H__ | ||||||
| 
 | 
 | ||||||
| #ifdef __cplusplus | #ifdef __cplusplus | ||||||
|  extern "C" { | extern "C" { | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| /* Includes ------------------------------------------------------------------*/ | /* Includes ------------------------------------------------------------------*/ | ||||||
|  | |||||||
| @ -24,7 +24,7 @@ | |||||||
| #define __USBD_CDC_IF_H__ | #define __USBD_CDC_IF_H__ | ||||||
| 
 | 
 | ||||||
| #ifdef __cplusplus | #ifdef __cplusplus | ||||||
|  extern "C" { | extern "C" { | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| /* Includes ------------------------------------------------------------------*/ | /* Includes ------------------------------------------------------------------*/ | ||||||
| @ -38,11 +38,11 @@ | |||||||
|   * @brief For Usb device. |   * @brief For Usb device. | ||||||
|   * @{ |   * @{ | ||||||
|   */ |   */ | ||||||
|    | 
 | ||||||
| /** @defgroup USBD_CDC_IF USBD_CDC_IF
 | /** @defgroup USBD_CDC_IF USBD_CDC_IF
 | ||||||
|   * @brief Usb VCP device module |   * @brief Usb VCP device module | ||||||
|   * @{ |   * @{ | ||||||
|   */  |   */ | ||||||
| 
 | 
 | ||||||
| /** @defgroup USBD_CDC_IF_Exported_Defines USBD_CDC_IF_Exported_Defines
 | /** @defgroup USBD_CDC_IF_Exported_Defines USBD_CDC_IF_Exported_Defines
 | ||||||
|   * @brief Defines. |   * @brief Defines. | ||||||
|  | |||||||
| @ -24,7 +24,7 @@ | |||||||
| #define __USBD_CONF__H__ | #define __USBD_CONF__H__ | ||||||
| 
 | 
 | ||||||
| #ifdef __cplusplus | #ifdef __cplusplus | ||||||
|  extern "C" { | extern "C" { | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| /* Includes ------------------------------------------------------------------*/ | /* Includes ------------------------------------------------------------------*/ | ||||||
| @ -61,21 +61,21 @@ | |||||||
|   */ |   */ | ||||||
| 
 | 
 | ||||||
| /*---------- -----------*/ | /*---------- -----------*/ | ||||||
| #define USBD_MAX_NUM_INTERFACES     1U | #define USBD_MAX_NUM_INTERFACES 1U | ||||||
| /*---------- -----------*/ | /*---------- -----------*/ | ||||||
| #define USBD_MAX_NUM_CONFIGURATION     1U | #define USBD_MAX_NUM_CONFIGURATION 1U | ||||||
| /*---------- -----------*/ | /*---------- -----------*/ | ||||||
| #define USBD_MAX_STR_DESC_SIZ     512U | #define USBD_MAX_STR_DESC_SIZ 512U | ||||||
| /*---------- -----------*/ | /*---------- -----------*/ | ||||||
| #define USBD_DEBUG_LEVEL     0U | #define USBD_DEBUG_LEVEL 0U | ||||||
| /*---------- -----------*/ | /*---------- -----------*/ | ||||||
| #define USBD_LPM_ENABLED     1U | #define USBD_LPM_ENABLED 1U | ||||||
| /*---------- -----------*/ | /*---------- -----------*/ | ||||||
| #define USBD_SELF_POWERED     1U | #define USBD_SELF_POWERED 1U | ||||||
| 
 | 
 | ||||||
| /****************************************/ | /****************************************/ | ||||||
| /* #define for FS and HS identification */ | /* #define for FS and HS identification */ | ||||||
| #define DEVICE_FS 		0 | #define DEVICE_FS 0 | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
|   * @} |   * @} | ||||||
| @ -89,42 +89,45 @@ | |||||||
| /* Memory management macros */ | /* Memory management macros */ | ||||||
| 
 | 
 | ||||||
| /** Alias for memory allocation. */ | /** Alias for memory allocation. */ | ||||||
| #define USBD_malloc         (uint32_t *)USBD_static_malloc | #define USBD_malloc (uint32_t*)USBD_static_malloc | ||||||
| 
 | 
 | ||||||
| /** Alias for memory release. */ | /** Alias for memory release. */ | ||||||
| #define USBD_free           USBD_static_free | #define USBD_free USBD_static_free | ||||||
| 
 | 
 | ||||||
| /** Alias for memory set. */ | /** Alias for memory set. */ | ||||||
| #define USBD_memset         /* Not used */ | #define USBD_memset /* Not used */ | ||||||
| 
 | 
 | ||||||
| /** Alias for memory copy. */ | /** Alias for memory copy. */ | ||||||
| #define USBD_memcpy         /* Not used */ | #define USBD_memcpy /* Not used */ | ||||||
| 
 | 
 | ||||||
| /** Alias for delay. */ | /** Alias for delay. */ | ||||||
| #define USBD_Delay          HAL_Delay | #define USBD_Delay HAL_Delay | ||||||
| 
 | 
 | ||||||
| /* DEBUG macros */ | /* DEBUG macros */ | ||||||
| 
 | 
 | ||||||
| #if (USBD_DEBUG_LEVEL > 0) | #if(USBD_DEBUG_LEVEL > 0) | ||||||
| #define USBD_UsrLog(...)    printf(__VA_ARGS__);\ | #define USBD_UsrLog(...) \ | ||||||
|                             printf("\n"); |     printf(__VA_ARGS__); \ | ||||||
|  |     printf("\n"); | ||||||
| #else | #else | ||||||
| #define USBD_UsrLog(...) | #define USBD_UsrLog(...) | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| #if (USBD_DEBUG_LEVEL > 1) | #if(USBD_DEBUG_LEVEL > 1) | ||||||
| 
 | 
 | ||||||
| #define USBD_ErrLog(...)    printf("ERROR: ") ;\ | #define USBD_ErrLog(...) \ | ||||||
|                             printf(__VA_ARGS__);\ |     printf("ERROR: ");   \ | ||||||
|                             printf("\n"); |     printf(__VA_ARGS__); \ | ||||||
|  |     printf("\n"); | ||||||
| #else | #else | ||||||
| #define USBD_ErrLog(...) | #define USBD_ErrLog(...) | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| #if (USBD_DEBUG_LEVEL > 2) | #if(USBD_DEBUG_LEVEL > 2) | ||||||
| #define USBD_DbgLog(...)    printf("DEBUG : ") ;\ | #define USBD_DbgLog(...) \ | ||||||
|                             printf(__VA_ARGS__);\ |     printf("DEBUG : ");  \ | ||||||
|                             printf("\n"); |     printf(__VA_ARGS__); \ | ||||||
|  |     printf("\n"); | ||||||
| #else | #else | ||||||
| #define USBD_DbgLog(...) | #define USBD_DbgLog(...) | ||||||
| #endif | #endif | ||||||
| @ -148,8 +151,8 @@ | |||||||
|   */ |   */ | ||||||
| 
 | 
 | ||||||
| /* Exported functions -------------------------------------------------------*/ | /* Exported functions -------------------------------------------------------*/ | ||||||
| void *USBD_static_malloc(uint32_t size); | void* USBD_static_malloc(uint32_t size); | ||||||
| void USBD_static_free(void *p); | void USBD_static_free(void* p); | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
|   * @} |   * @} | ||||||
|  | |||||||
| @ -17,13 +17,13 @@ | |||||||
|   * |   * | ||||||
|   ****************************************************************************** |   ****************************************************************************** | ||||||
|   */ |   */ | ||||||
| /* USER CODE END Header */   | /* USER CODE END Header */ | ||||||
| /* Define to prevent recursive inclusion -------------------------------------*/ | /* Define to prevent recursive inclusion -------------------------------------*/ | ||||||
| #ifndef __USBD_DESC__C__ | #ifndef __USBD_DESC__C__ | ||||||
| #define __USBD_DESC__C__ | #define __USBD_DESC__C__ | ||||||
| 
 | 
 | ||||||
| #ifdef __cplusplus | #ifdef __cplusplus | ||||||
|  extern "C" { | extern "C" { | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| /* Includes ------------------------------------------------------------------*/ | /* Includes ------------------------------------------------------------------*/ | ||||||
| @ -41,16 +41,16 @@ | |||||||
|   * @brief Usb device descriptors module. |   * @brief Usb device descriptors module. | ||||||
|   * @{ |   * @{ | ||||||
|   */ |   */ | ||||||
|    | 
 | ||||||
| /** @defgroup USBD_DESC_Exported_Constants USBD_DESC_Exported_Constants
 | /** @defgroup USBD_DESC_Exported_Constants USBD_DESC_Exported_Constants
 | ||||||
|   * @brief Constants. |   * @brief Constants. | ||||||
|   * @{ |   * @{ | ||||||
|   */ |   */ | ||||||
| #define         DEVICE_ID1          (UID_BASE) | #define DEVICE_ID1 (UID_BASE) | ||||||
| #define         DEVICE_ID2          (UID_BASE + 0x4) | #define DEVICE_ID2 (UID_BASE + 0x4) | ||||||
| #define         DEVICE_ID3          (UID_BASE + 0x8) | #define DEVICE_ID3 (UID_BASE + 0x8) | ||||||
| 
 | 
 | ||||||
| #define  USB_SIZ_STRING_SERIAL       0x1A | #define USB_SIZ_STRING_SERIAL 0x1A | ||||||
| 
 | 
 | ||||||
| /* USER CODE BEGIN EXPORTED_CONSTANTS */ | /* USER CODE BEGIN EXPORTED_CONSTANTS */ | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -15,18 +15,18 @@ void app_gpio_init(GpioPin gpio, GpioMode mode) { | |||||||
|         GPIO_InitStruct.Pull = GPIO_NOPULL; |         GPIO_InitStruct.Pull = GPIO_NOPULL; | ||||||
| 
 | 
 | ||||||
|         switch(mode) { |         switch(mode) { | ||||||
|             case GpioModeInput: |         case GpioModeInput: | ||||||
|                 GPIO_InitStruct.Mode = GPIO_MODE_INPUT; |             GPIO_InitStruct.Mode = GPIO_MODE_INPUT; | ||||||
|             break; |             break; | ||||||
| 
 | 
 | ||||||
|             case GpioModeOutput:  |         case GpioModeOutput: | ||||||
|                 GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; |             GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; | ||||||
|                 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM; |             GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM; | ||||||
|             break; |             break; | ||||||
| 
 | 
 | ||||||
|             case GpioModeOpenDrain: |         case GpioModeOpenDrain: | ||||||
|                 GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_OD; |             GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_OD; | ||||||
|                 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM; |             GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM; | ||||||
|             break; |             break; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
| @ -36,20 +36,21 @@ void app_gpio_init(GpioPin gpio, GpioMode mode) { | |||||||
| 
 | 
 | ||||||
| // TODO delay from timer
 | // TODO delay from timer
 | ||||||
| void delay_us(uint32_t time) { | void delay_us(uint32_t time) { | ||||||
|   time *= 11.8; |     time *= 11.8; | ||||||
| 
 | 
 | ||||||
|   while(time--) {} |     while(time--) { | ||||||
|  |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void pwm_set(float value, float freq, TIM_HandleTypeDef* tim, uint32_t channel) { | void pwm_set(float value, float freq, TIM_HandleTypeDef* tim, uint32_t channel) { | ||||||
|     tim->Init.CounterMode = TIM_COUNTERMODE_UP; |     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.ClockDivision = TIM_CLOCKDIVISION_DIV1; | ||||||
|     tim->Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; |     tim->Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; | ||||||
|     HAL_TIM_PWM_Init(tim); |     HAL_TIM_PWM_Init(tim); | ||||||
| 
 | 
 | ||||||
|     TIM_OC_InitTypeDef sConfigOC; |     TIM_OC_InitTypeDef sConfigOC; | ||||||
|    | 
 | ||||||
|     sConfigOC.OCMode = TIM_OCMODE_PWM1; |     sConfigOC.OCMode = TIM_OCMODE_PWM1; | ||||||
|     sConfigOC.Pulse = (uint16_t)(291 * value); |     sConfigOC.Pulse = (uint16_t)(291 * value); | ||||||
|     sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH; |     sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH; | ||||||
|  | |||||||
| @ -24,7 +24,7 @@ | |||||||
| #include "main.h" | #include "main.h" | ||||||
| 
 | 
 | ||||||
| /* Private includes ----------------------------------------------------------*/ | /* Private includes ----------------------------------------------------------*/ | ||||||
| /* USER CODE BEGIN Includes */      | /* USER CODE BEGIN Includes */ | ||||||
| #include <stdbool.h> | #include <stdbool.h> | ||||||
| 
 | 
 | ||||||
| /* USER CODE END Includes */ | /* USER CODE END Includes */ | ||||||
| @ -51,22 +51,25 @@ | |||||||
| 
 | 
 | ||||||
| /* Private function prototypes -----------------------------------------------*/ | /* Private function prototypes -----------------------------------------------*/ | ||||||
| /* USER CODE BEGIN FunctionPrototypes */ | /* USER CODE BEGIN FunctionPrototypes */ | ||||||
|     | 
 | ||||||
| /* USER CODE END FunctionPrototypes */ | /* USER CODE END FunctionPrototypes */ | ||||||
| 
 | 
 | ||||||
| /* GetIdleTaskMemory prototype (linked to static allocation support) */ | /* 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) */ | /* 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 */ | /* Hook prototypes */ | ||||||
| void vApplicationIdleHook(void); | void vApplicationIdleHook(void); | ||||||
| 
 | 
 | ||||||
| /* USER CODE BEGIN 2 */ | /* USER CODE BEGIN 2 */ | ||||||
| __weak void vApplicationIdleHook( void ) | __weak void vApplicationIdleHook(void) { | ||||||
| { |     /* vApplicationIdleHook() will only be called if configUSE_IDLE_HOOK is set
 | ||||||
|    /* 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 |    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 |    task. It is essential that code added to this hook function never attempts | ||||||
|    to block in any way (for example, call xQueueReceive() with a block time |    to block in any way (for example, call xQueueReceive() with a block time | ||||||
| @ -81,27 +84,29 @@ __weak void vApplicationIdleHook( void ) | |||||||
| /* USER CODE BEGIN GET_IDLE_TASK_MEMORY */ | /* USER CODE BEGIN GET_IDLE_TASK_MEMORY */ | ||||||
| static StaticTask_t xIdleTaskTCBBuffer; | static StaticTask_t xIdleTaskTCBBuffer; | ||||||
| static StackType_t xIdleStack[configMINIMAL_STACK_SIZE]; | 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, | ||||||
|   *ppxIdleTaskTCBBuffer = &xIdleTaskTCBBuffer; |                                    uint32_t* pulIdleTaskStackSize) { | ||||||
|   *ppxIdleTaskStackBuffer = &xIdleStack[0]; |     *ppxIdleTaskTCBBuffer = &xIdleTaskTCBBuffer; | ||||||
|   *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE; |     *ppxIdleTaskStackBuffer = &xIdleStack[0]; | ||||||
|   /* place for user code */ |     *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE; | ||||||
| }                    |     /* place for user code */ | ||||||
|  | } | ||||||
| /* USER CODE END GET_IDLE_TASK_MEMORY */ | /* USER CODE END GET_IDLE_TASK_MEMORY */ | ||||||
| 
 | 
 | ||||||
| /* USER CODE BEGIN GET_TIMER_TASK_MEMORY */ | /* USER CODE BEGIN GET_TIMER_TASK_MEMORY */ | ||||||
| static StaticTask_t xTimerTaskTCBBuffer; | static StaticTask_t xTimerTaskTCBBuffer; | ||||||
| static StackType_t xTimerStack[configTIMER_TASK_STACK_DEPTH]; | 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, | ||||||
|   *ppxTimerTaskTCBBuffer = &xTimerTaskTCBBuffer; |                                     uint32_t* pulTimerTaskStackSize) { | ||||||
|   *ppxTimerTaskStackBuffer = &xTimerStack[0]; |     *ppxTimerTaskTCBBuffer = &xTimerTaskTCBBuffer; | ||||||
|   *pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH; |     *ppxTimerTaskStackBuffer = &xTimerStack[0]; | ||||||
|   /* place for user code */ |     *pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH; | ||||||
| }                    |     /* place for user code */ | ||||||
|  | } | ||||||
| /* USER CODE END GET_TIMER_TASK_MEMORY */ | /* USER CODE END GET_TIMER_TASK_MEMORY */ | ||||||
| 
 | 
 | ||||||
| /* Private application code --------------------------------------------------*/ | /* Private application code --------------------------------------------------*/ | ||||||
| @ -111,7 +116,7 @@ bool task_equal(TaskHandle_t a, TaskHandle_t b) { | |||||||
| 
 | 
 | ||||||
|     return a == b; |     return a == b; | ||||||
| } | } | ||||||
|       | 
 | ||||||
| /* USER CODE END Application */ | /* USER CODE END Application */ | ||||||
| 
 | 
 | ||||||
| /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | ||||||
|  | |||||||
							
								
								
									
										1063
									
								
								target_f1/Src/main.c
									
									
									
									
									
								
							
							
						
						
									
										1063
									
								
								target_f1/Src/main.c
									
									
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @ -32,7 +32,7 @@ | |||||||
| 
 | 
 | ||||||
| /* Private define ------------------------------------------------------------*/ | /* Private define ------------------------------------------------------------*/ | ||||||
| /* USER CODE BEGIN Define */ | /* USER CODE BEGIN Define */ | ||||||
|   | 
 | ||||||
| /* USER CODE END Define */ | /* USER CODE END Define */ | ||||||
| 
 | 
 | ||||||
| /* Private macro -------------------------------------------------------------*/ | /* Private macro -------------------------------------------------------------*/ | ||||||
| @ -58,27 +58,26 @@ | |||||||
| /* USER CODE BEGIN 0 */ | /* USER CODE BEGIN 0 */ | ||||||
| 
 | 
 | ||||||
| /* USER CODE END 0 */ | /* USER CODE END 0 */ | ||||||
|                          | 
 | ||||||
| void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim); | void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim); | ||||||
|                                         /**
 | /**
 | ||||||
|   * Initializes the Global MSP. |   * Initializes the Global MSP. | ||||||
|   */ |   */ | ||||||
| void HAL_MspInit(void) | void HAL_MspInit(void) { | ||||||
| { |     /* USER CODE BEGIN MspInit 0 */ | ||||||
|   /* USER CODE BEGIN MspInit 0 */ |  | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END MspInit 0 */ |     /* USER CODE END MspInit 0 */ | ||||||
| 
 | 
 | ||||||
|   __HAL_RCC_SYSCFG_CLK_ENABLE(); |     __HAL_RCC_SYSCFG_CLK_ENABLE(); | ||||||
|   __HAL_RCC_PWR_CLK_ENABLE(); |     __HAL_RCC_PWR_CLK_ENABLE(); | ||||||
| 
 | 
 | ||||||
|   /* System interrupt init*/ |     /* System interrupt init*/ | ||||||
|   /* PendSV_IRQn interrupt configuration */ |     /* PendSV_IRQn interrupt configuration */ | ||||||
|   HAL_NVIC_SetPriority(PendSV_IRQn, 15, 0); |     HAL_NVIC_SetPriority(PendSV_IRQn, 15, 0); | ||||||
| 
 | 
 | ||||||
|   /* USER CODE BEGIN MspInit 1 */ |     /* USER CODE BEGIN MspInit 1 */ | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END MspInit 1 */ |     /* USER CODE END MspInit 1 */ | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
| @ -87,38 +86,35 @@ void HAL_MspInit(void) | |||||||
| * @param hadc: ADC handle pointer | * @param hadc: ADC handle pointer | ||||||
| * @retval None | * @retval None | ||||||
| */ | */ | ||||||
| void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc) | void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc) { | ||||||
| { |     GPIO_InitTypeDef GPIO_InitStruct = {0}; | ||||||
|   GPIO_InitTypeDef GPIO_InitStruct = {0}; |     if(hadc->Instance == ADC1) { | ||||||
|   if(hadc->Instance==ADC1) |         /* USER CODE BEGIN ADC1_MspInit 0 */ | ||||||
|   { |  | ||||||
|   /* USER CODE BEGIN ADC1_MspInit 0 */ |  | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END ADC1_MspInit 0 */ |         /* USER CODE END ADC1_MspInit 0 */ | ||||||
|     /* Peripheral clock enable */ |         /* Peripheral clock enable */ | ||||||
|     __HAL_RCC_ADC_CLK_ENABLE(); |         __HAL_RCC_ADC_CLK_ENABLE(); | ||||||
|    | 
 | ||||||
|     __HAL_RCC_GPIOC_CLK_ENABLE(); |         __HAL_RCC_GPIOC_CLK_ENABLE(); | ||||||
|     __HAL_RCC_GPIOA_CLK_ENABLE(); |         __HAL_RCC_GPIOA_CLK_ENABLE(); | ||||||
|     /**ADC1 GPIO Configuration    
 |         /**ADC1 GPIO Configuration    
 | ||||||
|     PC3     ------> ADC1_IN4 |     PC3     ------> ADC1_IN4 | ||||||
|     PA0     ------> ADC1_IN5  |     PA0     ------> ADC1_IN5  | ||||||
|     */ |     */ | ||||||
|     GPIO_InitStruct.Pin = BATT_V_Pin; |         GPIO_InitStruct.Pin = BATT_V_Pin; | ||||||
|     GPIO_InitStruct.Mode = GPIO_MODE_ANALOG_ADC_CONTROL; |         GPIO_InitStruct.Mode = GPIO_MODE_ANALOG_ADC_CONTROL; | ||||||
|     GPIO_InitStruct.Pull = GPIO_NOPULL; |         GPIO_InitStruct.Pull = GPIO_NOPULL; | ||||||
|     HAL_GPIO_Init(BATT_V_GPIO_Port, &GPIO_InitStruct); |         HAL_GPIO_Init(BATT_V_GPIO_Port, &GPIO_InitStruct); | ||||||
| 
 | 
 | ||||||
|     GPIO_InitStruct.Pin = IR_RX_Pin; |         GPIO_InitStruct.Pin = IR_RX_Pin; | ||||||
|     GPIO_InitStruct.Mode = GPIO_MODE_ANALOG_ADC_CONTROL; |         GPIO_InitStruct.Mode = GPIO_MODE_ANALOG_ADC_CONTROL; | ||||||
|     GPIO_InitStruct.Pull = GPIO_NOPULL; |         GPIO_InitStruct.Pull = GPIO_NOPULL; | ||||||
|     HAL_GPIO_Init(IR_RX_GPIO_Port, &GPIO_InitStruct); |         HAL_GPIO_Init(IR_RX_GPIO_Port, &GPIO_InitStruct); | ||||||
| 
 | 
 | ||||||
|   /* USER CODE BEGIN ADC1_MspInit 1 */ |         /* USER CODE BEGIN ADC1_MspInit 1 */ | ||||||
| 
 |  | ||||||
|   /* USER CODE END ADC1_MspInit 1 */ |  | ||||||
|   } |  | ||||||
| 
 | 
 | ||||||
|  |         /* USER CODE END ADC1_MspInit 1 */ | ||||||
|  |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
| @ -127,29 +123,26 @@ void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc) | |||||||
| * @param hadc: ADC handle pointer | * @param hadc: ADC handle pointer | ||||||
| * @retval None | * @retval None | ||||||
| */ | */ | ||||||
| void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc) | void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc) { | ||||||
| { |     if(hadc->Instance == ADC1) { | ||||||
|   if(hadc->Instance==ADC1) |         /* USER CODE BEGIN ADC1_MspDeInit 0 */ | ||||||
|   { |  | ||||||
|   /* USER CODE BEGIN ADC1_MspDeInit 0 */ |  | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END ADC1_MspDeInit 0 */ |         /* USER CODE END ADC1_MspDeInit 0 */ | ||||||
|     /* Peripheral clock disable */ |         /* Peripheral clock disable */ | ||||||
|     __HAL_RCC_ADC_CLK_DISABLE(); |         __HAL_RCC_ADC_CLK_DISABLE(); | ||||||
|    | 
 | ||||||
|     /**ADC1 GPIO Configuration    
 |         /**ADC1 GPIO Configuration    
 | ||||||
|     PC3     ------> ADC1_IN4 |     PC3     ------> ADC1_IN4 | ||||||
|     PA0     ------> ADC1_IN5  |     PA0     ------> ADC1_IN5  | ||||||
|     */ |     */ | ||||||
|     HAL_GPIO_DeInit(BATT_V_GPIO_Port, BATT_V_Pin); |         HAL_GPIO_DeInit(BATT_V_GPIO_Port, BATT_V_Pin); | ||||||
| 
 | 
 | ||||||
|     HAL_GPIO_DeInit(IR_RX_GPIO_Port, IR_RX_Pin); |         HAL_GPIO_DeInit(IR_RX_GPIO_Port, IR_RX_Pin); | ||||||
| 
 | 
 | ||||||
|   /* USER CODE BEGIN ADC1_MspDeInit 1 */ |         /* USER CODE BEGIN ADC1_MspDeInit 1 */ | ||||||
| 
 |  | ||||||
|   /* USER CODE END ADC1_MspDeInit 1 */ |  | ||||||
|   } |  | ||||||
| 
 | 
 | ||||||
|  |         /* USER CODE END ADC1_MspDeInit 1 */ | ||||||
|  |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
| @ -158,29 +151,26 @@ void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc) | |||||||
| * @param hcomp: COMP handle pointer | * @param hcomp: COMP handle pointer | ||||||
| * @retval None | * @retval None | ||||||
| */ | */ | ||||||
| void HAL_COMP_MspInit(COMP_HandleTypeDef* hcomp) | void HAL_COMP_MspInit(COMP_HandleTypeDef* hcomp) { | ||||||
| { |     GPIO_InitTypeDef GPIO_InitStruct = {0}; | ||||||
|   GPIO_InitTypeDef GPIO_InitStruct = {0}; |     if(hcomp->Instance == COMP1) { | ||||||
|   if(hcomp->Instance==COMP1) |         /* USER CODE BEGIN COMP1_MspInit 0 */ | ||||||
|   { |  | ||||||
|   /* USER CODE BEGIN COMP1_MspInit 0 */ |  | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END COMP1_MspInit 0 */ |         /* USER CODE END COMP1_MspInit 0 */ | ||||||
|    | 
 | ||||||
|     __HAL_RCC_GPIOC_CLK_ENABLE(); |         __HAL_RCC_GPIOC_CLK_ENABLE(); | ||||||
|     /**COMP1 GPIO Configuration    
 |         /**COMP1 GPIO Configuration    
 | ||||||
|     PC5     ------> COMP1_INP  |     PC5     ------> COMP1_INP  | ||||||
|     */ |     */ | ||||||
|     GPIO_InitStruct.Pin = RFID_RF_IN_Pin; |         GPIO_InitStruct.Pin = RFID_RF_IN_Pin; | ||||||
|     GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; |         GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; | ||||||
|     GPIO_InitStruct.Pull = GPIO_NOPULL; |         GPIO_InitStruct.Pull = GPIO_NOPULL; | ||||||
|     HAL_GPIO_Init(RFID_RF_IN_GPIO_Port, &GPIO_InitStruct); |         HAL_GPIO_Init(RFID_RF_IN_GPIO_Port, &GPIO_InitStruct); | ||||||
| 
 | 
 | ||||||
|   /* USER CODE BEGIN COMP1_MspInit 1 */ |         /* USER CODE BEGIN COMP1_MspInit 1 */ | ||||||
| 
 |  | ||||||
|   /* USER CODE END COMP1_MspInit 1 */ |  | ||||||
|   } |  | ||||||
| 
 | 
 | ||||||
|  |         /* USER CODE END COMP1_MspInit 1 */ | ||||||
|  |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
| @ -189,24 +179,21 @@ void HAL_COMP_MspInit(COMP_HandleTypeDef* hcomp) | |||||||
| * @param hcomp: COMP handle pointer | * @param hcomp: COMP handle pointer | ||||||
| * @retval None | * @retval None | ||||||
| */ | */ | ||||||
| void HAL_COMP_MspDeInit(COMP_HandleTypeDef* hcomp) | void HAL_COMP_MspDeInit(COMP_HandleTypeDef* hcomp) { | ||||||
| { |     if(hcomp->Instance == COMP1) { | ||||||
|   if(hcomp->Instance==COMP1) |         /* USER CODE BEGIN COMP1_MspDeInit 0 */ | ||||||
|   { |  | ||||||
|   /* USER CODE BEGIN COMP1_MspDeInit 0 */ |  | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END COMP1_MspDeInit 0 */ |         /* USER CODE END COMP1_MspDeInit 0 */ | ||||||
|    | 
 | ||||||
|     /**COMP1 GPIO Configuration    
 |         /**COMP1 GPIO Configuration    
 | ||||||
|     PC5     ------> COMP1_INP  |     PC5     ------> COMP1_INP  | ||||||
|     */ |     */ | ||||||
|     HAL_GPIO_DeInit(RFID_RF_IN_GPIO_Port, RFID_RF_IN_Pin); |         HAL_GPIO_DeInit(RFID_RF_IN_GPIO_Port, RFID_RF_IN_Pin); | ||||||
| 
 | 
 | ||||||
|   /* USER CODE BEGIN COMP1_MspDeInit 1 */ |         /* USER CODE BEGIN COMP1_MspDeInit 1 */ | ||||||
| 
 |  | ||||||
|   /* USER CODE END COMP1_MspDeInit 1 */ |  | ||||||
|   } |  | ||||||
| 
 | 
 | ||||||
|  |         /* USER CODE END COMP1_MspDeInit 1 */ | ||||||
|  |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
| @ -215,31 +202,28 @@ void HAL_COMP_MspDeInit(COMP_HandleTypeDef* hcomp) | |||||||
| * @param hdac: DAC handle pointer | * @param hdac: DAC handle pointer | ||||||
| * @retval None | * @retval None | ||||||
| */ | */ | ||||||
| void HAL_DAC_MspInit(DAC_HandleTypeDef* hdac) | void HAL_DAC_MspInit(DAC_HandleTypeDef* hdac) { | ||||||
| { |     GPIO_InitTypeDef GPIO_InitStruct = {0}; | ||||||
|   GPIO_InitTypeDef GPIO_InitStruct = {0}; |     if(hdac->Instance == DAC1) { | ||||||
|   if(hdac->Instance==DAC1) |         /* USER CODE BEGIN DAC1_MspInit 0 */ | ||||||
|   { |  | ||||||
|   /* USER CODE BEGIN DAC1_MspInit 0 */ |  | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END DAC1_MspInit 0 */ |         /* USER CODE END DAC1_MspInit 0 */ | ||||||
|     /* Peripheral clock enable */ |         /* Peripheral clock enable */ | ||||||
|     __HAL_RCC_DAC1_CLK_ENABLE(); |         __HAL_RCC_DAC1_CLK_ENABLE(); | ||||||
|    | 
 | ||||||
|     __HAL_RCC_GPIOA_CLK_ENABLE(); |         __HAL_RCC_GPIOA_CLK_ENABLE(); | ||||||
|     /**DAC1 GPIO Configuration    
 |         /**DAC1 GPIO Configuration    
 | ||||||
|     PA4     ------> DAC1_OUT1  |     PA4     ------> DAC1_OUT1  | ||||||
|     */ |     */ | ||||||
|     GPIO_InitStruct.Pin = RFID_REF_Pin; |         GPIO_InitStruct.Pin = RFID_REF_Pin; | ||||||
|     GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; |         GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; | ||||||
|     GPIO_InitStruct.Pull = GPIO_NOPULL; |         GPIO_InitStruct.Pull = GPIO_NOPULL; | ||||||
|     HAL_GPIO_Init(RFID_REF_GPIO_Port, &GPIO_InitStruct); |         HAL_GPIO_Init(RFID_REF_GPIO_Port, &GPIO_InitStruct); | ||||||
| 
 | 
 | ||||||
|   /* USER CODE BEGIN DAC1_MspInit 1 */ |         /* USER CODE BEGIN DAC1_MspInit 1 */ | ||||||
| 
 |  | ||||||
|   /* USER CODE END DAC1_MspInit 1 */ |  | ||||||
|   } |  | ||||||
| 
 | 
 | ||||||
|  |         /* USER CODE END DAC1_MspInit 1 */ | ||||||
|  |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
| @ -248,26 +232,23 @@ void HAL_DAC_MspInit(DAC_HandleTypeDef* hdac) | |||||||
| * @param hdac: DAC handle pointer | * @param hdac: DAC handle pointer | ||||||
| * @retval None | * @retval None | ||||||
| */ | */ | ||||||
| void HAL_DAC_MspDeInit(DAC_HandleTypeDef* hdac) | void HAL_DAC_MspDeInit(DAC_HandleTypeDef* hdac) { | ||||||
| { |     if(hdac->Instance == DAC1) { | ||||||
|   if(hdac->Instance==DAC1) |         /* USER CODE BEGIN DAC1_MspDeInit 0 */ | ||||||
|   { |  | ||||||
|   /* USER CODE BEGIN DAC1_MspDeInit 0 */ |  | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END DAC1_MspDeInit 0 */ |         /* USER CODE END DAC1_MspDeInit 0 */ | ||||||
|     /* Peripheral clock disable */ |         /* Peripheral clock disable */ | ||||||
|     __HAL_RCC_DAC1_CLK_DISABLE(); |         __HAL_RCC_DAC1_CLK_DISABLE(); | ||||||
|    | 
 | ||||||
|     /**DAC1 GPIO Configuration    
 |         /**DAC1 GPIO Configuration    
 | ||||||
|     PA4     ------> DAC1_OUT1  |     PA4     ------> DAC1_OUT1  | ||||||
|     */ |     */ | ||||||
|     HAL_GPIO_DeInit(RFID_REF_GPIO_Port, RFID_REF_Pin); |         HAL_GPIO_DeInit(RFID_REF_GPIO_Port, RFID_REF_Pin); | ||||||
| 
 | 
 | ||||||
|   /* USER CODE BEGIN DAC1_MspDeInit 1 */ |         /* USER CODE BEGIN DAC1_MspDeInit 1 */ | ||||||
| 
 |  | ||||||
|   /* USER CODE END DAC1_MspDeInit 1 */ |  | ||||||
|   } |  | ||||||
| 
 | 
 | ||||||
|  |         /* USER CODE END DAC1_MspDeInit 1 */ | ||||||
|  |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
| @ -276,59 +257,54 @@ void HAL_DAC_MspDeInit(DAC_HandleTypeDef* hdac) | |||||||
| * @param hspi: SPI handle pointer | * @param hspi: SPI handle pointer | ||||||
| * @retval None | * @retval None | ||||||
| */ | */ | ||||||
| void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi) | void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi) { | ||||||
| { |     GPIO_InitTypeDef GPIO_InitStruct = {0}; | ||||||
|   GPIO_InitTypeDef GPIO_InitStruct = {0}; |     if(hspi->Instance == SPI1) { | ||||||
|   if(hspi->Instance==SPI1) |         /* USER CODE BEGIN SPI1_MspInit 0 */ | ||||||
|   { |  | ||||||
|   /* USER CODE BEGIN SPI1_MspInit 0 */ |  | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END SPI1_MspInit 0 */ |         /* USER CODE END SPI1_MspInit 0 */ | ||||||
|     /* Peripheral clock enable */ |         /* Peripheral clock enable */ | ||||||
|     __HAL_RCC_SPI1_CLK_ENABLE(); |         __HAL_RCC_SPI1_CLK_ENABLE(); | ||||||
|    | 
 | ||||||
|     __HAL_RCC_GPIOB_CLK_ENABLE(); |         __HAL_RCC_GPIOB_CLK_ENABLE(); | ||||||
|     /**SPI1 GPIO Configuration    
 |         /**SPI1 GPIO Configuration    
 | ||||||
|     PB3 (JTDO-TRACESWO)     ------> SPI1_SCK |     PB3 (JTDO-TRACESWO)     ------> SPI1_SCK | ||||||
|     PB5     ------> SPI1_MOSI  |     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.Mode = GPIO_MODE_AF_PP; | ||||||
|     GPIO_InitStruct.Pull = GPIO_NOPULL; |         GPIO_InitStruct.Pull = GPIO_NOPULL; | ||||||
|     GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; |         GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; | ||||||
|     GPIO_InitStruct.Alternate = GPIO_AF5_SPI1; |         GPIO_InitStruct.Alternate = GPIO_AF5_SPI1; | ||||||
|     HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); |         HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); | ||||||
| 
 | 
 | ||||||
|   /* USER CODE BEGIN SPI1_MspInit 1 */ |         /* USER CODE BEGIN SPI1_MspInit 1 */ | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END 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 BEGIN SPI3_MspInit 0 */ |  | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END SPI3_MspInit 0 */ |         /* USER CODE END SPI3_MspInit 0 */ | ||||||
|     /* Peripheral clock enable */ |         /* Peripheral clock enable */ | ||||||
|     __HAL_RCC_SPI3_CLK_ENABLE(); |         __HAL_RCC_SPI3_CLK_ENABLE(); | ||||||
|    | 
 | ||||||
|     __HAL_RCC_GPIOC_CLK_ENABLE(); |         __HAL_RCC_GPIOC_CLK_ENABLE(); | ||||||
|     /**SPI3 GPIO Configuration    
 |         /**SPI3 GPIO Configuration    
 | ||||||
|     PC10     ------> SPI3_SCK |     PC10     ------> SPI3_SCK | ||||||
|     PC11     ------> SPI3_MISO |     PC11     ------> SPI3_MISO | ||||||
|     PC12     ------> SPI3_MOSI  |     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.Mode = GPIO_MODE_AF_PP; | ||||||
|     GPIO_InitStruct.Pull = GPIO_NOPULL; |         GPIO_InitStruct.Pull = GPIO_NOPULL; | ||||||
|     GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; |         GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; | ||||||
|     GPIO_InitStruct.Alternate = GPIO_AF6_SPI3; |         GPIO_InitStruct.Alternate = GPIO_AF6_SPI3; | ||||||
|     HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); |         HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); | ||||||
| 
 | 
 | ||||||
|   /* USER CODE BEGIN SPI3_MspInit 1 */ |         /* USER CODE BEGIN SPI3_MspInit 1 */ | ||||||
| 
 |  | ||||||
|   /* USER CODE END SPI3_MspInit 1 */ |  | ||||||
|   } |  | ||||||
| 
 | 
 | ||||||
|  |         /* USER CODE END SPI3_MspInit 1 */ | ||||||
|  |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
| @ -337,46 +313,41 @@ void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi) | |||||||
| * @param hspi: SPI handle pointer | * @param hspi: SPI handle pointer | ||||||
| * @retval None | * @retval None | ||||||
| */ | */ | ||||||
| void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi) | void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi) { | ||||||
| { |     if(hspi->Instance == SPI1) { | ||||||
|   if(hspi->Instance==SPI1) |         /* USER CODE BEGIN SPI1_MspDeInit 0 */ | ||||||
|   { |  | ||||||
|   /* USER CODE BEGIN SPI1_MspDeInit 0 */ |  | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END SPI1_MspDeInit 0 */ |         /* USER CODE END SPI1_MspDeInit 0 */ | ||||||
|     /* Peripheral clock disable */ |         /* Peripheral clock disable */ | ||||||
|     __HAL_RCC_SPI1_CLK_DISABLE(); |         __HAL_RCC_SPI1_CLK_DISABLE(); | ||||||
|    | 
 | ||||||
|     /**SPI1 GPIO Configuration    
 |         /**SPI1 GPIO Configuration    
 | ||||||
|     PB3 (JTDO-TRACESWO)     ------> SPI1_SCK |     PB3 (JTDO-TRACESWO)     ------> SPI1_SCK | ||||||
|     PB5     ------> SPI1_MOSI  |     PB5     ------> SPI1_MOSI  | ||||||
|     */ |     */ | ||||||
|     HAL_GPIO_DeInit(GPIOB, GPIO_PIN_3|GPIO_PIN_5); |         HAL_GPIO_DeInit(GPIOB, GPIO_PIN_3 | GPIO_PIN_5); | ||||||
| 
 | 
 | ||||||
|   /* USER CODE BEGIN SPI1_MspDeInit 1 */ |         /* USER CODE BEGIN SPI1_MspDeInit 1 */ | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END SPI1_MspDeInit 1 */ |         /* USER CODE END SPI1_MspDeInit 1 */ | ||||||
|   } |     } else if(hspi->Instance == SPI3) { | ||||||
|   else if(hspi->Instance==SPI3) |         /* USER CODE BEGIN SPI3_MspDeInit 0 */ | ||||||
|   { |  | ||||||
|   /* USER CODE BEGIN SPI3_MspDeInit 0 */ |  | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END SPI3_MspDeInit 0 */ |         /* USER CODE END SPI3_MspDeInit 0 */ | ||||||
|     /* Peripheral clock disable */ |         /* Peripheral clock disable */ | ||||||
|     __HAL_RCC_SPI3_CLK_DISABLE(); |         __HAL_RCC_SPI3_CLK_DISABLE(); | ||||||
|    | 
 | ||||||
|     /**SPI3 GPIO Configuration    
 |         /**SPI3 GPIO Configuration    
 | ||||||
|     PC10     ------> SPI3_SCK |     PC10     ------> SPI3_SCK | ||||||
|     PC11     ------> SPI3_MISO |     PC11     ------> SPI3_MISO | ||||||
|     PC12     ------> SPI3_MOSI  |     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 BEGIN SPI3_MspDeInit 1 */ | ||||||
| 
 |  | ||||||
|   /* USER CODE END SPI3_MspDeInit 1 */ |  | ||||||
|   } |  | ||||||
| 
 | 
 | ||||||
|  |         /* USER CODE END SPI3_MspDeInit 1 */ | ||||||
|  |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
| @ -385,20 +356,17 @@ void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi) | |||||||
| * @param htim_pwm: TIM_PWM handle pointer | * @param htim_pwm: TIM_PWM handle pointer | ||||||
| * @retval None | * @retval None | ||||||
| */ | */ | ||||||
| void HAL_TIM_PWM_MspInit(TIM_HandleTypeDef* htim_pwm) | void HAL_TIM_PWM_MspInit(TIM_HandleTypeDef* htim_pwm) { | ||||||
| { |     if(htim_pwm->Instance == TIM5) { | ||||||
|   if(htim_pwm->Instance==TIM5) |         /* USER CODE BEGIN TIM5_MspInit 0 */ | ||||||
|   { |  | ||||||
|   /* USER CODE BEGIN TIM5_MspInit 0 */ |  | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END TIM5_MspInit 0 */ |         /* USER CODE END TIM5_MspInit 0 */ | ||||||
|     /* Peripheral clock enable */ |         /* Peripheral clock enable */ | ||||||
|     __HAL_RCC_TIM5_CLK_ENABLE(); |         __HAL_RCC_TIM5_CLK_ENABLE(); | ||||||
|   /* USER CODE BEGIN TIM5_MspInit 1 */ |         /* USER CODE BEGIN TIM5_MspInit 1 */ | ||||||
| 
 |  | ||||||
|   /* USER CODE END TIM5_MspInit 1 */ |  | ||||||
|   } |  | ||||||
| 
 | 
 | ||||||
|  |         /* USER CODE END TIM5_MspInit 1 */ | ||||||
|  |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
| @ -407,36 +375,33 @@ void HAL_TIM_PWM_MspInit(TIM_HandleTypeDef* htim_pwm) | |||||||
| * @param htim_base: TIM_Base handle pointer | * @param htim_base: TIM_Base handle pointer | ||||||
| * @retval None | * @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}; | ||||||
|   GPIO_InitTypeDef GPIO_InitStruct = {0}; |     if(htim_base->Instance == TIM8) { | ||||||
|   if(htim_base->Instance==TIM8) |         /* USER CODE BEGIN TIM8_MspInit 0 */ | ||||||
|   { |  | ||||||
|   /* USER CODE BEGIN TIM8_MspInit 0 */ |  | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END TIM8_MspInit 0 */ |         /* USER CODE END TIM8_MspInit 0 */ | ||||||
|     /* Peripheral clock enable */ |         /* Peripheral clock enable */ | ||||||
|     __HAL_RCC_TIM8_CLK_ENABLE(); |         __HAL_RCC_TIM8_CLK_ENABLE(); | ||||||
|    | 
 | ||||||
|     __HAL_RCC_GPIOC_CLK_ENABLE(); |         __HAL_RCC_GPIOC_CLK_ENABLE(); | ||||||
|     /**TIM8 GPIO Configuration    
 |         /**TIM8 GPIO Configuration    
 | ||||||
|     PC7     ------> TIM8_CH2  |     PC7     ------> TIM8_CH2  | ||||||
|     */ |     */ | ||||||
|     GPIO_InitStruct.Pin = iButton_Pin; |         GPIO_InitStruct.Pin = iButton_Pin; | ||||||
|     GPIO_InitStruct.Mode = GPIO_MODE_AF_OD; |         GPIO_InitStruct.Mode = GPIO_MODE_AF_OD; | ||||||
|     GPIO_InitStruct.Pull = GPIO_NOPULL; |         GPIO_InitStruct.Pull = GPIO_NOPULL; | ||||||
|     GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM; |         GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM; | ||||||
|     GPIO_InitStruct.Alternate = GPIO_AF3_TIM8; |         GPIO_InitStruct.Alternate = GPIO_AF3_TIM8; | ||||||
|     HAL_GPIO_Init(iButton_GPIO_Port, &GPIO_InitStruct); |         HAL_GPIO_Init(iButton_GPIO_Port, &GPIO_InitStruct); | ||||||
| 
 | 
 | ||||||
|     /* TIM8 interrupt Init */ |         /* TIM8 interrupt Init */ | ||||||
|     HAL_NVIC_SetPriority(TIM8_CC_IRQn, 5, 0); |         HAL_NVIC_SetPriority(TIM8_CC_IRQn, 5, 0); | ||||||
|     HAL_NVIC_EnableIRQ(TIM8_CC_IRQn); |         HAL_NVIC_EnableIRQ(TIM8_CC_IRQn); | ||||||
|   /* USER CODE BEGIN TIM8_MspInit 1 */ |         /* USER CODE BEGIN TIM8_MspInit 1 */ | ||||||
| 
 |  | ||||||
|   /* USER CODE END TIM8_MspInit 1 */ |  | ||||||
|   } |  | ||||||
| 
 | 
 | ||||||
|  |         /* USER CODE END TIM8_MspInit 1 */ | ||||||
|  |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
| @ -445,68 +410,60 @@ void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base) | |||||||
| * @param htim_oc: TIM_OC handle pointer | * @param htim_oc: TIM_OC handle pointer | ||||||
| * @retval None | * @retval None | ||||||
| */ | */ | ||||||
| void HAL_TIM_OC_MspInit(TIM_HandleTypeDef* htim_oc) | void HAL_TIM_OC_MspInit(TIM_HandleTypeDef* htim_oc) { | ||||||
| { |     if(htim_oc->Instance == TIM15) { | ||||||
|   if(htim_oc->Instance==TIM15) |         /* USER CODE BEGIN TIM15_MspInit 0 */ | ||||||
|   { |  | ||||||
|   /* USER CODE BEGIN TIM15_MspInit 0 */ |  | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END TIM15_MspInit 0 */ |         /* USER CODE END TIM15_MspInit 0 */ | ||||||
|     /* Peripheral clock enable */ |         /* Peripheral clock enable */ | ||||||
|     __HAL_RCC_TIM15_CLK_ENABLE(); |         __HAL_RCC_TIM15_CLK_ENABLE(); | ||||||
|   /* USER CODE BEGIN TIM15_MspInit 1 */ |         /* USER CODE BEGIN TIM15_MspInit 1 */ | ||||||
| 
 |  | ||||||
|   /* USER CODE END TIM15_MspInit 1 */ |  | ||||||
|   } |  | ||||||
| 
 | 
 | ||||||
|  |         /* 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}; | ||||||
|   GPIO_InitTypeDef GPIO_InitStruct = {0}; |     if(htim->Instance == TIM5) { | ||||||
|   if(htim->Instance==TIM5) |         /* USER CODE BEGIN TIM5_MspPostInit 0 */ | ||||||
|   { |  | ||||||
|   /* USER CODE BEGIN TIM5_MspPostInit 0 */ |  | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END TIM5_MspPostInit 0 */ |         /* USER CODE END TIM5_MspPostInit 0 */ | ||||||
|     __HAL_RCC_GPIOA_CLK_ENABLE(); |         __HAL_RCC_GPIOA_CLK_ENABLE(); | ||||||
|     /**TIM5 GPIO Configuration    
 |         /**TIM5 GPIO Configuration    
 | ||||||
|     PA3     ------> TIM5_CH4  |     PA3     ------> TIM5_CH4  | ||||||
|     */ |     */ | ||||||
|     GPIO_InitStruct.Pin = SPEAKER_Pin; |         GPIO_InitStruct.Pin = SPEAKER_Pin; | ||||||
|     GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; |         GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; | ||||||
|     GPIO_InitStruct.Pull = GPIO_NOPULL; |         GPIO_InitStruct.Pull = GPIO_NOPULL; | ||||||
|     GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |         GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; | ||||||
|     GPIO_InitStruct.Alternate = GPIO_AF2_TIM5; |         GPIO_InitStruct.Alternate = GPIO_AF2_TIM5; | ||||||
|     HAL_GPIO_Init(SPEAKER_GPIO_Port, &GPIO_InitStruct); |         HAL_GPIO_Init(SPEAKER_GPIO_Port, &GPIO_InitStruct); | ||||||
| 
 | 
 | ||||||
|   /* USER CODE BEGIN TIM5_MspPostInit 1 */ |         /* USER CODE BEGIN TIM5_MspPostInit 1 */ | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END TIM5_MspPostInit 1 */ |         /* USER CODE END TIM5_MspPostInit 1 */ | ||||||
|   } |     } else if(htim->Instance == TIM15) { | ||||||
|   else if(htim->Instance==TIM15) |         /* USER CODE BEGIN TIM15_MspPostInit 0 */ | ||||||
|   { |  | ||||||
|   /* USER CODE BEGIN TIM15_MspPostInit 0 */ |  | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END TIM15_MspPostInit 0 */ |         /* USER CODE END TIM15_MspPostInit 0 */ | ||||||
|    | 
 | ||||||
|     __HAL_RCC_GPIOB_CLK_ENABLE(); |         __HAL_RCC_GPIOB_CLK_ENABLE(); | ||||||
|     /**TIM15 GPIO Configuration    
 |         /**TIM15 GPIO Configuration    
 | ||||||
|     PB13     ------> TIM15_CH1N |     PB13     ------> TIM15_CH1N | ||||||
|     PB15     ------> TIM15_CH2  |     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.Mode = GPIO_MODE_AF_PP; | ||||||
|     GPIO_InitStruct.Pull = GPIO_NOPULL; |         GPIO_InitStruct.Pull = GPIO_NOPULL; | ||||||
|     GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |         GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; | ||||||
|     GPIO_InitStruct.Alternate = GPIO_AF14_TIM15; |         GPIO_InitStruct.Alternate = GPIO_AF14_TIM15; | ||||||
|     HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); |         HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); | ||||||
| 
 | 
 | ||||||
|   /* USER CODE BEGIN TIM15_MspPostInit 1 */ |         /* USER CODE BEGIN TIM15_MspPostInit 1 */ | ||||||
| 
 |  | ||||||
|   /* USER CODE END TIM15_MspPostInit 1 */ |  | ||||||
|   } |  | ||||||
| 
 | 
 | ||||||
|  |         /* USER CODE END TIM15_MspPostInit 1 */ | ||||||
|  |     } | ||||||
| } | } | ||||||
| /**
 | /**
 | ||||||
| * @brief TIM_PWM MSP De-Initialization | * @brief TIM_PWM MSP De-Initialization | ||||||
| @ -514,20 +471,17 @@ void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim) | |||||||
| * @param htim_pwm: TIM_PWM handle pointer | * @param htim_pwm: TIM_PWM handle pointer | ||||||
| * @retval None | * @retval None | ||||||
| */ | */ | ||||||
| void HAL_TIM_PWM_MspDeInit(TIM_HandleTypeDef* htim_pwm) | void HAL_TIM_PWM_MspDeInit(TIM_HandleTypeDef* htim_pwm) { | ||||||
| { |     if(htim_pwm->Instance == TIM5) { | ||||||
|   if(htim_pwm->Instance==TIM5) |         /* USER CODE BEGIN TIM5_MspDeInit 0 */ | ||||||
|   { |  | ||||||
|   /* USER CODE BEGIN TIM5_MspDeInit 0 */ |  | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END TIM5_MspDeInit 0 */ |         /* USER CODE END TIM5_MspDeInit 0 */ | ||||||
|     /* Peripheral clock disable */ |         /* Peripheral clock disable */ | ||||||
|     __HAL_RCC_TIM5_CLK_DISABLE(); |         __HAL_RCC_TIM5_CLK_DISABLE(); | ||||||
|   /* USER CODE BEGIN TIM5_MspDeInit 1 */ |         /* USER CODE BEGIN TIM5_MspDeInit 1 */ | ||||||
| 
 |  | ||||||
|   /* USER CODE END TIM5_MspDeInit 1 */ |  | ||||||
|   } |  | ||||||
| 
 | 
 | ||||||
|  |         /* USER CODE END TIM5_MspDeInit 1 */ | ||||||
|  |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
| @ -536,28 +490,25 @@ void HAL_TIM_PWM_MspDeInit(TIM_HandleTypeDef* htim_pwm) | |||||||
| * @param htim_base: TIM_Base handle pointer | * @param htim_base: TIM_Base handle pointer | ||||||
| * @retval None | * @retval None | ||||||
| */ | */ | ||||||
| void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* htim_base) | void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* htim_base) { | ||||||
| { |     if(htim_base->Instance == TIM8) { | ||||||
|   if(htim_base->Instance==TIM8) |         /* USER CODE BEGIN TIM8_MspDeInit 0 */ | ||||||
|   { |  | ||||||
|   /* USER CODE BEGIN TIM8_MspDeInit 0 */ |  | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END TIM8_MspDeInit 0 */ |         /* USER CODE END TIM8_MspDeInit 0 */ | ||||||
|     /* Peripheral clock disable */ |         /* Peripheral clock disable */ | ||||||
|     __HAL_RCC_TIM8_CLK_DISABLE(); |         __HAL_RCC_TIM8_CLK_DISABLE(); | ||||||
|    | 
 | ||||||
|     /**TIM8 GPIO Configuration    
 |         /**TIM8 GPIO Configuration    
 | ||||||
|     PC7     ------> TIM8_CH2  |     PC7     ------> TIM8_CH2  | ||||||
|     */ |     */ | ||||||
|     HAL_GPIO_DeInit(iButton_GPIO_Port, iButton_Pin); |         HAL_GPIO_DeInit(iButton_GPIO_Port, iButton_Pin); | ||||||
| 
 | 
 | ||||||
|     /* TIM8 interrupt DeInit */ |         /* TIM8 interrupt DeInit */ | ||||||
|     HAL_NVIC_DisableIRQ(TIM8_CC_IRQn); |         HAL_NVIC_DisableIRQ(TIM8_CC_IRQn); | ||||||
|   /* USER CODE BEGIN TIM8_MspDeInit 1 */ |         /* USER CODE BEGIN TIM8_MspDeInit 1 */ | ||||||
| 
 |  | ||||||
|   /* USER CODE END TIM8_MspDeInit 1 */ |  | ||||||
|   } |  | ||||||
| 
 | 
 | ||||||
|  |         /* USER CODE END TIM8_MspDeInit 1 */ | ||||||
|  |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
| @ -566,20 +517,17 @@ void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* htim_base) | |||||||
| * @param htim_oc: TIM_OC handle pointer | * @param htim_oc: TIM_OC handle pointer | ||||||
| * @retval None | * @retval None | ||||||
| */ | */ | ||||||
| void HAL_TIM_OC_MspDeInit(TIM_HandleTypeDef* htim_oc) | void HAL_TIM_OC_MspDeInit(TIM_HandleTypeDef* htim_oc) { | ||||||
| { |     if(htim_oc->Instance == TIM15) { | ||||||
|   if(htim_oc->Instance==TIM15) |         /* USER CODE BEGIN TIM15_MspDeInit 0 */ | ||||||
|   { |  | ||||||
|   /* USER CODE BEGIN TIM15_MspDeInit 0 */ |  | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END TIM15_MspDeInit 0 */ |         /* USER CODE END TIM15_MspDeInit 0 */ | ||||||
|     /* Peripheral clock disable */ |         /* Peripheral clock disable */ | ||||||
|     __HAL_RCC_TIM15_CLK_DISABLE(); |         __HAL_RCC_TIM15_CLK_DISABLE(); | ||||||
|   /* USER CODE BEGIN TIM15_MspDeInit 1 */ |         /* USER CODE BEGIN TIM15_MspDeInit 1 */ | ||||||
| 
 |  | ||||||
|   /* USER CODE END TIM15_MspDeInit 1 */ |  | ||||||
|   } |  | ||||||
| 
 | 
 | ||||||
|  |         /* USER CODE END TIM15_MspDeInit 1 */ | ||||||
|  |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
| @ -588,34 +536,31 @@ void HAL_TIM_OC_MspDeInit(TIM_HandleTypeDef* htim_oc) | |||||||
| * @param huart: UART handle pointer | * @param huart: UART handle pointer | ||||||
| * @retval None | * @retval None | ||||||
| */ | */ | ||||||
| void HAL_UART_MspInit(UART_HandleTypeDef* huart) | void HAL_UART_MspInit(UART_HandleTypeDef* huart) { | ||||||
| { |     GPIO_InitTypeDef GPIO_InitStruct = {0}; | ||||||
|   GPIO_InitTypeDef GPIO_InitStruct = {0}; |     if(huart->Instance == USART1) { | ||||||
|   if(huart->Instance==USART1) |         /* USER CODE BEGIN USART1_MspInit 0 */ | ||||||
|   { |  | ||||||
|   /* USER CODE BEGIN USART1_MspInit 0 */ |  | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END USART1_MspInit 0 */ |         /* USER CODE END USART1_MspInit 0 */ | ||||||
|     /* Peripheral clock enable */ |         /* Peripheral clock enable */ | ||||||
|     __HAL_RCC_USART1_CLK_ENABLE(); |         __HAL_RCC_USART1_CLK_ENABLE(); | ||||||
|    | 
 | ||||||
|     __HAL_RCC_GPIOA_CLK_ENABLE(); |         __HAL_RCC_GPIOA_CLK_ENABLE(); | ||||||
|     /**USART1 GPIO Configuration    
 |         /**USART1 GPIO Configuration    
 | ||||||
|     PA9     ------> USART1_TX |     PA9     ------> USART1_TX | ||||||
|     PA10     ------> USART1_RX  |     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.Mode = GPIO_MODE_AF_PP; | ||||||
|     GPIO_InitStruct.Pull = GPIO_NOPULL; |         GPIO_InitStruct.Pull = GPIO_NOPULL; | ||||||
|     GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; |         GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; | ||||||
|     GPIO_InitStruct.Alternate = GPIO_AF7_USART1; |         GPIO_InitStruct.Alternate = GPIO_AF7_USART1; | ||||||
|     HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); |         HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); | ||||||
| 
 | 
 | ||||||
|   /* USER CODE BEGIN USART1_MspInit 1 */ |         /* USER CODE BEGIN USART1_MspInit 1 */ | ||||||
| 
 |  | ||||||
|   /* USER CODE END USART1_MspInit 1 */ |  | ||||||
|   } |  | ||||||
| 
 | 
 | ||||||
|  |         /* USER CODE END USART1_MspInit 1 */ | ||||||
|  |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
| @ -624,27 +569,24 @@ void HAL_UART_MspInit(UART_HandleTypeDef* huart) | |||||||
| * @param huart: UART handle pointer | * @param huart: UART handle pointer | ||||||
| * @retval None | * @retval None | ||||||
| */ | */ | ||||||
| void HAL_UART_MspDeInit(UART_HandleTypeDef* huart) | void HAL_UART_MspDeInit(UART_HandleTypeDef* huart) { | ||||||
| { |     if(huart->Instance == USART1) { | ||||||
|   if(huart->Instance==USART1) |         /* USER CODE BEGIN USART1_MspDeInit 0 */ | ||||||
|   { |  | ||||||
|   /* USER CODE BEGIN USART1_MspDeInit 0 */ |  | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END USART1_MspDeInit 0 */ |         /* USER CODE END USART1_MspDeInit 0 */ | ||||||
|     /* Peripheral clock disable */ |         /* Peripheral clock disable */ | ||||||
|     __HAL_RCC_USART1_CLK_DISABLE(); |         __HAL_RCC_USART1_CLK_DISABLE(); | ||||||
|    | 
 | ||||||
|     /**USART1 GPIO Configuration    
 |         /**USART1 GPIO Configuration    
 | ||||||
|     PA9     ------> USART1_TX |     PA9     ------> USART1_TX | ||||||
|     PA10     ------> USART1_RX  |     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 BEGIN USART1_MspDeInit 1 */ | ||||||
| 
 |  | ||||||
|   /* USER CODE END USART1_MspDeInit 1 */ |  | ||||||
|   } |  | ||||||
| 
 | 
 | ||||||
|  |         /* USER CODE END USART1_MspDeInit 1 */ | ||||||
|  |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /* USER CODE BEGIN 1 */ | /* USER CODE BEGIN 1 */ | ||||||
|  | |||||||
| @ -34,7 +34,7 @@ | |||||||
| 
 | 
 | ||||||
| /* Private define ------------------------------------------------------------*/ | /* Private define ------------------------------------------------------------*/ | ||||||
| /* USER CODE BEGIN PD */ | /* USER CODE BEGIN PD */ | ||||||
|   | 
 | ||||||
| /* USER CODE END PD */ | /* USER CODE END PD */ | ||||||
| 
 | 
 | ||||||
| /* Private macro -------------------------------------------------------------*/ | /* Private macro -------------------------------------------------------------*/ | ||||||
| @ -65,114 +65,102 @@ extern TIM_HandleTypeDef htim8; | |||||||
| /* USER CODE END EV */ | /* USER CODE END EV */ | ||||||
| 
 | 
 | ||||||
| /******************************************************************************/ | /******************************************************************************/ | ||||||
| /*           Cortex-M4 Processor Interruption and Exception Handlers          */  | /*           Cortex-M4 Processor Interruption and Exception Handlers          */ | ||||||
| /******************************************************************************/ | /******************************************************************************/ | ||||||
| /**
 | /**
 | ||||||
|   * @brief This function handles Non maskable interrupt. |   * @brief This function handles Non maskable interrupt. | ||||||
|   */ |   */ | ||||||
| void NMI_Handler(void) | void NMI_Handler(void) { | ||||||
| { |     /* USER CODE BEGIN NonMaskableInt_IRQn 0 */ | ||||||
|   /* USER CODE BEGIN NonMaskableInt_IRQn 0 */ |  | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END NonMaskableInt_IRQn 0 */ |     /* USER CODE END NonMaskableInt_IRQn 0 */ | ||||||
|   /* USER CODE BEGIN NonMaskableInt_IRQn 1 */ |     /* USER CODE BEGIN NonMaskableInt_IRQn 1 */ | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END NonMaskableInt_IRQn 1 */ |     /* USER CODE END NonMaskableInt_IRQn 1 */ | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
|   * @brief This function handles Hard fault interrupt. |   * @brief This function handles Hard fault interrupt. | ||||||
|   */ |   */ | ||||||
| void HardFault_Handler(void) | void HardFault_Handler(void) { | ||||||
| { |     /* USER CODE BEGIN HardFault_IRQn 0 */ | ||||||
|   /* USER CODE BEGIN HardFault_IRQn 0 */ |  | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END HardFault_IRQn 0 */ |     /* USER CODE END HardFault_IRQn 0 */ | ||||||
|   while (1) |     while(1) { | ||||||
|   { |         /* USER CODE BEGIN W1_HardFault_IRQn 0 */ | ||||||
|     /* USER CODE BEGIN W1_HardFault_IRQn 0 */ |         /* USER CODE END W1_HardFault_IRQn 0 */ | ||||||
|     /* USER CODE END W1_HardFault_IRQn 0 */ |     } | ||||||
|   } |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
|   * @brief This function handles Memory management fault. |   * @brief This function handles Memory management fault. | ||||||
|   */ |   */ | ||||||
| void MemManage_Handler(void) | void MemManage_Handler(void) { | ||||||
| { |     /* USER CODE BEGIN MemoryManagement_IRQn 0 */ | ||||||
|   /* USER CODE BEGIN MemoryManagement_IRQn 0 */ |  | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END MemoryManagement_IRQn 0 */ |     /* USER CODE END MemoryManagement_IRQn 0 */ | ||||||
|   while (1) |     while(1) { | ||||||
|   { |         /* USER CODE BEGIN W1_MemoryManagement_IRQn 0 */ | ||||||
|     /* USER CODE BEGIN W1_MemoryManagement_IRQn 0 */ |         /* USER CODE END W1_MemoryManagement_IRQn 0 */ | ||||||
|     /* USER CODE END W1_MemoryManagement_IRQn 0 */ |     } | ||||||
|   } |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
|   * @brief This function handles Prefetch fault, memory access fault. |   * @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 BEGIN BusFault_IRQn 0 */ |  | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END BusFault_IRQn 0 */ |     /* USER CODE END BusFault_IRQn 0 */ | ||||||
|   while (1) |     while(1) { | ||||||
|   { |         /* USER CODE BEGIN W1_BusFault_IRQn 0 */ | ||||||
|     /* USER CODE BEGIN W1_BusFault_IRQn 0 */ |         /* USER CODE END W1_BusFault_IRQn 0 */ | ||||||
|     /* USER CODE END W1_BusFault_IRQn 0 */ |     } | ||||||
|   } |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
|   * @brief This function handles Undefined instruction or illegal state. |   * @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 BEGIN UsageFault_IRQn 0 */ |  | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END UsageFault_IRQn 0 */ |     /* USER CODE END UsageFault_IRQn 0 */ | ||||||
|   while (1) |     while(1) { | ||||||
|   { |         /* USER CODE BEGIN W1_UsageFault_IRQn 0 */ | ||||||
|     /* USER CODE BEGIN W1_UsageFault_IRQn 0 */ |         /* USER CODE END W1_UsageFault_IRQn 0 */ | ||||||
|     /* USER CODE END W1_UsageFault_IRQn 0 */ |     } | ||||||
|   } |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
|   * @brief This function handles Debug monitor. |   * @brief This function handles Debug monitor. | ||||||
|   */ |   */ | ||||||
| void DebugMon_Handler(void) | void DebugMon_Handler(void) { | ||||||
| { |     /* USER CODE BEGIN DebugMonitor_IRQn 0 */ | ||||||
|   /* USER CODE BEGIN DebugMonitor_IRQn 0 */ |  | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END DebugMonitor_IRQn 0 */ |     /* USER CODE END DebugMonitor_IRQn 0 */ | ||||||
|   /* USER CODE BEGIN DebugMonitor_IRQn 1 */ |     /* USER CODE BEGIN DebugMonitor_IRQn 1 */ | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END DebugMonitor_IRQn 1 */ |     /* USER CODE END DebugMonitor_IRQn 1 */ | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
|   * @brief This function handles System tick timer. |   * @brief This function handles System tick timer. | ||||||
|   */ |   */ | ||||||
| void SysTick_Handler(void) | void SysTick_Handler(void) { | ||||||
| { |     /* USER CODE BEGIN SysTick_IRQn 0 */ | ||||||
|   /* USER CODE BEGIN SysTick_IRQn 0 */ |  | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END SysTick_IRQn 0 */ |     /* USER CODE END SysTick_IRQn 0 */ | ||||||
|   HAL_IncTick(); |     HAL_IncTick(); | ||||||
| #if (INCLUDE_xTaskGetSchedulerState == 1 ) | #if(INCLUDE_xTaskGetSchedulerState == 1) | ||||||
|   if (xTaskGetSchedulerState() != taskSCHEDULER_NOT_STARTED) |     if(xTaskGetSchedulerState() != taskSCHEDULER_NOT_STARTED) { | ||||||
|   { |  | ||||||
| #endif /* INCLUDE_xTaskGetSchedulerState */ | #endif /* INCLUDE_xTaskGetSchedulerState */ | ||||||
|   xPortSysTickHandler(); |         xPortSysTickHandler(); | ||||||
| #if (INCLUDE_xTaskGetSchedulerState == 1 ) | #if(INCLUDE_xTaskGetSchedulerState == 1) | ||||||
|   } |     } | ||||||
| #endif /* INCLUDE_xTaskGetSchedulerState */ | #endif /* INCLUDE_xTaskGetSchedulerState */ | ||||||
|   /* USER CODE BEGIN SysTick_IRQn 1 */ |     /* USER CODE BEGIN SysTick_IRQn 1 */ | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END SysTick_IRQn 1 */ |     /* USER CODE END SysTick_IRQn 1 */ | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /******************************************************************************/ | /******************************************************************************/ | ||||||
| @ -185,115 +173,105 @@ void SysTick_Handler(void) | |||||||
| /**
 | /**
 | ||||||
|   * @brief This function handles EXTI line0 interrupt. |   * @brief This function handles EXTI line0 interrupt. | ||||||
|   */ |   */ | ||||||
| void EXTI0_IRQHandler(void) | void EXTI0_IRQHandler(void) { | ||||||
| { |     /* USER CODE BEGIN EXTI0_IRQn 0 */ | ||||||
|   /* USER CODE BEGIN EXTI0_IRQn 0 */ |  | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END EXTI0_IRQn 0 */ |     /* USER CODE END EXTI0_IRQn 0 */ | ||||||
|   HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_0); |     HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_0); | ||||||
|   /* USER CODE BEGIN EXTI0_IRQn 1 */ |     /* USER CODE BEGIN EXTI0_IRQn 1 */ | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END EXTI0_IRQn 1 */ |     /* USER CODE END EXTI0_IRQn 1 */ | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
|   * @brief This function handles EXTI line1 interrupt. |   * @brief This function handles EXTI line1 interrupt. | ||||||
|   */ |   */ | ||||||
| void EXTI1_IRQHandler(void) | void EXTI1_IRQHandler(void) { | ||||||
| { |     /* USER CODE BEGIN EXTI1_IRQn 0 */ | ||||||
|   /* USER CODE BEGIN EXTI1_IRQn 0 */ |  | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END EXTI1_IRQn 0 */ |     /* USER CODE END EXTI1_IRQn 0 */ | ||||||
|   HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_1); |     HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_1); | ||||||
|   /* USER CODE BEGIN EXTI1_IRQn 1 */ |     /* USER CODE BEGIN EXTI1_IRQn 1 */ | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END EXTI1_IRQn 1 */ |     /* USER CODE END EXTI1_IRQn 1 */ | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
|   * @brief This function handles EXTI line2 interrupt. |   * @brief This function handles EXTI line2 interrupt. | ||||||
|   */ |   */ | ||||||
| void EXTI2_IRQHandler(void) | void EXTI2_IRQHandler(void) { | ||||||
| { |     /* USER CODE BEGIN EXTI2_IRQn 0 */ | ||||||
|   /* USER CODE BEGIN EXTI2_IRQn 0 */ |  | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END EXTI2_IRQn 0 */ |     /* USER CODE END EXTI2_IRQn 0 */ | ||||||
|   HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_2); |     HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_2); | ||||||
|   /* USER CODE BEGIN EXTI2_IRQn 1 */ |     /* USER CODE BEGIN EXTI2_IRQn 1 */ | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END EXTI2_IRQn 1 */ |     /* USER CODE END EXTI2_IRQn 1 */ | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
|   * @brief This function handles EXTI line4 interrupt. |   * @brief This function handles EXTI line4 interrupt. | ||||||
|   */ |   */ | ||||||
| void EXTI4_IRQHandler(void) | void EXTI4_IRQHandler(void) { | ||||||
| { |     /* USER CODE BEGIN EXTI4_IRQn 0 */ | ||||||
|   /* USER CODE BEGIN EXTI4_IRQn 0 */ |  | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END EXTI4_IRQn 0 */ |     /* USER CODE END EXTI4_IRQn 0 */ | ||||||
|   HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_4); |     HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_4); | ||||||
|   /* USER CODE BEGIN EXTI4_IRQn 1 */ |     /* USER CODE BEGIN EXTI4_IRQn 1 */ | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END EXTI4_IRQn 1 */ |     /* USER CODE END EXTI4_IRQn 1 */ | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
|   * @brief This function handles EXTI line[9:5] interrupts. |   * @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 BEGIN EXTI9_5_IRQn 0 */ |  | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END EXTI9_5_IRQn 0 */ |     /* USER CODE END EXTI9_5_IRQn 0 */ | ||||||
|   HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_6); |     HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_6); | ||||||
|   HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_8); |     HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_8); | ||||||
|   HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_9); |     HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_9); | ||||||
|   /* USER CODE BEGIN EXTI9_5_IRQn 1 */ |     /* USER CODE BEGIN EXTI9_5_IRQn 1 */ | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END EXTI9_5_IRQn 1 */ |     /* USER CODE END EXTI9_5_IRQn 1 */ | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void(*tim8_callback_ch2)(uint16_t ccr, TimerEvent tim_event); | void (*tim8_callback_ch2)(uint16_t ccr, TimerEvent tim_event); | ||||||
| 
 | 
 | ||||||
| void register_tim8_callback_ch2(void(*callback)(uint16_t ccr, TimerEvent tim_event)) { | void register_tim8_callback_ch2(void (*callback)(uint16_t ccr, TimerEvent tim_event)) { | ||||||
|   tim8_callback_ch2 = callback; |     tim8_callback_ch2 = callback; | ||||||
| } | } | ||||||
| /**
 | /**
 | ||||||
|   * @brief This function handles TIM8 capture compare interrupt. |   * @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 */ | ||||||
|   /* USER CODE BEGIN TIM8_CC_IRQn 0 */ |  | ||||||
| 
 | 
 | ||||||
|   /* Capture compare 2 event */ |     /* Capture compare 2 event */ | ||||||
|   if (__HAL_TIM_GET_FLAG(&htim8, TIM_FLAG_CC2) != RESET) |     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_IT_SOURCE(&htim8, TIM_IT_CC2) != RESET) |             __HAL_TIM_CLEAR_IT(&htim8, TIM_IT_CC2); | ||||||
|     { |             htim8.Channel = HAL_TIM_ACTIVE_CHANNEL_2; | ||||||
|       __HAL_TIM_CLEAR_IT(&htim8, TIM_IT_CC2); |             /* Input capture event */ | ||||||
|       htim8.Channel = HAL_TIM_ACTIVE_CHANNEL_2; |             if((htim8.Instance->CCMR1 & TIM_CCMR1_CC2S) != 0x00U) { | ||||||
|       /* Input capture event */ |                 /*
 | ||||||
|       if ((htim8.Instance->CCMR1 & TIM_CCMR1_CC2S) != 0x00U) |  | ||||||
|       { |  | ||||||
| /*
 |  | ||||||
| #if (USE_HAL_TIM_REGISTER_CALLBACKS == 1) | #if (USE_HAL_TIM_REGISTER_CALLBACKS == 1) | ||||||
|         htim->IC_CaptureCallback(htim); |         htim->IC_CaptureCallback(htim); | ||||||
| #else | #else | ||||||
|         HAL_TIM_IC_CaptureCallback(htim); |         HAL_TIM_IC_CaptureCallback(htim); | ||||||
| #endif | #endif | ||||||
| */ | */ | ||||||
|         if(tim8_callback_ch2 != NULL) { |                 if(tim8_callback_ch2 != NULL) { | ||||||
|           tim8_callback_ch2(htim8.Instance->CCR2, TimerEventInputCapture); |                     tim8_callback_ch2(htim8.Instance->CCR2, TimerEventInputCapture); | ||||||
|         } |                 } | ||||||
|       } |             } | ||||||
|       /* Output compare event */ |             /* Output compare event */ | ||||||
|       else |             else { | ||||||
|       { |                 if(tim8_callback_ch2 != NULL) { | ||||||
|         if(tim8_callback_ch2 != NULL) { |                     tim8_callback_ch2(0, TimerEventEndOfPulse); | ||||||
|           tim8_callback_ch2(0, TimerEventEndOfPulse); |                 } | ||||||
|         } |                 /*
 | ||||||
| /*
 |  | ||||||
| #if (USE_HAL_TIM_REGISTER_CALLBACKS == 1) | #if (USE_HAL_TIM_REGISTER_CALLBACKS == 1) | ||||||
|         htim->OC_DelayElapsedCallback(htim); |         htim->OC_DelayElapsedCallback(htim); | ||||||
|         htim->PWM_PulseFinishedCallback(htim); |         htim->PWM_PulseFinishedCallback(htim); | ||||||
| @ -302,31 +280,29 @@ void TIM8_CC_IRQHandler(void) | |||||||
|         HAL_TIM_PWM_PulseFinishedCallback(htim); |         HAL_TIM_PWM_PulseFinishedCallback(htim); | ||||||
| #endif | #endif | ||||||
| */ | */ | ||||||
|       } |             } | ||||||
|       htim8.Channel = HAL_TIM_ACTIVE_CHANNEL_CLEARED; |             htim8.Channel = HAL_TIM_ACTIVE_CHANNEL_CLEARED; | ||||||
|  |         } | ||||||
|     } |     } | ||||||
|   } |  | ||||||
| 
 | 
 | ||||||
|  |     /* USER CODE END TIM8_CC_IRQn 0 */ | ||||||
|  |     // HAL_TIM_IRQHandler(&htim8);
 | ||||||
|  |     /* USER CODE BEGIN TIM8_CC_IRQn 1 */ | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END TIM8_CC_IRQn 0 */ |     /* USER CODE END TIM8_CC_IRQn 1 */ | ||||||
|   // HAL_TIM_IRQHandler(&htim8);
 |  | ||||||
|   /* USER CODE BEGIN TIM8_CC_IRQn 1 */ |  | ||||||
| 
 |  | ||||||
|   /* USER CODE END TIM8_CC_IRQn 1 */ |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
|   * @brief This function handles USB OTG FS global interrupt. |   * @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 BEGIN OTG_FS_IRQn 0 */ |  | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END OTG_FS_IRQn 0 */ |     /* USER CODE END OTG_FS_IRQn 0 */ | ||||||
|   HAL_PCD_IRQHandler(&hpcd_USB_OTG_FS); |     HAL_PCD_IRQHandler(&hpcd_USB_OTG_FS); | ||||||
|   /* USER CODE BEGIN OTG_FS_IRQn 1 */ |     /* USER CODE BEGIN OTG_FS_IRQn 1 */ | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END OTG_FS_IRQn 1 */ |     /* USER CODE END OTG_FS_IRQn 1 */ | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /* USER CODE BEGIN 1 */ | /* USER CODE BEGIN 1 */ | ||||||
|  | |||||||
| @ -91,16 +91,16 @@ | |||||||
| 
 | 
 | ||||||
| #include "stm32l4xx.h" | #include "stm32l4xx.h" | ||||||
| 
 | 
 | ||||||
| #if !defined  (HSE_VALUE) | #if !defined(HSE_VALUE) | ||||||
|   #define HSE_VALUE    8000000U  /*!< Value of the External oscillator in Hz */ | #define HSE_VALUE 8000000U /*!< Value of the External oscillator in Hz */ | ||||||
| #endif /* HSE_VALUE */ | #endif /* HSE_VALUE */ | ||||||
| 
 | 
 | ||||||
| #if !defined  (MSI_VALUE) | #if !defined(MSI_VALUE) | ||||||
|   #define MSI_VALUE    4000000U  /*!< Value of the Internal oscillator in Hz*/ | #define MSI_VALUE 4000000U /*!< Value of the Internal oscillator in Hz*/ | ||||||
| #endif /* MSI_VALUE */ | #endif /* MSI_VALUE */ | ||||||
| 
 | 
 | ||||||
| #if !defined  (HSI_VALUE) | #if !defined(HSI_VALUE) | ||||||
|   #define HSI_VALUE    16000000U /*!< Value of the Internal oscillator in Hz*/ | #define HSI_VALUE 16000000U /*!< Value of the Internal oscillator in Hz*/ | ||||||
| #endif /* HSI_VALUE */ | #endif /* HSI_VALUE */ | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
| @ -123,7 +123,8 @@ | |||||||
| /*!< Uncomment the following line if you need to relocate your vector Table in
 | /*!< Uncomment the following line if you need to relocate your vector Table in
 | ||||||
|      Internal SRAM. */ |      Internal SRAM. */ | ||||||
| /* #define VECT_TAB_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. */ |                                    This value must be a multiple of 0x200. */ | ||||||
| /******************************************************************************/ | /******************************************************************************/ | ||||||
| /**
 | /**
 | ||||||
| @ -141,7 +142,7 @@ | |||||||
| /** @addtogroup STM32L4xx_System_Private_Variables
 | /** @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() |       1) by calling CMSIS function SystemCoreClockUpdate() | ||||||
|       2) by calling HAL API function HAL_RCC_GetHCLKFreq() |       2) by calling HAL API function HAL_RCC_GetHCLKFreq() | ||||||
|       3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency |       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 |                is no need to call the 2 first functions listed above, since SystemCoreClock | ||||||
|                variable is updated automatically. |                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 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 uint8_t APBPrescTable[8] = {0U, 0U, 0U, 0U, 1U, 2U, 3U, 4U}; | ||||||
|   const uint32_t MSIRangeTable[12] = {100000U,   200000U,   400000U,   800000U,  1000000U,  2000000U, \ | const uint32_t MSIRangeTable[12] = {100000U, | ||||||
|                                       4000000U, 8000000U, 16000000U, 24000000U, 32000000U, 48000000U}; |                                     200000U, | ||||||
|  |                                     400000U, | ||||||
|  |                                     800000U, | ||||||
|  |                                     1000000U, | ||||||
|  |                                     2000000U, | ||||||
|  |                                     4000000U, | ||||||
|  |                                     8000000U, | ||||||
|  |                                     16000000U, | ||||||
|  |                                     24000000U, | ||||||
|  |                                     32000000U, | ||||||
|  |                                     48000000U}; | ||||||
| /**
 | /**
 | ||||||
|   * @} |   * @} | ||||||
|   */ |   */ | ||||||
| @ -177,37 +188,36 @@ | |||||||
|   * @retval None |   * @retval None | ||||||
|   */ |   */ | ||||||
| 
 | 
 | ||||||
| void SystemInit(void) | void SystemInit(void) { | ||||||
| { | /* FPU settings ------------------------------------------------------------*/ | ||||||
|   /* FPU settings ------------------------------------------------------------*/ | #if(__FPU_PRESENT == 1) && (__FPU_USED == 1) | ||||||
|   #if (__FPU_PRESENT == 1) && (__FPU_USED == 1) |     SCB->CPACR |= ((3UL << 10 * 2) | (3UL << 11 * 2)); /* set CP10 and CP11 Full Access */ | ||||||
|     SCB->CPACR |= ((3UL << 10*2)|(3UL << 11*2));  /* set CP10 and CP11 Full Access */ | #endif | ||||||
|   #endif |  | ||||||
| 
 | 
 | ||||||
|   /* Reset the RCC clock configuration to the default reset state ------------*/ |     /* Reset the RCC clock configuration to the default reset state ------------*/ | ||||||
|   /* Set MSION bit */ |     /* Set MSION bit */ | ||||||
|   RCC->CR |= RCC_CR_MSION; |     RCC->CR |= RCC_CR_MSION; | ||||||
| 
 | 
 | ||||||
|   /* Reset CFGR register */ |     /* Reset CFGR register */ | ||||||
|   RCC->CFGR = 0x00000000U; |     RCC->CFGR = 0x00000000U; | ||||||
| 
 | 
 | ||||||
|   /* Reset HSEON, CSSON , HSION, and PLLON bits */ |     /* Reset HSEON, CSSON , HSION, and PLLON bits */ | ||||||
|   RCC->CR &= 0xEAF6FFFFU; |     RCC->CR &= 0xEAF6FFFFU; | ||||||
| 
 | 
 | ||||||
|   /* Reset PLLCFGR register */ |     /* Reset PLLCFGR register */ | ||||||
|   RCC->PLLCFGR = 0x00001000U; |     RCC->PLLCFGR = 0x00001000U; | ||||||
| 
 | 
 | ||||||
|   /* Reset HSEBYP bit */ |     /* Reset HSEBYP bit */ | ||||||
|   RCC->CR &= 0xFFFBFFFFU; |     RCC->CR &= 0xFFFBFFFFU; | ||||||
| 
 | 
 | ||||||
|   /* Disable all interrupts */ |     /* Disable all interrupts */ | ||||||
|   RCC->CIER = 0x00000000U; |     RCC->CIER = 0x00000000U; | ||||||
| 
 | 
 | ||||||
|   /* Configure the Vector Table location add offset address ------------------*/ |     /* Configure the Vector Table location add offset address ------------------*/ | ||||||
| #ifdef VECT_TAB_SRAM | #ifdef VECT_TAB_SRAM | ||||||
|   SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */ |     SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */ | ||||||
| #else | #else | ||||||
|   SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */ |     SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */ | ||||||
| #endif | #endif | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -253,75 +263,68 @@ void SystemInit(void) | |||||||
|   * @param  None |   * @param  None | ||||||
|   * @retval None |   * @retval None | ||||||
|   */ |   */ | ||||||
| void SystemCoreClockUpdate(void) | void SystemCoreClockUpdate(void) { | ||||||
| { |     uint32_t tmp = 0U, msirange = 0U, pllvco = 0U, pllr = 2U, pllsource = 0U, pllm = 2U; | ||||||
|   uint32_t tmp = 0U, msirange = 0U, pllvco = 0U, pllr = 2U, pllsource = 0U, pllm = 2U; |  | ||||||
| 
 | 
 | ||||||
|   /* Get MSI Range frequency--------------------------------------------------*/ |     /* Get MSI Range frequency--------------------------------------------------*/ | ||||||
|   if((RCC->CR & RCC_CR_MSIRGSEL) == RESET) |     if((RCC->CR & RCC_CR_MSIRGSEL) == RESET) { /* MSISRANGE from RCC_CSR applies */ | ||||||
|   { /* MSISRANGE from RCC_CSR applies */ |         msirange = (RCC->CSR & RCC_CSR_MSISRANGE) >> 8U; | ||||||
|     msirange = (RCC->CSR & RCC_CSR_MSISRANGE) >> 8U; |     } else { /* MSIRANGE from RCC_CR applies */ | ||||||
|   } |         msirange = (RCC->CR & RCC_CR_MSIRANGE) >> 4U; | ||||||
|   else |     } | ||||||
|   { /* MSIRANGE from RCC_CR applies */ |     /*MSI frequency range in HZ*/ | ||||||
|     msirange = (RCC->CR & RCC_CR_MSIRANGE) >> 4U; |     msirange = MSIRangeTable[msirange]; | ||||||
|   } |  | ||||||
|   /*MSI frequency range in HZ*/ |  | ||||||
|   msirange = MSIRangeTable[msirange]; |  | ||||||
| 
 | 
 | ||||||
|   /* Get SYSCLK source -------------------------------------------------------*/ |     /* Get SYSCLK source -------------------------------------------------------*/ | ||||||
|   switch (RCC->CFGR & RCC_CFGR_SWS) |     switch(RCC->CFGR & RCC_CFGR_SWS) { | ||||||
|   { |     case 0x00: /* MSI used as system clock source */ | ||||||
|     case 0x00:  /* MSI used as system clock source */ |         SystemCoreClock = msirange; | ||||||
|       SystemCoreClock = msirange; |         break; | ||||||
|       break; |  | ||||||
| 
 | 
 | ||||||
|     case 0x04:  /* HSI used as system clock source */ |     case 0x04: /* HSI used as system clock source */ | ||||||
|       SystemCoreClock = HSI_VALUE; |         SystemCoreClock = HSI_VALUE; | ||||||
|       break; |         break; | ||||||
| 
 | 
 | ||||||
|     case 0x08:  /* HSE used as system clock source */ |     case 0x08: /* HSE used as system clock source */ | ||||||
|       SystemCoreClock = HSE_VALUE; |         SystemCoreClock = HSE_VALUE; | ||||||
|       break; |         break; | ||||||
| 
 | 
 | ||||||
|     case 0x0C:  /* PLL used as system clock  source */ |     case 0x0C: /* PLL used as system clock  source */ | ||||||
|       /* PLL_VCO = (HSE_VALUE or HSI_VALUE or MSI_VALUE/ PLLM) * PLLN
 |         /* PLL_VCO = (HSE_VALUE or HSI_VALUE or MSI_VALUE/ PLLM) * PLLN
 | ||||||
|          SYSCLK = PLL_VCO / PLLR |          SYSCLK = PLL_VCO / PLLR | ||||||
|          */ |          */ | ||||||
|       pllsource = (RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC); |         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 */ | ||||||
|         case 0x02:  /* HSI used as PLL clock source */ |             pllvco = (HSI_VALUE / pllm); | ||||||
|           pllvco = (HSI_VALUE / pllm); |             break; | ||||||
|           break; |  | ||||||
| 
 | 
 | ||||||
|         case 0x03:  /* HSE used as PLL clock source */ |         case 0x03: /* HSE used as PLL clock source */ | ||||||
|           pllvco = (HSE_VALUE / pllm); |             pllvco = (HSE_VALUE / pllm); | ||||||
|           break; |             break; | ||||||
| 
 | 
 | ||||||
|         default:    /* MSI used as PLL clock source */ |         default: /* MSI used as PLL clock source */ | ||||||
|           pllvco = (msirange / pllm); |             pllvco = (msirange / pllm); | ||||||
|           break; |             break; | ||||||
|       } |         } | ||||||
|       pllvco = pllvco * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 8U); |         pllvco = pllvco * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 8U); | ||||||
|       pllr = (((RCC->PLLCFGR & RCC_PLLCFGR_PLLR) >> 25U) + 1U) * 2U; |         pllr = (((RCC->PLLCFGR & RCC_PLLCFGR_PLLR) >> 25U) + 1U) * 2U; | ||||||
|       SystemCoreClock = pllvco/pllr; |         SystemCoreClock = pllvco / pllr; | ||||||
|       break; |         break; | ||||||
| 
 | 
 | ||||||
|     default: |     default: | ||||||
|       SystemCoreClock = msirange; |         SystemCoreClock = msirange; | ||||||
|       break; |         break; | ||||||
|   } |     } | ||||||
|   /* Compute HCLK clock frequency --------------------------------------------*/ |     /* Compute HCLK clock frequency --------------------------------------------*/ | ||||||
|   /* Get HCLK prescaler */ |     /* Get HCLK prescaler */ | ||||||
|   tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4U)]; |     tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4U)]; | ||||||
|   /* HCLK clock frequency */ |     /* HCLK clock frequency */ | ||||||
|   SystemCoreClock >>= tmp; |     SystemCoreClock >>= tmp; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| /**
 | /**
 | ||||||
|   * @} |   * @} | ||||||
|   */ |   */ | ||||||
|  | |||||||
| @ -63,32 +63,27 @@ extern USBD_DescriptorsTypeDef FS_Desc; | |||||||
|   * Init USB device Library, add supported class and start the library |   * Init USB device Library, add supported class and start the library | ||||||
|   * @retval None |   * @retval None | ||||||
|   */ |   */ | ||||||
| void MX_USB_DEVICE_Init(void) | void MX_USB_DEVICE_Init(void) { | ||||||
| { |     /* USER CODE BEGIN USB_DEVICE_Init_PreTreatment */ | ||||||
|   /* USER CODE BEGIN USB_DEVICE_Init_PreTreatment */ | 
 | ||||||
|    |     /* USER CODE END USB_DEVICE_Init_PreTreatment */ | ||||||
|   /* USER CODE END USB_DEVICE_Init_PreTreatment */ | 
 | ||||||
|    |     /* Init Device Library, add supported class and start the library. */ | ||||||
|   /* 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(); | ||||||
|   { |     } | ||||||
|     Error_Handler(); |     if(USBD_RegisterClass(&hUsbDeviceFS, &USBD_CDC) != USBD_OK) { | ||||||
|   } |         Error_Handler(); | ||||||
|   if (USBD_RegisterClass(&hUsbDeviceFS, &USBD_CDC) != USBD_OK) |     } | ||||||
|   { |     if(USBD_CDC_RegisterInterface(&hUsbDeviceFS, &USBD_Interface_fops_FS) != USBD_OK) { | ||||||
|     Error_Handler(); |         Error_Handler(); | ||||||
|   } |     } | ||||||
|   if (USBD_CDC_RegisterInterface(&hUsbDeviceFS, &USBD_Interface_fops_FS) != USBD_OK) |     if(USBD_Start(&hUsbDeviceFS) != USBD_OK) { | ||||||
|   { |         Error_Handler(); | ||||||
|     Error_Handler(); |     } | ||||||
|   } |     /* USER CODE BEGIN USB_DEVICE_Init_PostTreatment */ | ||||||
|   if (USBD_Start(&hUsbDeviceFS) != USBD_OK) | 
 | ||||||
|   { |     /* USER CODE END USB_DEVICE_Init_PostTreatment */ | ||||||
|     Error_Handler(); |  | ||||||
|   } |  | ||||||
|   /* USER CODE BEGIN USB_DEVICE_Init_PostTreatment */ |  | ||||||
|    |  | ||||||
|   /* USER CODE END USB_DEVICE_Init_PostTreatment */ |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
|  | |||||||
| @ -65,8 +65,8 @@ | |||||||
| /* USER CODE BEGIN PRIVATE_DEFINES */ | /* USER CODE BEGIN PRIVATE_DEFINES */ | ||||||
| /* Define size for the receive and transmit buffer over CDC */ | /* Define size for the receive and transmit buffer over CDC */ | ||||||
| /* It's up to user to redefine and/or remove those define */ | /* It's up to user to redefine and/or remove those define */ | ||||||
| #define APP_RX_DATA_SIZE  2048 | #define APP_RX_DATA_SIZE 2048 | ||||||
| #define APP_TX_DATA_SIZE  2048 | #define APP_TX_DATA_SIZE 2048 | ||||||
| /* USER CODE END PRIVATE_DEFINES */ | /* USER CODE END PRIVATE_DEFINES */ | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
| @ -129,7 +129,7 @@ extern USBD_HandleTypeDef hUsbDeviceFS; | |||||||
| static int8_t CDC_Init_FS(void); | static int8_t CDC_Init_FS(void); | ||||||
| static int8_t CDC_DeInit_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_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 */ | /* USER CODE BEGIN PRIVATE_FUNCTIONS_DECLARATION */ | ||||||
| 
 | 
 | ||||||
| @ -139,38 +139,33 @@ static int8_t CDC_Receive_FS(uint8_t* pbuf, uint32_t *Len); | |||||||
|   * @} |   * @} | ||||||
|   */ |   */ | ||||||
| 
 | 
 | ||||||
| USBD_CDC_ItfTypeDef USBD_Interface_fops_FS = | USBD_CDC_ItfTypeDef USBD_Interface_fops_FS = {CDC_Init_FS, | ||||||
| { |                                               CDC_DeInit_FS, | ||||||
|   CDC_Init_FS, |                                               CDC_Control_FS, | ||||||
|   CDC_DeInit_FS, |                                               CDC_Receive_FS}; | ||||||
|   CDC_Control_FS, |  | ||||||
|   CDC_Receive_FS |  | ||||||
| }; |  | ||||||
| 
 | 
 | ||||||
| /* Private functions ---------------------------------------------------------*/ | /* Private functions ---------------------------------------------------------*/ | ||||||
| /**
 | /**
 | ||||||
|   * @brief  Initializes the CDC media low layer over the FS USB IP |   * @brief  Initializes the CDC media low layer over the FS USB IP | ||||||
|   * @retval USBD_OK if all operations are OK else USBD_FAIL |   * @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 */ | ||||||
|   /* USER CODE BEGIN 3 */ |     /* Set Application Buffers */ | ||||||
|   /* Set Application Buffers */ |     USBD_CDC_SetTxBuffer(&hUsbDeviceFS, UserTxBufferFS, 0); | ||||||
|   USBD_CDC_SetTxBuffer(&hUsbDeviceFS, UserTxBufferFS, 0); |     USBD_CDC_SetRxBuffer(&hUsbDeviceFS, UserRxBufferFS); | ||||||
|   USBD_CDC_SetRxBuffer(&hUsbDeviceFS, UserRxBufferFS); |     return (USBD_OK); | ||||||
|   return (USBD_OK); |     /* USER CODE END 3 */ | ||||||
|   /* USER CODE END 3 */ |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
|   * @brief  DeInitializes the CDC media low layer |   * @brief  DeInitializes the CDC media low layer | ||||||
|   * @retval USBD_OK if all operations are OK else USBD_FAIL |   * @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 */ | ||||||
|   /* USER CODE BEGIN 4 */ |     return (USBD_OK); | ||||||
|   return (USBD_OK); |     /* USER CODE END 4 */ | ||||||
|   /* USER CODE END 4 */ |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
| @ -180,70 +175,68 @@ static int8_t CDC_DeInit_FS(void) | |||||||
|   * @param  length: Number of data to be sent (in bytes) |   * @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 |   * @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 */ | ||||||
|   /* USER CODE BEGIN 5 */ |     switch(cmd) { | ||||||
|   switch(cmd) |  | ||||||
|   { |  | ||||||
|     case CDC_SEND_ENCAPSULATED_COMMAND: |     case CDC_SEND_ENCAPSULATED_COMMAND: | ||||||
| 
 | 
 | ||||||
|     break; |         break; | ||||||
| 
 | 
 | ||||||
|     case CDC_GET_ENCAPSULATED_RESPONSE: |     case CDC_GET_ENCAPSULATED_RESPONSE: | ||||||
| 
 | 
 | ||||||
|     break; |         break; | ||||||
| 
 | 
 | ||||||
|     case CDC_SET_COMM_FEATURE: |     case CDC_SET_COMM_FEATURE: | ||||||
| 
 | 
 | ||||||
|     break; |         break; | ||||||
| 
 | 
 | ||||||
|     case CDC_GET_COMM_FEATURE: |     case CDC_GET_COMM_FEATURE: | ||||||
| 
 | 
 | ||||||
|     break; |         break; | ||||||
| 
 | 
 | ||||||
|     case CDC_CLEAR_COMM_FEATURE: |     case CDC_CLEAR_COMM_FEATURE: | ||||||
| 
 | 
 | ||||||
|     break; |         break; | ||||||
| 
 | 
 | ||||||
|   /*******************************************************************************/ |         /*******************************************************************************/ | ||||||
|   /* Line Coding Structure                                                       */ |         /* Line Coding Structure                                                       */ | ||||||
|   /*-----------------------------------------------------------------------------*/ |         /*-----------------------------------------------------------------------------*/ | ||||||
|   /* Offset | Field       | Size | Value  | Description                          */ |         /* Offset | Field       | Size | Value  | Description                          */ | ||||||
|   /* 0      | dwDTERate   |   4  | Number |Data terminal rate, in bits per second*/ |         /* 0      | dwDTERate   |   4  | Number |Data terminal rate, in bits per second*/ | ||||||
|   /* 4      | bCharFormat |   1  | Number | Stop bits                            */ |         /* 4      | bCharFormat |   1  | Number | Stop bits                            */ | ||||||
|   /*                                        0 - 1 Stop bit                       */ |         /*                                        0 - 1 Stop bit                       */ | ||||||
|   /*                                        1 - 1.5 Stop bits                    */ |         /*                                        1 - 1.5 Stop bits                    */ | ||||||
|   /*                                        2 - 2 Stop bits                      */ |         /*                                        2 - 2 Stop bits                      */ | ||||||
|   /* 5      | bParityType |  1   | Number | Parity                               */ |         /* 5      | bParityType |  1   | Number | Parity                               */ | ||||||
|   /*                                        0 - None                             */ |         /*                                        0 - None                             */ | ||||||
|   /*                                        1 - Odd                              */ |         /*                                        1 - Odd                              */ | ||||||
|   /*                                        2 - Even                             */ |         /*                                        2 - Even                             */ | ||||||
|   /*                                        3 - Mark                             */ |         /*                                        3 - Mark                             */ | ||||||
|   /*                                        4 - Space                            */ |         /*                                        4 - Space                            */ | ||||||
|   /* 6      | bDataBits  |   1   | Number Data bits (5, 6, 7, 8 or 16).          */ |         /* 6      | bDataBits  |   1   | Number Data bits (5, 6, 7, 8 or 16).          */ | ||||||
|   /*******************************************************************************/ |         /*******************************************************************************/ | ||||||
|     case CDC_SET_LINE_CODING: |     case CDC_SET_LINE_CODING: | ||||||
| 
 | 
 | ||||||
|     break; |         break; | ||||||
| 
 | 
 | ||||||
|     case CDC_GET_LINE_CODING: |     case CDC_GET_LINE_CODING: | ||||||
| 
 | 
 | ||||||
|     break; |         break; | ||||||
| 
 | 
 | ||||||
|     case CDC_SET_CONTROL_LINE_STATE: |     case CDC_SET_CONTROL_LINE_STATE: | ||||||
| 
 | 
 | ||||||
|     break; |         break; | ||||||
| 
 | 
 | ||||||
|     case CDC_SEND_BREAK: |     case CDC_SEND_BREAK: | ||||||
| 
 | 
 | ||||||
|     break; |         break; | ||||||
| 
 | 
 | ||||||
|   default: |     default: | ||||||
|     break; |         break; | ||||||
|   } |     } | ||||||
| 
 | 
 | ||||||
|   return (USBD_OK); |     return (USBD_OK); | ||||||
|   /* USER CODE END 5 */ |     /* USER CODE END 5 */ | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
| @ -260,13 +253,12 @@ static int8_t CDC_Control_FS(uint8_t cmd, uint8_t* pbuf, uint16_t length) | |||||||
|   * @param  Len: Number of data received (in bytes) |   * @param  Len: Number of data received (in bytes) | ||||||
|   * @retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL |   * @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 */ | ||||||
|   /* USER CODE BEGIN 6 */ |     USBD_CDC_SetRxBuffer(&hUsbDeviceFS, &Buf[0]); | ||||||
|   USBD_CDC_SetRxBuffer(&hUsbDeviceFS, &Buf[0]); |     USBD_CDC_ReceivePacket(&hUsbDeviceFS); | ||||||
|   USBD_CDC_ReceivePacket(&hUsbDeviceFS); |     return (USBD_OK); | ||||||
|   return (USBD_OK); |     /* USER CODE END 6 */ | ||||||
|   /* USER CODE END 6 */ |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
| @ -280,18 +272,17 @@ static int8_t CDC_Receive_FS(uint8_t* Buf, uint32_t *Len) | |||||||
|   * @param  Len: Number of data to be sent (in bytes) |   * @param  Len: Number of data to be sent (in bytes) | ||||||
|   * @retval USBD_OK if all operations are OK else USBD_FAIL or USBD_BUSY |   * @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; | ||||||
|   uint8_t result = USBD_OK; |     /* USER CODE BEGIN 7 */ | ||||||
|   /* USER CODE BEGIN 7 */ |     USBD_CDC_HandleTypeDef* hcdc = (USBD_CDC_HandleTypeDef*)hUsbDeviceFS.pClassData; | ||||||
|   USBD_CDC_HandleTypeDef *hcdc = (USBD_CDC_HandleTypeDef*)hUsbDeviceFS.pClassData; |     if(hcdc->TxState != 0) { | ||||||
|   if (hcdc->TxState != 0){ |         return USBD_BUSY; | ||||||
|     return USBD_BUSY; |     } | ||||||
|   } |     USBD_CDC_SetTxBuffer(&hUsbDeviceFS, Buf, Len); | ||||||
|   USBD_CDC_SetTxBuffer(&hUsbDeviceFS, Buf, Len); |     result = USBD_CDC_TransmitPacket(&hUsbDeviceFS); | ||||||
|   result = USBD_CDC_TransmitPacket(&hUsbDeviceFS); |     /* USER CODE END 7 */ | ||||||
|   /* USER CODE END 7 */ |     return result; | ||||||
|   return result; |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /* USER CODE BEGIN PRIVATE_FUNCTIONS_IMPLEMENTATION */ | /* USER CODE BEGIN PRIVATE_FUNCTIONS_IMPLEMENTATION */ | ||||||
|  | |||||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @ -63,15 +63,15 @@ | |||||||
|   * @{ |   * @{ | ||||||
|   */ |   */ | ||||||
| 
 | 
 | ||||||
| #define USBD_VID     1155 | #define USBD_VID 1155 | ||||||
| #define USBD_LANGID_STRING     1033 | #define USBD_LANGID_STRING 1033 | ||||||
| #define USBD_MANUFACTURER_STRING     "STMicroelectronics" | #define USBD_MANUFACTURER_STRING "STMicroelectronics" | ||||||
| #define USBD_PID_FS     22336 | #define USBD_PID_FS 22336 | ||||||
| #define USBD_PRODUCT_STRING_FS     "Flipper Zero Virtual ComPort" | #define USBD_PRODUCT_STRING_FS "Flipper Zero Virtual ComPort" | ||||||
| #define USBD_CONFIGURATION_STRING_FS     "CDC Config" | #define USBD_CONFIGURATION_STRING_FS "CDC Config" | ||||||
| #define USBD_INTERFACE_STRING_FS     "CDC Interface" | #define USBD_INTERFACE_STRING_FS "CDC Interface" | ||||||
| 
 | 
 | ||||||
| #define USB_SIZ_BOS_DESC            0x0C | #define USB_SIZ_BOS_DESC 0x0C | ||||||
| 
 | 
 | ||||||
| /* USER CODE BEGIN PRIVATE_DEFINES */ | /* USER CODE BEGIN PRIVATE_DEFINES */ | ||||||
| 
 | 
 | ||||||
| @ -97,34 +97,33 @@ | |||||||
| /**
 | /**
 | ||||||
|   * @} |   * @} | ||||||
|   */ |   */ | ||||||
|    | 
 | ||||||
| /** @defgroup USBD_DESC_Private_FunctionPrototypes USBD_DESC_Private_FunctionPrototypes
 | /** @defgroup USBD_DESC_Private_FunctionPrototypes USBD_DESC_Private_FunctionPrototypes
 | ||||||
|   * @brief Private functions declaration. |   * @brief Private functions declaration. | ||||||
|   * @{ |   * @{ | ||||||
|   */ |   */ | ||||||
|    | 
 | ||||||
| static void Get_SerialNum(void); | 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
 | /** @defgroup USBD_DESC_Private_FunctionPrototypes USBD_DESC_Private_FunctionPrototypes
 | ||||||
|   * @brief Private functions declaration for FS. |   * @brief Private functions declaration for FS. | ||||||
|   * @{ |   * @{ | ||||||
|   */ |   */ | ||||||
| 
 | 
 | ||||||
| uint8_t * USBD_FS_DeviceDescriptor(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_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t* length); | ||||||
| uint8_t * USBD_FS_ManufacturerStrDescriptor(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_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t* length); | ||||||
| uint8_t * USBD_FS_SerialStrDescriptor(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_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t* length); | ||||||
| uint8_t * USBD_FS_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); | uint8_t* USBD_FS_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t* length); | ||||||
| #if (USBD_LPM_ENABLED == 1) | #if(USBD_LPM_ENABLED == 1) | ||||||
| uint8_t * USBD_FS_USR_BOSDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); | uint8_t* USBD_FS_USR_BOSDescriptor(USBD_SpeedTypeDef speed, uint16_t* length); | ||||||
| #endif /* (USBD_LPM_ENABLED == 1) */ | #endif /* (USBD_LPM_ENABLED == 1) */ | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
| @ -136,74 +135,71 @@ uint8_t * USBD_FS_USR_BOSDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); | |||||||
|   * @{ |   * @{ | ||||||
|   */ |   */ | ||||||
| 
 | 
 | ||||||
| USBD_DescriptorsTypeDef FS_Desc = | USBD_DescriptorsTypeDef FS_Desc = {USBD_FS_DeviceDescriptor, | ||||||
| { |                                    USBD_FS_LangIDStrDescriptor, | ||||||
|   USBD_FS_DeviceDescriptor |                                    USBD_FS_ManufacturerStrDescriptor, | ||||||
| , USBD_FS_LangIDStrDescriptor |                                    USBD_FS_ProductStrDescriptor, | ||||||
| , USBD_FS_ManufacturerStrDescriptor |                                    USBD_FS_SerialStrDescriptor, | ||||||
| , USBD_FS_ProductStrDescriptor |                                    USBD_FS_ConfigStrDescriptor, | ||||||
| , USBD_FS_SerialStrDescriptor |                                    USBD_FS_InterfaceStrDescriptor | ||||||
| , USBD_FS_ConfigStrDescriptor | #if(USBD_LPM_ENABLED == 1) | ||||||
| , USBD_FS_InterfaceStrDescriptor |                                    , | ||||||
| #if (USBD_LPM_ENABLED == 1) |                                    USBD_FS_USR_BOSDescriptor | ||||||
| , USBD_FS_USR_BOSDescriptor |  | ||||||
| #endif /* (USBD_LPM_ENABLED == 1) */ | #endif /* (USBD_LPM_ENABLED == 1) */ | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| #if defined ( __ICCARM__ ) /* IAR Compiler */ | #if defined(__ICCARM__) /* IAR Compiler */ | ||||||
|   #pragma data_alignment=4 | #pragma data_alignment = 4 | ||||||
| #endif /* defined ( __ICCARM__ ) */ | #endif /* defined ( __ICCARM__ ) */ | ||||||
| /** USB standard device descriptor. */ | /** 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 */ | ||||||
|   0x12,                       /*bLength */ |     USB_DESC_TYPE_DEVICE, /*bDescriptorType*/ | ||||||
|   USB_DESC_TYPE_DEVICE,       /*bDescriptorType*/ | #if(USBD_LPM_ENABLED == 1) | ||||||
| #if (USBD_LPM_ENABLED == 1) |     0x01, | ||||||
|   0x01,                       /*bcdUSB */ /* changed to USB version 2.01
 | /*bcdUSB */ /* changed to USB version 2.01
 | ||||||
|                                              in order to support LPM L1 suspend |                                              in order to support LPM L1 suspend | ||||||
|                                              resume test of USBCV3.0*/ |                                              resume test of USBCV3.0*/ | ||||||
| #else | #else | ||||||
|   0x00,                       /*bcdUSB */ |     0x00, /*bcdUSB */ | ||||||
| #endif /* (USBD_LPM_ENABLED == 1) */ | #endif /* (USBD_LPM_ENABLED == 1) */ | ||||||
|   0x02, |     0x02, | ||||||
|   0x02,                       /*bDeviceClass*/ |     0x02, /*bDeviceClass*/ | ||||||
|   0x02,                       /*bDeviceSubClass*/ |     0x02, /*bDeviceSubClass*/ | ||||||
|   0x00,                       /*bDeviceProtocol*/ |     0x00, /*bDeviceProtocol*/ | ||||||
|   USB_MAX_EP0_SIZE,           /*bMaxPacketSize*/ |     USB_MAX_EP0_SIZE, /*bMaxPacketSize*/ | ||||||
|   LOBYTE(USBD_VID),           /*idVendor*/ |     LOBYTE(USBD_VID), /*idVendor*/ | ||||||
|   HIBYTE(USBD_VID),           /*idVendor*/ |     HIBYTE(USBD_VID), /*idVendor*/ | ||||||
|   LOBYTE(USBD_PID_FS),        /*idProduct*/ |     LOBYTE(USBD_PID_FS), /*idProduct*/ | ||||||
|   HIBYTE(USBD_PID_FS),        /*idProduct*/ |     HIBYTE(USBD_PID_FS), /*idProduct*/ | ||||||
|   0x00,                       /*bcdDevice rel. 2.00*/ |     0x00, /*bcdDevice rel. 2.00*/ | ||||||
|   0x02, |     0x02, | ||||||
|   USBD_IDX_MFC_STR,           /*Index of manufacturer  string*/ |     USBD_IDX_MFC_STR, /*Index of manufacturer  string*/ | ||||||
|   USBD_IDX_PRODUCT_STR,       /*Index of product string*/ |     USBD_IDX_PRODUCT_STR, /*Index of product string*/ | ||||||
|   USBD_IDX_SERIAL_STR,        /*Index of serial number string*/ |     USBD_IDX_SERIAL_STR, /*Index of serial number string*/ | ||||||
|   USBD_MAX_NUM_CONFIGURATION  /*bNumConfigurations*/ |     USBD_MAX_NUM_CONFIGURATION /*bNumConfigurations*/ | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| /* USB_DeviceDescriptor */ | /* USB_DeviceDescriptor */ | ||||||
| /** BOS descriptor. */ | /** BOS descriptor. */ | ||||||
| #if (USBD_LPM_ENABLED == 1) | #if(USBD_LPM_ENABLED == 1) | ||||||
| #if defined ( __ICCARM__ ) /* IAR Compiler */ | #if defined(__ICCARM__) /* IAR Compiler */ | ||||||
|   #pragma data_alignment=4 | #pragma data_alignment = 4 | ||||||
| #endif /* defined ( __ICCARM__ ) */ | #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, | ||||||
|   0x5, |     USB_DESC_TYPE_BOS, | ||||||
|   USB_DESC_TYPE_BOS, |     0xC, | ||||||
|   0xC, |     0x0, | ||||||
|   0x0, |     0x1, /* 1 device capability*/ | ||||||
|   0x1,  /* 1 device capability*/ |     /* device capability*/ | ||||||
|         /* device capability*/ |     0x7, | ||||||
|   0x7, |     USB_DEVICE_CAPABITY_TYPE, | ||||||
|   USB_DEVICE_CAPABITY_TYPE, |     0x2, | ||||||
|   0x2, |     0x2, /* LPM capability bit set*/ | ||||||
|   0x2,  /* LPM capability bit set*/ |     0x0, | ||||||
|   0x0, |     0x0, | ||||||
|   0x0, |     0x0}; | ||||||
|   0x0 |  | ||||||
| }; |  | ||||||
| #endif /* (USBD_LPM_ENABLED == 1) */ | #endif /* (USBD_LPM_ENABLED == 1) */ | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
| @ -215,31 +211,29 @@ __ALIGN_BEGIN uint8_t USBD_FS_BOSDesc[USB_SIZ_BOS_DESC] __ALIGN_END = | |||||||
|   * @{ |   * @{ | ||||||
|   */ |   */ | ||||||
| 
 | 
 | ||||||
| #if defined ( __ICCARM__ ) /* IAR Compiler */ | #if defined(__ICCARM__) /* IAR Compiler */ | ||||||
|   #pragma data_alignment=4 | #pragma data_alignment = 4 | ||||||
| #endif /* defined ( __ICCARM__ ) */ | #endif /* defined ( __ICCARM__ ) */ | ||||||
| 
 | 
 | ||||||
| /** USB lang indentifier descriptor. */ | /** 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_LEN_LANGID_STR_DESC, |     USB_DESC_TYPE_STRING, | ||||||
|      USB_DESC_TYPE_STRING, |     LOBYTE(USBD_LANGID_STRING), | ||||||
|      LOBYTE(USBD_LANGID_STRING), |     HIBYTE(USBD_LANGID_STRING)}; | ||||||
|      HIBYTE(USBD_LANGID_STRING) |  | ||||||
| }; |  | ||||||
| 
 | 
 | ||||||
| #if defined ( __ICCARM__ ) /* IAR Compiler */ | #if defined(__ICCARM__) /* IAR Compiler */ | ||||||
|   #pragma data_alignment=4 | #pragma data_alignment = 4 | ||||||
| #endif /* defined ( __ICCARM__ ) */ | #endif /* defined ( __ICCARM__ ) */ | ||||||
| /* Internal string descriptor. */ | /* Internal string descriptor. */ | ||||||
| __ALIGN_BEGIN uint8_t USBD_StrDesc[USBD_MAX_STR_DESC_SIZ] __ALIGN_END; | __ALIGN_BEGIN uint8_t USBD_StrDesc[USBD_MAX_STR_DESC_SIZ] __ALIGN_END; | ||||||
| 
 | 
 | ||||||
| #if defined ( __ICCARM__ ) /*!< IAR Compiler */ | #if defined(__ICCARM__) /*!< IAR Compiler */ | ||||||
|   #pragma data_alignment=4    | #pragma data_alignment = 4 | ||||||
| #endif | #endif | ||||||
| __ALIGN_BEGIN uint8_t USBD_StringSerial[USB_SIZ_STRING_SERIAL] __ALIGN_END = { | __ALIGN_BEGIN uint8_t USBD_StringSerial[USB_SIZ_STRING_SERIAL] __ALIGN_END = { | ||||||
|   USB_SIZ_STRING_SERIAL, |     USB_SIZ_STRING_SERIAL, | ||||||
|   USB_DESC_TYPE_STRING, |     USB_DESC_TYPE_STRING, | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
| @ -257,11 +251,10 @@ __ALIGN_BEGIN uint8_t USBD_StringSerial[USB_SIZ_STRING_SERIAL] __ALIGN_END = { | |||||||
|   * @param  length : Pointer to data length variable |   * @param  length : Pointer to data length variable | ||||||
|   * @retval Pointer to descriptor buffer |   * @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); | ||||||
|   UNUSED(speed); |     *length = sizeof(USBD_FS_DeviceDesc); | ||||||
|   *length = sizeof(USBD_FS_DeviceDesc); |     return USBD_FS_DeviceDesc; | ||||||
|   return USBD_FS_DeviceDesc; |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
| @ -270,11 +263,10 @@ uint8_t * USBD_FS_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) | |||||||
|   * @param  length : Pointer to data length variable |   * @param  length : Pointer to data length variable | ||||||
|   * @retval Pointer to descriptor buffer |   * @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); | ||||||
|   UNUSED(speed); |     *length = sizeof(USBD_LangIDDesc); | ||||||
|   *length = sizeof(USBD_LangIDDesc); |     return USBD_LangIDDesc; | ||||||
|   return USBD_LangIDDesc; |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
| @ -283,17 +275,13 @@ uint8_t * USBD_FS_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) | |||||||
|   * @param  length : Pointer to data length variable |   * @param  length : Pointer to data length variable | ||||||
|   * @retval Pointer to descriptor buffer |   * @retval Pointer to descriptor buffer | ||||||
|   */ |   */ | ||||||
| uint8_t * USBD_FS_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) | uint8_t* USBD_FS_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t* length) { | ||||||
| { |     if(speed == 0) { | ||||||
|   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); |         USBD_GetString((uint8_t*)USBD_PRODUCT_STRING_FS, USBD_StrDesc, length); | ||||||
|   } |     } | ||||||
|   else |     return USBD_StrDesc; | ||||||
|   { |  | ||||||
|     USBD_GetString((uint8_t *)USBD_PRODUCT_STRING_FS, USBD_StrDesc, length); |  | ||||||
|   } |  | ||||||
|   return USBD_StrDesc; |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
| @ -302,11 +290,10 @@ uint8_t * USBD_FS_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length | |||||||
|   * @param  length : Pointer to data length variable |   * @param  length : Pointer to data length variable | ||||||
|   * @retval Pointer to descriptor buffer |   * @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); | ||||||
|   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; | ||||||
|   return USBD_StrDesc; |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
| @ -315,18 +302,17 @@ uint8_t * USBD_FS_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *l | |||||||
|   * @param  length : Pointer to data length variable |   * @param  length : Pointer to data length variable | ||||||
|   * @retval Pointer to descriptor buffer |   * @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); | ||||||
|   UNUSED(speed); |     *length = USB_SIZ_STRING_SERIAL; | ||||||
|   *length = USB_SIZ_STRING_SERIAL; |  | ||||||
| 
 | 
 | ||||||
|   /* Update the serial number string descriptor with the data from the unique
 |     /* Update the serial number string descriptor with the data from the unique
 | ||||||
|    * ID */ |    * ID */ | ||||||
|   Get_SerialNum(); |     Get_SerialNum(); | ||||||
|   /* USER CODE BEGIN USBD_FS_SerialStrDescriptor */ |     /* USER CODE BEGIN USBD_FS_SerialStrDescriptor */ | ||||||
|    | 
 | ||||||
|   /* USER CODE END USBD_FS_SerialStrDescriptor */ |     /* USER CODE END USBD_FS_SerialStrDescriptor */ | ||||||
|   return (uint8_t *) USBD_StringSerial; |     return (uint8_t*)USBD_StringSerial; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
| @ -335,17 +321,13 @@ uint8_t * USBD_FS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) | |||||||
|   * @param  length : Pointer to data length variable |   * @param  length : Pointer to data length variable | ||||||
|   * @retval Pointer to descriptor buffer |   * @retval Pointer to descriptor buffer | ||||||
|   */ |   */ | ||||||
| uint8_t * USBD_FS_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) | uint8_t* USBD_FS_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t* length) { | ||||||
| { |     if(speed == USBD_SPEED_HIGH) { | ||||||
|   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); |         USBD_GetString((uint8_t*)USBD_CONFIGURATION_STRING_FS, USBD_StrDesc, length); | ||||||
|   } |     } | ||||||
|   else |     return USBD_StrDesc; | ||||||
|   { |  | ||||||
|     USBD_GetString((uint8_t *)USBD_CONFIGURATION_STRING_FS, USBD_StrDesc, length); |  | ||||||
|   } |  | ||||||
|   return USBD_StrDesc; |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
| @ -354,31 +336,26 @@ uint8_t * USBD_FS_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) | |||||||
|   * @param  length : Pointer to data length variable |   * @param  length : Pointer to data length variable | ||||||
|   * @retval Pointer to descriptor buffer |   * @retval Pointer to descriptor buffer | ||||||
|   */ |   */ | ||||||
| uint8_t * USBD_FS_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) | uint8_t* USBD_FS_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t* length) { | ||||||
| { |     if(speed == 0) { | ||||||
|   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); |         USBD_GetString((uint8_t*)USBD_INTERFACE_STRING_FS, USBD_StrDesc, length); | ||||||
|   } |     } | ||||||
|   else |     return USBD_StrDesc; | ||||||
|   { |  | ||||||
|     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 |   * @brief  Return the BOS descriptor | ||||||
|   * @param  speed : Current device speed |   * @param  speed : Current device speed | ||||||
|   * @param  length : Pointer to data length variable |   * @param  length : Pointer to data length variable | ||||||
|   * @retval Pointer to descriptor buffer |   * @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); | ||||||
|   UNUSED(speed); |     *length = sizeof(USBD_FS_BOSDesc); | ||||||
|   *length = sizeof(USBD_FS_BOSDesc); |     return (uint8_t*)USBD_FS_BOSDesc; | ||||||
|   return (uint8_t*)USBD_FS_BOSDesc; |  | ||||||
| } | } | ||||||
| #endif /* (USBD_LPM_ENABLED == 1) */ | #endif /* (USBD_LPM_ENABLED == 1) */ | ||||||
| 
 | 
 | ||||||
| @ -387,21 +364,19 @@ uint8_t * USBD_FS_USR_BOSDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) | |||||||
|   * @param  None  |   * @param  None  | ||||||
|   * @retval None |   * @retval None | ||||||
|   */ |   */ | ||||||
| static void Get_SerialNum(void) | static void Get_SerialNum(void) { | ||||||
| { |     uint32_t deviceserial0, deviceserial1, deviceserial2; | ||||||
|   uint32_t deviceserial0, deviceserial1, deviceserial2; |  | ||||||
| 
 | 
 | ||||||
|   deviceserial0 = *(uint32_t *) DEVICE_ID1; |     deviceserial0 = *(uint32_t*)DEVICE_ID1; | ||||||
|   deviceserial1 = *(uint32_t *) DEVICE_ID2; |     deviceserial1 = *(uint32_t*)DEVICE_ID2; | ||||||
|   deviceserial2 = *(uint32_t *) DEVICE_ID3; |     deviceserial2 = *(uint32_t*)DEVICE_ID3; | ||||||
| 
 | 
 | ||||||
|   deviceserial0 += deviceserial2; |     deviceserial0 += deviceserial2; | ||||||
| 
 | 
 | ||||||
|   if (deviceserial0 != 0) |     if(deviceserial0 != 0) { | ||||||
|   { |         IntToUnicode(deviceserial0, &USBD_StringSerial[2], 8); | ||||||
|     IntToUnicode(deviceserial0, &USBD_StringSerial[2], 8); |         IntToUnicode(deviceserial1, &USBD_StringSerial[18], 4); | ||||||
|     IntToUnicode(deviceserial1, &USBD_StringSerial[18], 4); |     } | ||||||
|   } |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
| @ -411,25 +386,20 @@ static void Get_SerialNum(void) | |||||||
|   * @param  len: buffer length |   * @param  len: buffer length | ||||||
|   * @retval None |   * @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; | ||||||
|   uint8_t idx = 0; |  | ||||||
| 
 | 
 | ||||||
|   for (idx = 0; idx < len; idx++) |     for(idx = 0; idx < len; idx++) { | ||||||
|   { |         if(((value >> 28)) < 0xA) { | ||||||
|     if (((value >> 28)) < 0xA) |             pbuf[2 * idx] = (value >> 28) + '0'; | ||||||
|     { |         } else { | ||||||
|       pbuf[2 * idx] = (value >> 28) + '0'; |             pbuf[2 * idx] = (value >> 28) + 'A' - 10; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         value = value << 4; | ||||||
|  | 
 | ||||||
|  |         pbuf[2 * idx + 1] = 0; | ||||||
|     } |     } | ||||||
|     else |  | ||||||
|     { |  | ||||||
|       pbuf[2 * idx] = (value >> 28) + 'A' - 10; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     value = value << 4; |  | ||||||
| 
 |  | ||||||
|     pbuf[2 * idx + 1] = 0; |  | ||||||
|   } |  | ||||||
| } | } | ||||||
| /**
 | /**
 | ||||||
|   * @} |   * @} | ||||||
|  | |||||||
| @ -25,7 +25,7 @@ | |||||||
|  * |  * | ||||||
|  * 1 tab == 4 spaces! |  * 1 tab == 4 spaces! | ||||||
|  */ |  */ | ||||||
|  /* USER CODE END Header */ | /* USER CODE END Header */ | ||||||
| 
 | 
 | ||||||
| #ifndef FREERTOS_CONFIG_H | #ifndef FREERTOS_CONFIG_H | ||||||
| #define FREERTOS_CONFIG_H | #define FREERTOS_CONFIG_H | ||||||
| @ -42,15 +42,15 @@ | |||||||
|  * See http://www.freertos.org/a00110.html
 |  * See http://www.freertos.org/a00110.html
 | ||||||
|  *----------------------------------------------------------*/ |  *----------------------------------------------------------*/ | ||||||
| 
 | 
 | ||||||
| /* USER CODE BEGIN Includes */   	       | /* USER CODE BEGIN Includes */ | ||||||
| /* Section where include file can be added */ | /* Section where include file can be added */ | ||||||
| /* USER CODE END Includes */  | /* USER CODE END Includes */ | ||||||
| 
 | 
 | ||||||
| /* Ensure definitions are only used by the compiler, and not by the assembler. */ | /* Ensure definitions are only used by the compiler, and not by the assembler. */ | ||||||
| #if defined(__ICCARM__) || defined(__CC_ARM) || defined(__GNUC__) | #if defined(__ICCARM__) || defined(__CC_ARM) || defined(__GNUC__) | ||||||
|   #include <stdint.h> | #include <stdint.h> | ||||||
|   extern uint32_t SystemCoreClock; | extern uint32_t SystemCoreClock; | ||||||
|   void xPortSysTickHandler(void); | void xPortSysTickHandler(void); | ||||||
| #endif | #endif | ||||||
| #define configUSE_PREEMPTION                     1 | #define configUSE_PREEMPTION                     1 | ||||||
| #define configSUPPORT_STATIC_ALLOCATION          1 | #define configSUPPORT_STATIC_ALLOCATION          1 | ||||||
| @ -71,37 +71,37 @@ | |||||||
| #define configNUM_THREAD_LOCAL_STORAGE_POINTERS  1 | #define configNUM_THREAD_LOCAL_STORAGE_POINTERS  1 | ||||||
| 
 | 
 | ||||||
| /* Co-routine definitions. */ | /* Co-routine definitions. */ | ||||||
| #define configUSE_CO_ROUTINES                    0 | #define configUSE_CO_ROUTINES 0 | ||||||
| #define configMAX_CO_ROUTINE_PRIORITIES          ( 2 ) | #define configMAX_CO_ROUTINE_PRIORITIES (2) | ||||||
| 
 | 
 | ||||||
| /* Software timer definitions. */ | /* Software timer definitions. */ | ||||||
| #define configUSE_TIMERS                         1 | #define configUSE_TIMERS 1 | ||||||
| #define configTIMER_TASK_PRIORITY                ( 2 ) | #define configTIMER_TASK_PRIORITY (2) | ||||||
| #define configTIMER_QUEUE_LENGTH                 10 | #define configTIMER_QUEUE_LENGTH 10 | ||||||
| #define configTIMER_TASK_STACK_DEPTH             256 | #define configTIMER_TASK_STACK_DEPTH 256 | ||||||
| 
 | 
 | ||||||
| /* Set the following definitions to 1 to include the API function, or zero
 | /* Set the following definitions to 1 to include the API function, or zero
 | ||||||
| to exclude the API function. */ | to exclude the API function. */ | ||||||
| #define INCLUDE_vTaskPrioritySet            1 | #define INCLUDE_vTaskPrioritySet 1 | ||||||
| #define INCLUDE_uxTaskPriorityGet           1 | #define INCLUDE_uxTaskPriorityGet 1 | ||||||
| #define INCLUDE_vTaskDelete                 1 | #define INCLUDE_vTaskDelete 1 | ||||||
| #define INCLUDE_vTaskCleanUpResources       0 | #define INCLUDE_vTaskCleanUpResources 0 | ||||||
| #define INCLUDE_vTaskSuspend                1 | #define INCLUDE_vTaskSuspend 1 | ||||||
| #define INCLUDE_vTaskDelayUntil             0 | #define INCLUDE_vTaskDelayUntil 0 | ||||||
| #define INCLUDE_vTaskDelay                  1 | #define INCLUDE_vTaskDelay 1 | ||||||
| #define INCLUDE_xTaskGetSchedulerState      1 | #define INCLUDE_xTaskGetSchedulerState 1 | ||||||
| 
 | 
 | ||||||
| /* Cortex-M specific definitions. */ | /* Cortex-M specific definitions. */ | ||||||
| #ifdef __NVIC_PRIO_BITS | #ifdef __NVIC_PRIO_BITS | ||||||
|  /* __BVIC_PRIO_BITS will be specified when CMSIS is being used. */ | /* __BVIC_PRIO_BITS will be specified when CMSIS is being used. */ | ||||||
|  #define configPRIO_BITS         __NVIC_PRIO_BITS | #define configPRIO_BITS __NVIC_PRIO_BITS | ||||||
| #else | #else | ||||||
|  #define configPRIO_BITS         4 | #define configPRIO_BITS 4 | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| /* The lowest interrupt priority that can be used in a call to a "set priority"
 | /* The lowest interrupt priority that can be used in a call to a "set priority"
 | ||||||
| function. */ | function. */ | ||||||
| #define configLIBRARY_LOWEST_INTERRUPT_PRIORITY   15 | #define configLIBRARY_LOWEST_INTERRUPT_PRIORITY 15 | ||||||
| 
 | 
 | ||||||
| /* The highest interrupt priority that can be used by any interrupt service
 | /* The highest interrupt priority that can be used by any interrupt service
 | ||||||
| routine that makes calls to interrupt safe FreeRTOS API functions.  DO NOT CALL | routine that makes calls to interrupt safe FreeRTOS API functions.  DO NOT CALL | ||||||
| @ -111,29 +111,36 @@ PRIORITY THAN THIS! (higher priorities are lower numeric values. */ | |||||||
| 
 | 
 | ||||||
| /* Interrupt priorities used by the kernel port layer itself.  These are generic
 | /* 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. */ | 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 !!!!
 | /* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!!
 | ||||||
| See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */
 | 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
 | /* Normal assert() semantics without relying on the provision of an assert.h
 | ||||||
| header file. */ | header file. */ | ||||||
| /* USER CODE BEGIN 1 */ | /* 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 */ | /* USER CODE END 1 */ | ||||||
| 
 | 
 | ||||||
| /* Definitions that map the FreeRTOS port interrupt handlers to their CMSIS
 | /* Definitions that map the FreeRTOS port interrupt handlers to their CMSIS
 | ||||||
| standard names. */ | standard names. */ | ||||||
| #define vPortSVCHandler    SVC_Handler | #define vPortSVCHandler SVC_Handler | ||||||
| #define xPortPendSVHandler PendSV_Handler | #define xPortPendSVHandler PendSV_Handler | ||||||
| 
 | 
 | ||||||
| /* IMPORTANT: This define is commented when used with STM32Cube firmware, when the timebase source is SysTick,
 | /* IMPORTANT: This define is commented when used with STM32Cube firmware, when the timebase source is SysTick,
 | ||||||
|               to prevent overwriting SysTick_Handler defined within STM32Cube HAL */ |               to prevent overwriting SysTick_Handler defined within STM32Cube HAL */ | ||||||
|   | 
 | ||||||
| /* #define xPortSysTickHandler SysTick_Handler */ | /* #define xPortSysTickHandler SysTick_Handler */ | ||||||
| 
 | 
 | ||||||
| /* USER CODE BEGIN Defines */   	       | /* USER CODE BEGIN Defines */ | ||||||
| /* Section where parameter definitions can be added (for instance, to override default ones in FreeRTOS.h) */ | /* Section where parameter definitions can be added (for instance, to override default ones in FreeRTOS.h) */ | ||||||
| /* USER CODE END Defines */  | /* USER CODE END Defines */ | ||||||
| 
 | 
 | ||||||
| #endif /* FREERTOS_CONFIG_H */ | #endif /* FREERTOS_CONFIG_H */ | ||||||
|  | |||||||
| @ -9,11 +9,7 @@ GPIO and HAL implementations | |||||||
| #include <stdbool.h> | #include <stdbool.h> | ||||||
| #include "main.h" | #include "main.h" | ||||||
| 
 | 
 | ||||||
| typedef enum { | typedef enum { GpioModeInput, GpioModeOutput, GpioModeOpenDrain } GpioMode; | ||||||
|     GpioModeInput, |  | ||||||
|     GpioModeOutput, |  | ||||||
|     GpioModeOpenDrain |  | ||||||
| } GpioMode; |  | ||||||
| 
 | 
 | ||||||
| typedef struct { | typedef struct { | ||||||
|     GPIO_TypeDef* port; |     GPIO_TypeDef* port; | ||||||
| @ -50,7 +46,8 @@ inline void app_tim_ic_init(bool both) { | |||||||
|     HAL_TIM_OC_Stop(&htim8, TIM_CHANNEL_2); |     HAL_TIM_OC_Stop(&htim8, TIM_CHANNEL_2); | ||||||
| 
 | 
 | ||||||
|     TIM_IC_InitTypeDef sConfigIC = {0}; |     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.ICSelection = TIM_ICSELECTION_DIRECTTI; | ||||||
|     sConfigIC.ICPrescaler = TIM_ICPSC_DIV1; |     sConfigIC.ICPrescaler = TIM_ICPSC_DIV1; | ||||||
|     sConfigIC.ICFilter = 0; |     sConfigIC.ICFilter = 0; | ||||||
|  | |||||||
| @ -38,10 +38,7 @@ extern "C" { | |||||||
| /* Exported types ------------------------------------------------------------*/ | /* Exported types ------------------------------------------------------------*/ | ||||||
| /* USER CODE BEGIN ET */ | /* USER CODE BEGIN ET */ | ||||||
| 
 | 
 | ||||||
| typedef enum { | typedef enum { TimerEventInputCapture, TimerEventEndOfPulse } TimerEvent; | ||||||
|   TimerEventInputCapture, |  | ||||||
|   TimerEventEndOfPulse |  | ||||||
| } TimerEvent; |  | ||||||
| 
 | 
 | ||||||
| /* USER CODE END ET */ | /* USER CODE END ET */ | ||||||
| 
 | 
 | ||||||
| @ -55,14 +52,14 @@ typedef enum { | |||||||
| 
 | 
 | ||||||
| /* USER CODE END EM */ | /* USER CODE END EM */ | ||||||
| 
 | 
 | ||||||
| void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim); | void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim); | ||||||
| 
 | 
 | ||||||
| /* Exported functions prototypes ---------------------------------------------*/ | /* Exported functions prototypes ---------------------------------------------*/ | ||||||
| void Error_Handler(void); | void Error_Handler(void); | ||||||
| 
 | 
 | ||||||
| /* USER CODE BEGIN EFP */ | /* 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 */ | /* 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_GPIO_Port RFID_OUT_GPIO_Port | ||||||
| #define EM_PIN_Pin RFID_OUT_Pin | #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 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
 | //2 main, 5 remote, 3 M16
 | ||||||
| #define GDO2     GpioPin{.port = NULL, .pin = 0} | #define GDO2                   \ | ||||||
| #define GDO0     GpioPin{.port = CC1101_G0_GPIO_Port, .pin = CC1101_G0_Pin} |     GpioPin {                  \ | ||||||
|  |         .port = NULL, .pin = 0 \ | ||||||
|  |     } | ||||||
|  | #define GDO0                                              \ | ||||||
|  |     GpioPin {                                             \ | ||||||
|  |         .port = CC1101_G0_GPIO_Port, .pin = CC1101_G0_Pin \ | ||||||
|  |     } | ||||||
| 
 | 
 | ||||||
| /* USER CODE END Private defines */ | /* USER CODE END Private defines */ | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -30,14 +30,14 @@ | |||||||
|   * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |   * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||||
|   * |   * | ||||||
|   ****************************************************************************** |   ****************************************************************************** | ||||||
|   */  |   */ | ||||||
| 
 | 
 | ||||||
| /* Define to prevent recursive inclusion -------------------------------------*/ | /* Define to prevent recursive inclusion -------------------------------------*/ | ||||||
| #ifndef __STM32L4xx_HAL_CONF_H | #ifndef __STM32L4xx_HAL_CONF_H | ||||||
| #define __STM32L4xx_HAL_CONF_H | #define __STM32L4xx_HAL_CONF_H | ||||||
| 
 | 
 | ||||||
| #ifdef __cplusplus | #ifdef __cplusplus | ||||||
|  extern "C" { | extern "C" { | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| /* Exported types ------------------------------------------------------------*/ | /* Exported types ------------------------------------------------------------*/ | ||||||
| @ -48,7 +48,7 @@ | |||||||
|   * @brief This is the list of modules to be used in the HAL driver  |   * @brief This is the list of modules to be used in the HAL driver  | ||||||
|   */ |   */ | ||||||
| 
 | 
 | ||||||
| #define HAL_MODULE_ENABLED   | #define HAL_MODULE_ENABLED | ||||||
| #define HAL_ADC_MODULE_ENABLED | #define HAL_ADC_MODULE_ENABLED | ||||||
| /*#define HAL_CRYP_MODULE_ENABLED   */ | /*#define HAL_CRYP_MODULE_ENABLED   */ | ||||||
| /*#define HAL_CAN_MODULE_ENABLED   */ | /*#define HAL_CAN_MODULE_ENABLED   */ | ||||||
| @ -95,7 +95,7 @@ | |||||||
| /*#define HAL_WWDG_MODULE_ENABLED   */ | /*#define HAL_WWDG_MODULE_ENABLED   */ | ||||||
| /*#define HAL_EXTI_MODULE_ENABLED   */ | /*#define HAL_EXTI_MODULE_ENABLED   */ | ||||||
| #define HAL_GPIO_MODULE_ENABLED | #define HAL_GPIO_MODULE_ENABLED | ||||||
| #define HAL_EXTI_MODULE_ENABLED  | #define HAL_EXTI_MODULE_ENABLED | ||||||
| #define HAL_I2C_MODULE_ENABLED | #define HAL_I2C_MODULE_ENABLED | ||||||
| #define HAL_DMA_MODULE_ENABLED | #define HAL_DMA_MODULE_ENABLED | ||||||
| #define HAL_RCC_MODULE_ENABLED | #define HAL_RCC_MODULE_ENABLED | ||||||
| @ -109,28 +109,28 @@ | |||||||
|   *        This value is used by the RCC HAL module to compute the system frequency |   *        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).   |   *        (when HSE is used as system clock source, directly or through the PLL).   | ||||||
|   */ |   */ | ||||||
| #if !defined  (HSE_VALUE)  | #if !defined(HSE_VALUE) | ||||||
|   #define HSE_VALUE    ((uint32_t)16000000U) /*!< Value of the External oscillator in Hz */ | #define HSE_VALUE ((uint32_t)16000000U) /*!< Value of the External oscillator in Hz */ | ||||||
| #endif /* HSE_VALUE */ | #endif /* HSE_VALUE */ | ||||||
| 
 | 
 | ||||||
| #if !defined  (HSE_STARTUP_TIMEOUT) | #if !defined(HSE_STARTUP_TIMEOUT) | ||||||
|   #define HSE_STARTUP_TIMEOUT    ((uint32_t)100U)   /*!< Time out for HSE start up, in ms */ | #define HSE_STARTUP_TIMEOUT ((uint32_t)100U) /*!< Time out for HSE start up, in ms */ | ||||||
| #endif /* HSE_STARTUP_TIMEOUT */ | #endif /* HSE_STARTUP_TIMEOUT */ | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
|   * @brief Internal Multiple Speed oscillator (MSI) default value. |   * @brief Internal Multiple Speed oscillator (MSI) default value. | ||||||
|   *        This value is the default MSI range value after Reset. |   *        This value is the default MSI range value after Reset. | ||||||
|   */ |   */ | ||||||
| #if !defined  (MSI_VALUE) | #if !defined(MSI_VALUE) | ||||||
|   #define MSI_VALUE    ((uint32_t)4000000U) /*!< Value of the Internal oscillator in Hz*/ | #define MSI_VALUE ((uint32_t)4000000U) /*!< Value of the Internal oscillator in Hz*/ | ||||||
| #endif /* MSI_VALUE */ | #endif /* MSI_VALUE */ | ||||||
| /**
 | /**
 | ||||||
|   * @brief Internal High Speed oscillator (HSI) value. |   * @brief Internal High Speed oscillator (HSI) value. | ||||||
|   *        This value is used by the RCC HAL module to compute the system frequency |   *        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).  |   *        (when HSI is used as system clock source, directly or through the PLL).  | ||||||
|   */ |   */ | ||||||
| #if !defined  (HSI_VALUE) | #if !defined(HSI_VALUE) | ||||||
|   #define HSI_VALUE    ((uint32_t)16000000U) /*!< Value of the Internal oscillator in Hz*/ | #define HSI_VALUE ((uint32_t)16000000U) /*!< Value of the Internal oscillator in Hz*/ | ||||||
| #endif /* HSI_VALUE */ | #endif /* HSI_VALUE */ | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
| @ -140,17 +140,18 @@ | |||||||
|   *        When the CRS is not used, the HSI48 RC oscillator runs on it default frequency |   *        When the CRS is not used, the HSI48 RC oscillator runs on it default frequency | ||||||
|   *        which is subject to manufacturing process variations. |   *        which is subject to manufacturing process variations. | ||||||
|   */ |   */ | ||||||
| #if !defined  (HSI48_VALUE)  | #if !defined(HSI48_VALUE) | ||||||
|  #define HSI48_VALUE   ((uint32_t)48000000U) /*!< Value of the Internal High Speed oscillator for USB FS/SDMMC/RNG in Hz. | #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.*/ |                                               The real value my vary depending on manufacturing process variations.*/ | ||||||
| #endif /* HSI48_VALUE */ | #endif /* HSI48_VALUE */ | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
|   * @brief Internal Low Speed oscillator (LSI) value. |   * @brief Internal Low Speed oscillator (LSI) value. | ||||||
|   */ |   */ | ||||||
| #if !defined  (LSI_VALUE)  | #if !defined(LSI_VALUE) | ||||||
|  #define LSI_VALUE  ((uint32_t)32000U)       /*!< LSI Typical Value in Hz*/ | #define LSI_VALUE ((uint32_t)32000U) /*!< LSI Typical Value in Hz*/ | ||||||
| #endif /* LSI_VALUE */                      /*!< Value of the Internal Low Speed oscillator in Hz | #endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz | ||||||
|                                              The real value may vary depending on the variations |                                              The real value may vary depending on the variations | ||||||
|                                              in voltage and temperature.*/ |                                              in voltage and temperature.*/ | ||||||
| 
 | 
 | ||||||
| @ -158,12 +159,12 @@ | |||||||
|   * @brief External Low Speed oscillator (LSE) value. |   * @brief External Low Speed oscillator (LSE) value. | ||||||
|   *        This value is used by the UART, RTC HAL module to compute the system frequency |   *        This value is used by the UART, RTC HAL module to compute the system frequency | ||||||
|   */ |   */ | ||||||
| #if !defined  (LSE_VALUE) | #if !defined(LSE_VALUE) | ||||||
|   #define LSE_VALUE    ((uint32_t)32768U) /*!< Value of the External oscillator in Hz*/ | #define LSE_VALUE ((uint32_t)32768U) /*!< Value of the External oscillator in Hz*/ | ||||||
| #endif /* LSE_VALUE */ | #endif /* LSE_VALUE */ | ||||||
| 
 | 
 | ||||||
| #if !defined  (LSE_STARTUP_TIMEOUT) | #if !defined(LSE_STARTUP_TIMEOUT) | ||||||
|   #define LSE_STARTUP_TIMEOUT    ((uint32_t)5000U)   /*!< Time out for LSE start up, in ms */ | #define LSE_STARTUP_TIMEOUT ((uint32_t)5000U) /*!< Time out for LSE start up, in ms */ | ||||||
| #endif /* HSE_STARTUP_TIMEOUT */ | #endif /* HSE_STARTUP_TIMEOUT */ | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
| @ -171,8 +172,9 @@ | |||||||
|   *        This value is used by the RCC HAL module to compute the SAI1 & SAI2 clock source  |   *        This value is used by the RCC HAL module to compute the SAI1 & SAI2 clock source  | ||||||
|   *        frequency. |   *        frequency. | ||||||
|   */ |   */ | ||||||
| #if !defined  (EXTERNAL_SAI1_CLOCK_VALUE) | #if !defined(EXTERNAL_SAI1_CLOCK_VALUE) | ||||||
|   #define EXTERNAL_SAI1_CLOCK_VALUE    ((uint32_t)2097000U) /*!< Value of the SAI1 External clock source in Hz*/ | #define EXTERNAL_SAI1_CLOCK_VALUE \ | ||||||
|  |     ((uint32_t)2097000U) /*!< Value of the SAI1 External clock source in Hz*/ | ||||||
| #endif /* EXTERNAL_SAI1_CLOCK_VALUE */ | #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  |   *        This value is used by the RCC HAL module to compute the SAI1 & SAI2 clock source  | ||||||
|   *        frequency. |   *        frequency. | ||||||
|   */ |   */ | ||||||
| #if !defined  (EXTERNAL_SAI2_CLOCK_VALUE) | #if !defined(EXTERNAL_SAI2_CLOCK_VALUE) | ||||||
|   #define EXTERNAL_SAI2_CLOCK_VALUE    ((uint32_t)2097000U) /*!< Value of the SAI2 External clock source in Hz*/ | #define EXTERNAL_SAI2_CLOCK_VALUE \ | ||||||
|  |     ((uint32_t)2097000U) /*!< Value of the SAI2 External clock source in Hz*/ | ||||||
| #endif /* EXTERNAL_SAI2_CLOCK_VALUE */ | #endif /* EXTERNAL_SAI2_CLOCK_VALUE */ | ||||||
| 
 | 
 | ||||||
| /* Tip: To avoid modifying this file each time you need to use different HSE,
 | /* Tip: To avoid modifying this file each time you need to use different HSE,
 | ||||||
| @ -190,14 +193,14 @@ | |||||||
| /* ########################### System Configuration ######################### */ | /* ########################### System Configuration ######################### */ | ||||||
| /**
 | /**
 | ||||||
|   * @brief This is the HAL system configuration section |   * @brief This is the HAL system configuration section | ||||||
|   */      |   */ | ||||||
|    | 
 | ||||||
| #define  VDD_VALUE					  ((uint32_t)3300U) /*!< Value of VDD in mv */            | #define VDD_VALUE ((uint32_t)3300U) /*!< Value of VDD in mv */ | ||||||
| #define  TICK_INT_PRIORITY            ((uint32_t)15U)    /*!< tick interrupt priority */             | #define TICK_INT_PRIORITY ((uint32_t)15U) /*!< tick interrupt priority */ | ||||||
| #define  USE_RTOS                     0U      | #define USE_RTOS 0U | ||||||
| #define  PREFETCH_ENABLE              1U | #define PREFETCH_ENABLE 1U | ||||||
| #define  INSTRUCTION_CACHE_ENABLE     1U | #define INSTRUCTION_CACHE_ENABLE 1U | ||||||
| #define  DATA_CACHE_ENABLE            1U | #define DATA_CACHE_ENABLE 1U | ||||||
| 
 | 
 | ||||||
| /* ########################## Assert Selection ############################## */ | /* ########################## Assert Selection ############################## */ | ||||||
| /**
 | /**
 | ||||||
| @ -213,7 +216,7 @@ | |||||||
|  * Deactivated: CRC code cleaned from driver |  * Deactivated: CRC code cleaned from driver | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| #define USE_SPI_CRC                   0U | #define USE_SPI_CRC 0U | ||||||
| 
 | 
 | ||||||
| /* Includes ------------------------------------------------------------------*/ | /* Includes ------------------------------------------------------------------*/ | ||||||
| /**
 | /**
 | ||||||
| @ -221,201 +224,201 @@ | |||||||
|   */ |   */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_RCC_MODULE_ENABLED | #ifdef HAL_RCC_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_rcc.h" | #include "stm32l4xx_hal_rcc.h" | ||||||
|   #include "stm32l4xx_hal_rcc_ex.h" | #include "stm32l4xx_hal_rcc_ex.h" | ||||||
| #endif /* HAL_RCC_MODULE_ENABLED */ | #endif /* HAL_RCC_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_EXTI_MODULE_ENABLED | #ifdef HAL_EXTI_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_exti.h" | #include "stm32l4xx_hal_exti.h" | ||||||
| #endif /* HAL_EXTI_MODULE_ENABLED */ | #endif /* HAL_EXTI_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_GPIO_MODULE_ENABLED | #ifdef HAL_GPIO_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_gpio.h" | #include "stm32l4xx_hal_gpio.h" | ||||||
| #endif /* HAL_GPIO_MODULE_ENABLED */ | #endif /* HAL_GPIO_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_DMA_MODULE_ENABLED | #ifdef HAL_DMA_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_dma.h" | #include "stm32l4xx_hal_dma.h" | ||||||
|   #include "stm32l4xx_hal_dma_ex.h" | #include "stm32l4xx_hal_dma_ex.h" | ||||||
| #endif /* HAL_DMA_MODULE_ENABLED */ | #endif /* HAL_DMA_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_DFSDM_MODULE_ENABLED | #ifdef HAL_DFSDM_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_dfsdm.h" | #include "stm32l4xx_hal_dfsdm.h" | ||||||
| #endif /* HAL_DFSDM_MODULE_ENABLED */ | #endif /* HAL_DFSDM_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_CORTEX_MODULE_ENABLED | #ifdef HAL_CORTEX_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_cortex.h" | #include "stm32l4xx_hal_cortex.h" | ||||||
| #endif /* HAL_CORTEX_MODULE_ENABLED */ | #endif /* HAL_CORTEX_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_ADC_MODULE_ENABLED | #ifdef HAL_ADC_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_adc.h" | #include "stm32l4xx_hal_adc.h" | ||||||
| #endif /* HAL_ADC_MODULE_ENABLED */ | #endif /* HAL_ADC_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_CAN_MODULE_ENABLED | #ifdef HAL_CAN_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_can.h" | #include "stm32l4xx_hal_can.h" | ||||||
| #endif /* HAL_CAN_MODULE_ENABLED */ | #endif /* HAL_CAN_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_COMP_MODULE_ENABLED | #ifdef HAL_COMP_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_comp.h" | #include "stm32l4xx_hal_comp.h" | ||||||
| #endif /* HAL_COMP_MODULE_ENABLED */ | #endif /* HAL_COMP_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_CRC_MODULE_ENABLED | #ifdef HAL_CRC_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_crc.h" | #include "stm32l4xx_hal_crc.h" | ||||||
| #endif /* HAL_CRC_MODULE_ENABLED */ | #endif /* HAL_CRC_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_CRYP_MODULE_ENABLED | #ifdef HAL_CRYP_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_cryp.h" | #include "stm32l4xx_hal_cryp.h" | ||||||
| #endif /* HAL_CRYP_MODULE_ENABLED */ | #endif /* HAL_CRYP_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_DAC_MODULE_ENABLED | #ifdef HAL_DAC_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_dac.h" | #include "stm32l4xx_hal_dac.h" | ||||||
| #endif /* HAL_DAC_MODULE_ENABLED */ | #endif /* HAL_DAC_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_DCMI_MODULE_ENABLED | #ifdef HAL_DCMI_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_dcmi.h" | #include "stm32l4xx_hal_dcmi.h" | ||||||
| #endif /* HAL_DCMI_MODULE_ENABLED */ | #endif /* HAL_DCMI_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_DMA2D_MODULE_ENABLED | #ifdef HAL_DMA2D_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_dma2d.h" | #include "stm32l4xx_hal_dma2d.h" | ||||||
| #endif /* HAL_DMA2D_MODULE_ENABLED */ | #endif /* HAL_DMA2D_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_DSI_MODULE_ENABLED | #ifdef HAL_DSI_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_dsi.h" | #include "stm32l4xx_hal_dsi.h" | ||||||
| #endif /* HAL_DSI_MODULE_ENABLED */ | #endif /* HAL_DSI_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_FIREWALL_MODULE_ENABLED | #ifdef HAL_FIREWALL_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_firewall.h" | #include "stm32l4xx_hal_firewall.h" | ||||||
| #endif /* HAL_FIREWALL_MODULE_ENABLED */ | #endif /* HAL_FIREWALL_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_FLASH_MODULE_ENABLED | #ifdef HAL_FLASH_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_flash.h" | #include "stm32l4xx_hal_flash.h" | ||||||
| #endif /* HAL_FLASH_MODULE_ENABLED */ | #endif /* HAL_FLASH_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_HASH_MODULE_ENABLED | #ifdef HAL_HASH_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_hash.h" | #include "stm32l4xx_hal_hash.h" | ||||||
| #endif /* HAL_HASH_MODULE_ENABLED */ | #endif /* HAL_HASH_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_SRAM_MODULE_ENABLED | #ifdef HAL_SRAM_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_sram.h" | #include "stm32l4xx_hal_sram.h" | ||||||
| #endif /* HAL_SRAM_MODULE_ENABLED */ | #endif /* HAL_SRAM_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_MMC_MODULE_ENABLED | #ifdef HAL_MMC_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_mmc.h" | #include "stm32l4xx_hal_mmc.h" | ||||||
| #endif /* HAL_MMC_MODULE_ENABLED */ | #endif /* HAL_MMC_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_NOR_MODULE_ENABLED | #ifdef HAL_NOR_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_nor.h" | #include "stm32l4xx_hal_nor.h" | ||||||
| #endif /* HAL_NOR_MODULE_ENABLED */ | #endif /* HAL_NOR_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_NAND_MODULE_ENABLED | #ifdef HAL_NAND_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_nand.h" | #include "stm32l4xx_hal_nand.h" | ||||||
| #endif /* HAL_NAND_MODULE_ENABLED */ | #endif /* HAL_NAND_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_I2C_MODULE_ENABLED | #ifdef HAL_I2C_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_i2c.h" | #include "stm32l4xx_hal_i2c.h" | ||||||
| #endif /* HAL_I2C_MODULE_ENABLED */ | #endif /* HAL_I2C_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_IWDG_MODULE_ENABLED | #ifdef HAL_IWDG_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_iwdg.h" | #include "stm32l4xx_hal_iwdg.h" | ||||||
| #endif /* HAL_IWDG_MODULE_ENABLED */ | #endif /* HAL_IWDG_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_LCD_MODULE_ENABLED | #ifdef HAL_LCD_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_lcd.h" | #include "stm32l4xx_hal_lcd.h" | ||||||
| #endif /* HAL_LCD_MODULE_ENABLED */ | #endif /* HAL_LCD_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_LPTIM_MODULE_ENABLED | #ifdef HAL_LPTIM_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_lptim.h" | #include "stm32l4xx_hal_lptim.h" | ||||||
| #endif /* HAL_LPTIM_MODULE_ENABLED */ | #endif /* HAL_LPTIM_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_LTDC_MODULE_ENABLED | #ifdef HAL_LTDC_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_ltdc.h" | #include "stm32l4xx_hal_ltdc.h" | ||||||
| #endif /* HAL_LTDC_MODULE_ENABLED */ | #endif /* HAL_LTDC_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_OPAMP_MODULE_ENABLED | #ifdef HAL_OPAMP_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_opamp.h" | #include "stm32l4xx_hal_opamp.h" | ||||||
| #endif /* HAL_OPAMP_MODULE_ENABLED */ | #endif /* HAL_OPAMP_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_OSPI_MODULE_ENABLED | #ifdef HAL_OSPI_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_ospi.h" | #include "stm32l4xx_hal_ospi.h" | ||||||
| #endif /* HAL_OSPI_MODULE_ENABLED */ | #endif /* HAL_OSPI_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_PWR_MODULE_ENABLED | #ifdef HAL_PWR_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_pwr.h" | #include "stm32l4xx_hal_pwr.h" | ||||||
| #endif /* HAL_PWR_MODULE_ENABLED */ | #endif /* HAL_PWR_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_QSPI_MODULE_ENABLED | #ifdef HAL_QSPI_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_qspi.h" | #include "stm32l4xx_hal_qspi.h" | ||||||
| #endif /* HAL_QSPI_MODULE_ENABLED */ | #endif /* HAL_QSPI_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_RNG_MODULE_ENABLED | #ifdef HAL_RNG_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_rng.h" | #include "stm32l4xx_hal_rng.h" | ||||||
| #endif /* HAL_RNG_MODULE_ENABLED */ | #endif /* HAL_RNG_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_RTC_MODULE_ENABLED | #ifdef HAL_RTC_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_rtc.h" | #include "stm32l4xx_hal_rtc.h" | ||||||
| #endif /* HAL_RTC_MODULE_ENABLED */ | #endif /* HAL_RTC_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_SAI_MODULE_ENABLED | #ifdef HAL_SAI_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_sai.h" | #include "stm32l4xx_hal_sai.h" | ||||||
| #endif /* HAL_SAI_MODULE_ENABLED */ | #endif /* HAL_SAI_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_SD_MODULE_ENABLED | #ifdef HAL_SD_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_sd.h" | #include "stm32l4xx_hal_sd.h" | ||||||
| #endif /* HAL_SD_MODULE_ENABLED */ | #endif /* HAL_SD_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_SMBUS_MODULE_ENABLED | #ifdef HAL_SMBUS_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_smbus.h" | #include "stm32l4xx_hal_smbus.h" | ||||||
| #endif /* HAL_SMBUS_MODULE_ENABLED */ | #endif /* HAL_SMBUS_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_SPI_MODULE_ENABLED | #ifdef HAL_SPI_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_spi.h" | #include "stm32l4xx_hal_spi.h" | ||||||
| #endif /* HAL_SPI_MODULE_ENABLED */ | #endif /* HAL_SPI_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_SWPMI_MODULE_ENABLED | #ifdef HAL_SWPMI_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_swpmi.h" | #include "stm32l4xx_hal_swpmi.h" | ||||||
| #endif /* HAL_SWPMI_MODULE_ENABLED */ | #endif /* HAL_SWPMI_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_TIM_MODULE_ENABLED | #ifdef HAL_TIM_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_tim.h" | #include "stm32l4xx_hal_tim.h" | ||||||
| #endif /* HAL_TIM_MODULE_ENABLED */ | #endif /* HAL_TIM_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_TSC_MODULE_ENABLED | #ifdef HAL_TSC_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_tsc.h" | #include "stm32l4xx_hal_tsc.h" | ||||||
| #endif /* HAL_TSC_MODULE_ENABLED */ | #endif /* HAL_TSC_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_UART_MODULE_ENABLED | #ifdef HAL_UART_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_uart.h" | #include "stm32l4xx_hal_uart.h" | ||||||
| #endif /* HAL_UART_MODULE_ENABLED */ | #endif /* HAL_UART_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_USART_MODULE_ENABLED | #ifdef HAL_USART_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_usart.h" | #include "stm32l4xx_hal_usart.h" | ||||||
| #endif /* HAL_USART_MODULE_ENABLED */ | #endif /* HAL_USART_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_IRDA_MODULE_ENABLED | #ifdef HAL_IRDA_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_irda.h" | #include "stm32l4xx_hal_irda.h" | ||||||
| #endif /* HAL_IRDA_MODULE_ENABLED */ | #endif /* HAL_IRDA_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_SMARTCARD_MODULE_ENABLED | #ifdef HAL_SMARTCARD_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_smartcard.h" | #include "stm32l4xx_hal_smartcard.h" | ||||||
| #endif /* HAL_SMARTCARD_MODULE_ENABLED */ | #endif /* HAL_SMARTCARD_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_WWDG_MODULE_ENABLED | #ifdef HAL_WWDG_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_wwdg.h" | #include "stm32l4xx_hal_wwdg.h" | ||||||
| #endif /* HAL_WWDG_MODULE_ENABLED */ | #endif /* HAL_WWDG_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_PCD_MODULE_ENABLED | #ifdef HAL_PCD_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_pcd.h" | #include "stm32l4xx_hal_pcd.h" | ||||||
| #endif /* HAL_PCD_MODULE_ENABLED */ | #endif /* HAL_PCD_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_HCD_MODULE_ENABLED | #ifdef HAL_HCD_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_hcd.h" | #include "stm32l4xx_hal_hcd.h" | ||||||
| #endif /* HAL_HCD_MODULE_ENABLED */ | #endif /* HAL_HCD_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| #ifdef HAL_GFXMMU_MODULE_ENABLED | #ifdef HAL_GFXMMU_MODULE_ENABLED | ||||||
|   #include "stm32l4xx_hal_gfxmmu.h" | #include "stm32l4xx_hal_gfxmmu.h" | ||||||
| #endif /* HAL_GFXMMU_MODULE_ENABLED */ | #endif /* HAL_GFXMMU_MODULE_ENABLED */ | ||||||
| 
 | 
 | ||||||
| /* Exported macro ------------------------------------------------------------*/ | /* Exported macro ------------------------------------------------------------*/ | ||||||
| #ifdef  USE_FULL_ASSERT | #ifdef USE_FULL_ASSERT | ||||||
| /**
 | /**
 | ||||||
|   * @brief  The assert_param macro is used for function's parameters check. |   * @brief  The assert_param macro is used for function's parameters check. | ||||||
|   * @param  expr: If expr is false, it calls assert_failed function |   * @param  expr: If expr is false, it calls assert_failed function | ||||||
| @ -424,11 +427,11 @@ | |||||||
|   *         If expr is true, it returns no value. |   *         If expr is true, it returns no value. | ||||||
|   * @retval None |   * @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 ------------------------------------------------------- */ | /* Exported functions ------------------------------------------------------- */ | ||||||
|   void assert_failed(char *file, uint32_t line); | void assert_failed(char* file, uint32_t line); | ||||||
| #else | #else | ||||||
|   #define assert_param(expr) ((void)0U) | #define assert_param(expr) ((void)0U) | ||||||
| #endif /* USE_FULL_ASSERT */ | #endif /* USE_FULL_ASSERT */ | ||||||
| 
 | 
 | ||||||
| #ifdef __cplusplus | #ifdef __cplusplus | ||||||
|  | |||||||
| @ -23,8 +23,8 @@ | |||||||
| #define __STM32L4xx_IT_H | #define __STM32L4xx_IT_H | ||||||
| 
 | 
 | ||||||
| #ifdef __cplusplus | #ifdef __cplusplus | ||||||
|  extern "C" { | extern "C" { | ||||||
| #endif  | #endif | ||||||
| 
 | 
 | ||||||
| /* Private includes ----------------------------------------------------------*/ | /* Private includes ----------------------------------------------------------*/ | ||||||
| /* USER CODE BEGIN Includes */ | /* USER CODE BEGIN Includes */ | ||||||
|  | |||||||
| @ -24,7 +24,7 @@ | |||||||
| #define __USB_DEVICE__H__ | #define __USB_DEVICE__H__ | ||||||
| 
 | 
 | ||||||
| #ifdef __cplusplus | #ifdef __cplusplus | ||||||
|  extern "C" { | extern "C" { | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| /* Includes ------------------------------------------------------------------*/ | /* Includes ------------------------------------------------------------------*/ | ||||||
|  | |||||||
| @ -24,7 +24,7 @@ | |||||||
| #define __USBD_CDC_IF_H__ | #define __USBD_CDC_IF_H__ | ||||||
| 
 | 
 | ||||||
| #ifdef __cplusplus | #ifdef __cplusplus | ||||||
|  extern "C" { | extern "C" { | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| /* Includes ------------------------------------------------------------------*/ | /* Includes ------------------------------------------------------------------*/ | ||||||
| @ -38,11 +38,11 @@ | |||||||
|   * @brief For Usb device. |   * @brief For Usb device. | ||||||
|   * @{ |   * @{ | ||||||
|   */ |   */ | ||||||
|    | 
 | ||||||
| /** @defgroup USBD_CDC_IF USBD_CDC_IF
 | /** @defgroup USBD_CDC_IF USBD_CDC_IF
 | ||||||
|   * @brief Usb VCP device module |   * @brief Usb VCP device module | ||||||
|   * @{ |   * @{ | ||||||
|   */  |   */ | ||||||
| 
 | 
 | ||||||
| /** @defgroup USBD_CDC_IF_Exported_Defines USBD_CDC_IF_Exported_Defines
 | /** @defgroup USBD_CDC_IF_Exported_Defines USBD_CDC_IF_Exported_Defines
 | ||||||
|   * @brief Defines. |   * @brief Defines. | ||||||
|  | |||||||
| @ -24,7 +24,7 @@ | |||||||
| #define __USBD_CONF__H__ | #define __USBD_CONF__H__ | ||||||
| 
 | 
 | ||||||
| #ifdef __cplusplus | #ifdef __cplusplus | ||||||
|  extern "C" { | extern "C" { | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| /* Includes ------------------------------------------------------------------*/ | /* Includes ------------------------------------------------------------------*/ | ||||||
| @ -64,21 +64,21 @@ | |||||||
|   */ |   */ | ||||||
| 
 | 
 | ||||||
| /*---------- -----------*/ | /*---------- -----------*/ | ||||||
| #define USBD_MAX_NUM_INTERFACES     1U | #define USBD_MAX_NUM_INTERFACES 1U | ||||||
| /*---------- -----------*/ | /*---------- -----------*/ | ||||||
| #define USBD_MAX_NUM_CONFIGURATION     1U | #define USBD_MAX_NUM_CONFIGURATION 1U | ||||||
| /*---------- -----------*/ | /*---------- -----------*/ | ||||||
| #define USBD_MAX_STR_DESC_SIZ     512U | #define USBD_MAX_STR_DESC_SIZ 512U | ||||||
| /*---------- -----------*/ | /*---------- -----------*/ | ||||||
| #define USBD_DEBUG_LEVEL     0U | #define USBD_DEBUG_LEVEL 0U | ||||||
| /*---------- -----------*/ | /*---------- -----------*/ | ||||||
| #define USBD_LPM_ENABLED     1U | #define USBD_LPM_ENABLED 1U | ||||||
| /*---------- -----------*/ | /*---------- -----------*/ | ||||||
| #define USBD_SELF_POWERED     1U | #define USBD_SELF_POWERED 1U | ||||||
| 
 | 
 | ||||||
| /****************************************/ | /****************************************/ | ||||||
| /* #define for FS and HS identification */ | /* #define for FS and HS identification */ | ||||||
| #define DEVICE_FS 		0 | #define DEVICE_FS 0 | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
|   * @} |   * @} | ||||||
| @ -92,42 +92,45 @@ | |||||||
| /* Memory management macros */ | /* Memory management macros */ | ||||||
| 
 | 
 | ||||||
| /** Alias for memory allocation. */ | /** Alias for memory allocation. */ | ||||||
| #define USBD_malloc         (uint32_t *)USBD_static_malloc | #define USBD_malloc (uint32_t*)USBD_static_malloc | ||||||
| 
 | 
 | ||||||
| /** Alias for memory release. */ | /** Alias for memory release. */ | ||||||
| #define USBD_free           USBD_static_free | #define USBD_free USBD_static_free | ||||||
| 
 | 
 | ||||||
| /** Alias for memory set. */ | /** Alias for memory set. */ | ||||||
| #define USBD_memset         /* Not used */ | #define USBD_memset /* Not used */ | ||||||
| 
 | 
 | ||||||
| /** Alias for memory copy. */ | /** Alias for memory copy. */ | ||||||
| #define USBD_memcpy         /* Not used */ | #define USBD_memcpy /* Not used */ | ||||||
| 
 | 
 | ||||||
| /** Alias for delay. */ | /** Alias for delay. */ | ||||||
| #define USBD_Delay          HAL_Delay | #define USBD_Delay HAL_Delay | ||||||
| 
 | 
 | ||||||
| /* DEBUG macros */ | /* DEBUG macros */ | ||||||
| 
 | 
 | ||||||
| #if (USBD_DEBUG_LEVEL > 0) | #if(USBD_DEBUG_LEVEL > 0) | ||||||
| #define USBD_UsrLog(...)    printf(__VA_ARGS__);\ | #define USBD_UsrLog(...) \ | ||||||
|                             printf("\n"); |     printf(__VA_ARGS__); \ | ||||||
|  |     printf("\n"); | ||||||
| #else | #else | ||||||
| #define USBD_UsrLog(...) | #define USBD_UsrLog(...) | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| #if (USBD_DEBUG_LEVEL > 1) | #if(USBD_DEBUG_LEVEL > 1) | ||||||
| 
 | 
 | ||||||
| #define USBD_ErrLog(...)    printf("ERROR: ") ;\ | #define USBD_ErrLog(...) \ | ||||||
|                             printf(__VA_ARGS__);\ |     printf("ERROR: ");   \ | ||||||
|                             printf("\n"); |     printf(__VA_ARGS__); \ | ||||||
|  |     printf("\n"); | ||||||
| #else | #else | ||||||
| #define USBD_ErrLog(...) | #define USBD_ErrLog(...) | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| #if (USBD_DEBUG_LEVEL > 2) | #if(USBD_DEBUG_LEVEL > 2) | ||||||
| #define USBD_DbgLog(...)    printf("DEBUG : ") ;\ | #define USBD_DbgLog(...) \ | ||||||
|                             printf(__VA_ARGS__);\ |     printf("DEBUG : ");  \ | ||||||
|                             printf("\n"); |     printf(__VA_ARGS__); \ | ||||||
|  |     printf("\n"); | ||||||
| #else | #else | ||||||
| #define USBD_DbgLog(...) | #define USBD_DbgLog(...) | ||||||
| #endif | #endif | ||||||
| @ -151,8 +154,8 @@ | |||||||
|   */ |   */ | ||||||
| 
 | 
 | ||||||
| /* Exported functions -------------------------------------------------------*/ | /* Exported functions -------------------------------------------------------*/ | ||||||
| void *USBD_static_malloc(uint32_t size); | void* USBD_static_malloc(uint32_t size); | ||||||
| void USBD_static_free(void *p); | void USBD_static_free(void* p); | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
|   * @} |   * @} | ||||||
|  | |||||||
| @ -17,13 +17,13 @@ | |||||||
|   * |   * | ||||||
|   ****************************************************************************** |   ****************************************************************************** | ||||||
|   */ |   */ | ||||||
| /* USER CODE END Header */   | /* USER CODE END Header */ | ||||||
| /* Define to prevent recursive inclusion -------------------------------------*/ | /* Define to prevent recursive inclusion -------------------------------------*/ | ||||||
| #ifndef __USBD_DESC__C__ | #ifndef __USBD_DESC__C__ | ||||||
| #define __USBD_DESC__C__ | #define __USBD_DESC__C__ | ||||||
| 
 | 
 | ||||||
| #ifdef __cplusplus | #ifdef __cplusplus | ||||||
|  extern "C" { | extern "C" { | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| /* Includes ------------------------------------------------------------------*/ | /* Includes ------------------------------------------------------------------*/ | ||||||
| @ -41,16 +41,16 @@ | |||||||
|   * @brief Usb device descriptors module. |   * @brief Usb device descriptors module. | ||||||
|   * @{ |   * @{ | ||||||
|   */ |   */ | ||||||
|    | 
 | ||||||
| /** @defgroup USBD_DESC_Exported_Constants USBD_DESC_Exported_Constants
 | /** @defgroup USBD_DESC_Exported_Constants USBD_DESC_Exported_Constants
 | ||||||
|   * @brief Constants. |   * @brief Constants. | ||||||
|   * @{ |   * @{ | ||||||
|   */ |   */ | ||||||
| #define         DEVICE_ID1          (UID_BASE) | #define DEVICE_ID1 (UID_BASE) | ||||||
| #define         DEVICE_ID2          (UID_BASE + 0x4) | #define DEVICE_ID2 (UID_BASE + 0x4) | ||||||
| #define         DEVICE_ID3          (UID_BASE + 0x8) | #define DEVICE_ID3 (UID_BASE + 0x8) | ||||||
| 
 | 
 | ||||||
| #define  USB_SIZ_STRING_SERIAL       0x1A | #define USB_SIZ_STRING_SERIAL 0x1A | ||||||
| 
 | 
 | ||||||
| /* USER CODE BEGIN EXPORTED_CONSTANTS */ | /* USER CODE BEGIN EXPORTED_CONSTANTS */ | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -15,18 +15,18 @@ void app_gpio_init(GpioPin gpio, GpioMode mode) { | |||||||
|         GPIO_InitStruct.Pull = GPIO_NOPULL; |         GPIO_InitStruct.Pull = GPIO_NOPULL; | ||||||
| 
 | 
 | ||||||
|         switch(mode) { |         switch(mode) { | ||||||
|             case GpioModeInput: |         case GpioModeInput: | ||||||
|                 GPIO_InitStruct.Mode = GPIO_MODE_INPUT; |             GPIO_InitStruct.Mode = GPIO_MODE_INPUT; | ||||||
|             break; |             break; | ||||||
| 
 | 
 | ||||||
|             case GpioModeOutput:  |         case GpioModeOutput: | ||||||
|                 GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; |             GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; | ||||||
|                 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM; |             GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM; | ||||||
|             break; |             break; | ||||||
| 
 | 
 | ||||||
|             case GpioModeOpenDrain: |         case GpioModeOpenDrain: | ||||||
|                 GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_OD; |             GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_OD; | ||||||
|                 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM; |             GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM; | ||||||
|             break; |             break; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
| @ -36,20 +36,21 @@ void app_gpio_init(GpioPin gpio, GpioMode mode) { | |||||||
| 
 | 
 | ||||||
| // TODO delay from timer
 | // TODO delay from timer
 | ||||||
| void delay_us(uint32_t time) { | void delay_us(uint32_t time) { | ||||||
|   time *= 11.8; |     time *= 11.8; | ||||||
| 
 | 
 | ||||||
|   while(time--) {} |     while(time--) { | ||||||
|  |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void pwm_set(float value, float freq, TIM_HandleTypeDef* tim, uint32_t channel) { | void pwm_set(float value, float freq, TIM_HandleTypeDef* tim, uint32_t channel) { | ||||||
|     tim->Init.CounterMode = TIM_COUNTERMODE_UP; |     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.ClockDivision = TIM_CLOCKDIVISION_DIV1; | ||||||
|     tim->Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; |     tim->Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; | ||||||
|     HAL_TIM_PWM_Init(tim); |     HAL_TIM_PWM_Init(tim); | ||||||
| 
 | 
 | ||||||
|     TIM_OC_InitTypeDef sConfigOC; |     TIM_OC_InitTypeDef sConfigOC; | ||||||
|    | 
 | ||||||
|     sConfigOC.OCMode = TIM_OCMODE_PWM1; |     sConfigOC.OCMode = TIM_OCMODE_PWM1; | ||||||
|     sConfigOC.Pulse = (uint16_t)(291 * value); |     sConfigOC.Pulse = (uint16_t)(291 * value); | ||||||
|     sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH; |     sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH; | ||||||
|  | |||||||
| @ -24,7 +24,7 @@ | |||||||
| #include "main.h" | #include "main.h" | ||||||
| 
 | 
 | ||||||
| /* Private includes ----------------------------------------------------------*/ | /* Private includes ----------------------------------------------------------*/ | ||||||
| /* USER CODE BEGIN Includes */      | /* USER CODE BEGIN Includes */ | ||||||
| #include <stdbool.h> | #include <stdbool.h> | ||||||
| 
 | 
 | ||||||
| /* USER CODE END Includes */ | /* USER CODE END Includes */ | ||||||
| @ -51,22 +51,25 @@ | |||||||
| 
 | 
 | ||||||
| /* Private function prototypes -----------------------------------------------*/ | /* Private function prototypes -----------------------------------------------*/ | ||||||
| /* USER CODE BEGIN FunctionPrototypes */ | /* USER CODE BEGIN FunctionPrototypes */ | ||||||
|     | 
 | ||||||
| /* USER CODE END FunctionPrototypes */ | /* USER CODE END FunctionPrototypes */ | ||||||
| 
 | 
 | ||||||
| /* GetIdleTaskMemory prototype (linked to static allocation support) */ | /* 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) */ | /* 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 */ | /* Hook prototypes */ | ||||||
| void vApplicationIdleHook(void); | void vApplicationIdleHook(void); | ||||||
| 
 | 
 | ||||||
| /* USER CODE BEGIN 2 */ | /* USER CODE BEGIN 2 */ | ||||||
| __weak void vApplicationIdleHook( void ) | __weak void vApplicationIdleHook(void) { | ||||||
| { |     /* vApplicationIdleHook() will only be called if configUSE_IDLE_HOOK is set
 | ||||||
|    /* 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 |    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 |    task. It is essential that code added to this hook function never attempts | ||||||
|    to block in any way (for example, call xQueueReceive() with a block time |    to block in any way (for example, call xQueueReceive() with a block time | ||||||
| @ -81,27 +84,29 @@ __weak void vApplicationIdleHook( void ) | |||||||
| /* USER CODE BEGIN GET_IDLE_TASK_MEMORY */ | /* USER CODE BEGIN GET_IDLE_TASK_MEMORY */ | ||||||
| static StaticTask_t xIdleTaskTCBBuffer; | static StaticTask_t xIdleTaskTCBBuffer; | ||||||
| static StackType_t xIdleStack[configMINIMAL_STACK_SIZE]; | 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, | ||||||
|   *ppxIdleTaskTCBBuffer = &xIdleTaskTCBBuffer; |                                    uint32_t* pulIdleTaskStackSize) { | ||||||
|   *ppxIdleTaskStackBuffer = &xIdleStack[0]; |     *ppxIdleTaskTCBBuffer = &xIdleTaskTCBBuffer; | ||||||
|   *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE; |     *ppxIdleTaskStackBuffer = &xIdleStack[0]; | ||||||
|   /* place for user code */ |     *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE; | ||||||
| }                    |     /* place for user code */ | ||||||
|  | } | ||||||
| /* USER CODE END GET_IDLE_TASK_MEMORY */ | /* USER CODE END GET_IDLE_TASK_MEMORY */ | ||||||
| 
 | 
 | ||||||
| /* USER CODE BEGIN GET_TIMER_TASK_MEMORY */ | /* USER CODE BEGIN GET_TIMER_TASK_MEMORY */ | ||||||
| static StaticTask_t xTimerTaskTCBBuffer; | static StaticTask_t xTimerTaskTCBBuffer; | ||||||
| static StackType_t xTimerStack[configTIMER_TASK_STACK_DEPTH]; | 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, | ||||||
|   *ppxTimerTaskTCBBuffer = &xTimerTaskTCBBuffer; |                                     uint32_t* pulTimerTaskStackSize) { | ||||||
|   *ppxTimerTaskStackBuffer = &xTimerStack[0]; |     *ppxTimerTaskTCBBuffer = &xTimerTaskTCBBuffer; | ||||||
|   *pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH; |     *ppxTimerTaskStackBuffer = &xTimerStack[0]; | ||||||
|   /* place for user code */ |     *pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH; | ||||||
| }                    |     /* place for user code */ | ||||||
|  | } | ||||||
| /* USER CODE END GET_TIMER_TASK_MEMORY */ | /* USER CODE END GET_TIMER_TASK_MEMORY */ | ||||||
| 
 | 
 | ||||||
| /* Private application code --------------------------------------------------*/ | /* Private application code --------------------------------------------------*/ | ||||||
| @ -111,7 +116,7 @@ bool task_equal(TaskHandle_t a, TaskHandle_t b) { | |||||||
| 
 | 
 | ||||||
|     return a == b; |     return a == b; | ||||||
| } | } | ||||||
|       | 
 | ||||||
| /* USER CODE END Application */ | /* USER CODE END Application */ | ||||||
| 
 | 
 | ||||||
| /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | ||||||
|  | |||||||
							
								
								
									
										1022
									
								
								target_f2/Src/main.c
									
									
									
									
									
								
							
							
						
						
									
										1022
									
								
								target_f2/Src/main.c
									
									
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @ -32,7 +32,7 @@ | |||||||
| 
 | 
 | ||||||
| /* Private define ------------------------------------------------------------*/ | /* Private define ------------------------------------------------------------*/ | ||||||
| /* USER CODE BEGIN Define */ | /* USER CODE BEGIN Define */ | ||||||
|   | 
 | ||||||
| /* USER CODE END Define */ | /* USER CODE END Define */ | ||||||
| 
 | 
 | ||||||
| /* Private macro -------------------------------------------------------------*/ | /* Private macro -------------------------------------------------------------*/ | ||||||
| @ -58,27 +58,26 @@ | |||||||
| /* USER CODE BEGIN 0 */ | /* USER CODE BEGIN 0 */ | ||||||
| 
 | 
 | ||||||
| /* USER CODE END 0 */ | /* USER CODE END 0 */ | ||||||
|                          | 
 | ||||||
| void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim); | void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim); | ||||||
|                                         /**
 | /**
 | ||||||
|   * Initializes the Global MSP. |   * Initializes the Global MSP. | ||||||
|   */ |   */ | ||||||
| void HAL_MspInit(void) | void HAL_MspInit(void) { | ||||||
| { |     /* USER CODE BEGIN MspInit 0 */ | ||||||
|   /* USER CODE BEGIN MspInit 0 */ |  | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END MspInit 0 */ |     /* USER CODE END MspInit 0 */ | ||||||
| 
 | 
 | ||||||
|   __HAL_RCC_SYSCFG_CLK_ENABLE(); |     __HAL_RCC_SYSCFG_CLK_ENABLE(); | ||||||
|   __HAL_RCC_PWR_CLK_ENABLE(); |     __HAL_RCC_PWR_CLK_ENABLE(); | ||||||
| 
 | 
 | ||||||
|   /* System interrupt init*/ |     /* System interrupt init*/ | ||||||
|   /* PendSV_IRQn interrupt configuration */ |     /* PendSV_IRQn interrupt configuration */ | ||||||
|   HAL_NVIC_SetPriority(PendSV_IRQn, 15, 0); |     HAL_NVIC_SetPriority(PendSV_IRQn, 15, 0); | ||||||
| 
 | 
 | ||||||
|   /* USER CODE BEGIN MspInit 1 */ |     /* USER CODE BEGIN MspInit 1 */ | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END MspInit 1 */ |     /* USER CODE END MspInit 1 */ | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
| @ -87,38 +86,35 @@ void HAL_MspInit(void) | |||||||
| * @param hadc: ADC handle pointer | * @param hadc: ADC handle pointer | ||||||
| * @retval None | * @retval None | ||||||
| */ | */ | ||||||
| void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc) | void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc) { | ||||||
| { |     GPIO_InitTypeDef GPIO_InitStruct = {0}; | ||||||
|   GPIO_InitTypeDef GPIO_InitStruct = {0}; |     if(hadc->Instance == ADC1) { | ||||||
|   if(hadc->Instance==ADC1) |         /* USER CODE BEGIN ADC1_MspInit 0 */ | ||||||
|   { |  | ||||||
|   /* USER CODE BEGIN ADC1_MspInit 0 */ |  | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END ADC1_MspInit 0 */ |         /* USER CODE END ADC1_MspInit 0 */ | ||||||
|     /* Peripheral clock enable */ |         /* Peripheral clock enable */ | ||||||
|     __HAL_RCC_ADC_CLK_ENABLE(); |         __HAL_RCC_ADC_CLK_ENABLE(); | ||||||
|    | 
 | ||||||
|     __HAL_RCC_GPIOC_CLK_ENABLE(); |         __HAL_RCC_GPIOC_CLK_ENABLE(); | ||||||
|     __HAL_RCC_GPIOA_CLK_ENABLE(); |         __HAL_RCC_GPIOA_CLK_ENABLE(); | ||||||
|     /**ADC1 GPIO Configuration    
 |         /**ADC1 GPIO Configuration    
 | ||||||
|     PC3     ------> ADC1_IN4 |     PC3     ------> ADC1_IN4 | ||||||
|     PA0     ------> ADC1_IN5  |     PA0     ------> ADC1_IN5  | ||||||
|     */ |     */ | ||||||
|     GPIO_InitStruct.Pin = BATT_V_Pin; |         GPIO_InitStruct.Pin = BATT_V_Pin; | ||||||
|     GPIO_InitStruct.Mode = GPIO_MODE_ANALOG_ADC_CONTROL; |         GPIO_InitStruct.Mode = GPIO_MODE_ANALOG_ADC_CONTROL; | ||||||
|     GPIO_InitStruct.Pull = GPIO_NOPULL; |         GPIO_InitStruct.Pull = GPIO_NOPULL; | ||||||
|     HAL_GPIO_Init(BATT_V_GPIO_Port, &GPIO_InitStruct); |         HAL_GPIO_Init(BATT_V_GPIO_Port, &GPIO_InitStruct); | ||||||
| 
 | 
 | ||||||
|     GPIO_InitStruct.Pin = IR_RX_Pin; |         GPIO_InitStruct.Pin = IR_RX_Pin; | ||||||
|     GPIO_InitStruct.Mode = GPIO_MODE_ANALOG_ADC_CONTROL; |         GPIO_InitStruct.Mode = GPIO_MODE_ANALOG_ADC_CONTROL; | ||||||
|     GPIO_InitStruct.Pull = GPIO_NOPULL; |         GPIO_InitStruct.Pull = GPIO_NOPULL; | ||||||
|     HAL_GPIO_Init(IR_RX_GPIO_Port, &GPIO_InitStruct); |         HAL_GPIO_Init(IR_RX_GPIO_Port, &GPIO_InitStruct); | ||||||
| 
 | 
 | ||||||
|   /* USER CODE BEGIN ADC1_MspInit 1 */ |         /* USER CODE BEGIN ADC1_MspInit 1 */ | ||||||
| 
 |  | ||||||
|   /* USER CODE END ADC1_MspInit 1 */ |  | ||||||
|   } |  | ||||||
| 
 | 
 | ||||||
|  |         /* USER CODE END ADC1_MspInit 1 */ | ||||||
|  |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
| @ -127,29 +123,26 @@ void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc) | |||||||
| * @param hadc: ADC handle pointer | * @param hadc: ADC handle pointer | ||||||
| * @retval None | * @retval None | ||||||
| */ | */ | ||||||
| void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc) | void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc) { | ||||||
| { |     if(hadc->Instance == ADC1) { | ||||||
|   if(hadc->Instance==ADC1) |         /* USER CODE BEGIN ADC1_MspDeInit 0 */ | ||||||
|   { |  | ||||||
|   /* USER CODE BEGIN ADC1_MspDeInit 0 */ |  | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END ADC1_MspDeInit 0 */ |         /* USER CODE END ADC1_MspDeInit 0 */ | ||||||
|     /* Peripheral clock disable */ |         /* Peripheral clock disable */ | ||||||
|     __HAL_RCC_ADC_CLK_DISABLE(); |         __HAL_RCC_ADC_CLK_DISABLE(); | ||||||
|    | 
 | ||||||
|     /**ADC1 GPIO Configuration    
 |         /**ADC1 GPIO Configuration    
 | ||||||
|     PC3     ------> ADC1_IN4 |     PC3     ------> ADC1_IN4 | ||||||
|     PA0     ------> ADC1_IN5  |     PA0     ------> ADC1_IN5  | ||||||
|     */ |     */ | ||||||
|     HAL_GPIO_DeInit(BATT_V_GPIO_Port, BATT_V_Pin); |         HAL_GPIO_DeInit(BATT_V_GPIO_Port, BATT_V_Pin); | ||||||
| 
 | 
 | ||||||
|     HAL_GPIO_DeInit(IR_RX_GPIO_Port, IR_RX_Pin); |         HAL_GPIO_DeInit(IR_RX_GPIO_Port, IR_RX_Pin); | ||||||
| 
 | 
 | ||||||
|   /* USER CODE BEGIN ADC1_MspDeInit 1 */ |         /* USER CODE BEGIN ADC1_MspDeInit 1 */ | ||||||
| 
 |  | ||||||
|   /* USER CODE END ADC1_MspDeInit 1 */ |  | ||||||
|   } |  | ||||||
| 
 | 
 | ||||||
|  |         /* USER CODE END ADC1_MspDeInit 1 */ | ||||||
|  |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
| @ -158,29 +151,26 @@ void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc) | |||||||
| * @param hcomp: COMP handle pointer | * @param hcomp: COMP handle pointer | ||||||
| * @retval None | * @retval None | ||||||
| */ | */ | ||||||
| void HAL_COMP_MspInit(COMP_HandleTypeDef* hcomp) | void HAL_COMP_MspInit(COMP_HandleTypeDef* hcomp) { | ||||||
| { |     GPIO_InitTypeDef GPIO_InitStruct = {0}; | ||||||
|   GPIO_InitTypeDef GPIO_InitStruct = {0}; |     if(hcomp->Instance == COMP1) { | ||||||
|   if(hcomp->Instance==COMP1) |         /* USER CODE BEGIN COMP1_MspInit 0 */ | ||||||
|   { |  | ||||||
|   /* USER CODE BEGIN COMP1_MspInit 0 */ |  | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END COMP1_MspInit 0 */ |         /* USER CODE END COMP1_MspInit 0 */ | ||||||
|    | 
 | ||||||
|     __HAL_RCC_GPIOC_CLK_ENABLE(); |         __HAL_RCC_GPIOC_CLK_ENABLE(); | ||||||
|     /**COMP1 GPIO Configuration    
 |         /**COMP1 GPIO Configuration    
 | ||||||
|     PC5     ------> COMP1_INP  |     PC5     ------> COMP1_INP  | ||||||
|     */ |     */ | ||||||
|     GPIO_InitStruct.Pin = RFID_RF_IN_Pin; |         GPIO_InitStruct.Pin = RFID_RF_IN_Pin; | ||||||
|     GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; |         GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; | ||||||
|     GPIO_InitStruct.Pull = GPIO_NOPULL; |         GPIO_InitStruct.Pull = GPIO_NOPULL; | ||||||
|     HAL_GPIO_Init(RFID_RF_IN_GPIO_Port, &GPIO_InitStruct); |         HAL_GPIO_Init(RFID_RF_IN_GPIO_Port, &GPIO_InitStruct); | ||||||
| 
 | 
 | ||||||
|   /* USER CODE BEGIN COMP1_MspInit 1 */ |         /* USER CODE BEGIN COMP1_MspInit 1 */ | ||||||
| 
 |  | ||||||
|   /* USER CODE END COMP1_MspInit 1 */ |  | ||||||
|   } |  | ||||||
| 
 | 
 | ||||||
|  |         /* USER CODE END COMP1_MspInit 1 */ | ||||||
|  |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
| @ -189,24 +179,21 @@ void HAL_COMP_MspInit(COMP_HandleTypeDef* hcomp) | |||||||
| * @param hcomp: COMP handle pointer | * @param hcomp: COMP handle pointer | ||||||
| * @retval None | * @retval None | ||||||
| */ | */ | ||||||
| void HAL_COMP_MspDeInit(COMP_HandleTypeDef* hcomp) | void HAL_COMP_MspDeInit(COMP_HandleTypeDef* hcomp) { | ||||||
| { |     if(hcomp->Instance == COMP1) { | ||||||
|   if(hcomp->Instance==COMP1) |         /* USER CODE BEGIN COMP1_MspDeInit 0 */ | ||||||
|   { |  | ||||||
|   /* USER CODE BEGIN COMP1_MspDeInit 0 */ |  | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END COMP1_MspDeInit 0 */ |         /* USER CODE END COMP1_MspDeInit 0 */ | ||||||
|    | 
 | ||||||
|     /**COMP1 GPIO Configuration    
 |         /**COMP1 GPIO Configuration    
 | ||||||
|     PC5     ------> COMP1_INP  |     PC5     ------> COMP1_INP  | ||||||
|     */ |     */ | ||||||
|     HAL_GPIO_DeInit(RFID_RF_IN_GPIO_Port, RFID_RF_IN_Pin); |         HAL_GPIO_DeInit(RFID_RF_IN_GPIO_Port, RFID_RF_IN_Pin); | ||||||
| 
 | 
 | ||||||
|   /* USER CODE BEGIN COMP1_MspDeInit 1 */ |         /* USER CODE BEGIN COMP1_MspDeInit 1 */ | ||||||
| 
 |  | ||||||
|   /* USER CODE END COMP1_MspDeInit 1 */ |  | ||||||
|   } |  | ||||||
| 
 | 
 | ||||||
|  |         /* USER CODE END COMP1_MspDeInit 1 */ | ||||||
|  |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
| @ -215,59 +202,54 @@ void HAL_COMP_MspDeInit(COMP_HandleTypeDef* hcomp) | |||||||
| * @param hspi: SPI handle pointer | * @param hspi: SPI handle pointer | ||||||
| * @retval None | * @retval None | ||||||
| */ | */ | ||||||
| void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi) | void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi) { | ||||||
| { |     GPIO_InitTypeDef GPIO_InitStruct = {0}; | ||||||
|   GPIO_InitTypeDef GPIO_InitStruct = {0}; |     if(hspi->Instance == SPI1) { | ||||||
|   if(hspi->Instance==SPI1) |         /* USER CODE BEGIN SPI1_MspInit 0 */ | ||||||
|   { |  | ||||||
|   /* USER CODE BEGIN SPI1_MspInit 0 */ |  | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END SPI1_MspInit 0 */ |         /* USER CODE END SPI1_MspInit 0 */ | ||||||
|     /* Peripheral clock enable */ |         /* Peripheral clock enable */ | ||||||
|     __HAL_RCC_SPI1_CLK_ENABLE(); |         __HAL_RCC_SPI1_CLK_ENABLE(); | ||||||
|    | 
 | ||||||
|     __HAL_RCC_GPIOB_CLK_ENABLE(); |         __HAL_RCC_GPIOB_CLK_ENABLE(); | ||||||
|     /**SPI1 GPIO Configuration    
 |         /**SPI1 GPIO Configuration    
 | ||||||
|     PB3 (JTDO-TRACESWO)     ------> SPI1_SCK |     PB3 (JTDO-TRACESWO)     ------> SPI1_SCK | ||||||
|     PB5     ------> SPI1_MOSI  |     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.Mode = GPIO_MODE_AF_PP; | ||||||
|     GPIO_InitStruct.Pull = GPIO_NOPULL; |         GPIO_InitStruct.Pull = GPIO_NOPULL; | ||||||
|     GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; |         GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; | ||||||
|     GPIO_InitStruct.Alternate = GPIO_AF5_SPI1; |         GPIO_InitStruct.Alternate = GPIO_AF5_SPI1; | ||||||
|     HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); |         HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); | ||||||
| 
 | 
 | ||||||
|   /* USER CODE BEGIN SPI1_MspInit 1 */ |         /* USER CODE BEGIN SPI1_MspInit 1 */ | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END 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 BEGIN SPI3_MspInit 0 */ |  | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END SPI3_MspInit 0 */ |         /* USER CODE END SPI3_MspInit 0 */ | ||||||
|     /* Peripheral clock enable */ |         /* Peripheral clock enable */ | ||||||
|     __HAL_RCC_SPI3_CLK_ENABLE(); |         __HAL_RCC_SPI3_CLK_ENABLE(); | ||||||
|    | 
 | ||||||
|     __HAL_RCC_GPIOC_CLK_ENABLE(); |         __HAL_RCC_GPIOC_CLK_ENABLE(); | ||||||
|     /**SPI3 GPIO Configuration    
 |         /**SPI3 GPIO Configuration    
 | ||||||
|     PC10     ------> SPI3_SCK |     PC10     ------> SPI3_SCK | ||||||
|     PC11     ------> SPI3_MISO |     PC11     ------> SPI3_MISO | ||||||
|     PC12     ------> SPI3_MOSI  |     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.Mode = GPIO_MODE_AF_PP; | ||||||
|     GPIO_InitStruct.Pull = GPIO_NOPULL; |         GPIO_InitStruct.Pull = GPIO_NOPULL; | ||||||
|     GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; |         GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; | ||||||
|     GPIO_InitStruct.Alternate = GPIO_AF6_SPI3; |         GPIO_InitStruct.Alternate = GPIO_AF6_SPI3; | ||||||
|     HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); |         HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); | ||||||
| 
 | 
 | ||||||
|   /* USER CODE BEGIN SPI3_MspInit 1 */ |         /* USER CODE BEGIN SPI3_MspInit 1 */ | ||||||
| 
 |  | ||||||
|   /* USER CODE END SPI3_MspInit 1 */ |  | ||||||
|   } |  | ||||||
| 
 | 
 | ||||||
|  |         /* USER CODE END SPI3_MspInit 1 */ | ||||||
|  |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
| @ -276,46 +258,41 @@ void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi) | |||||||
| * @param hspi: SPI handle pointer | * @param hspi: SPI handle pointer | ||||||
| * @retval None | * @retval None | ||||||
| */ | */ | ||||||
| void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi) | void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi) { | ||||||
| { |     if(hspi->Instance == SPI1) { | ||||||
|   if(hspi->Instance==SPI1) |         /* USER CODE BEGIN SPI1_MspDeInit 0 */ | ||||||
|   { |  | ||||||
|   /* USER CODE BEGIN SPI1_MspDeInit 0 */ |  | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END SPI1_MspDeInit 0 */ |         /* USER CODE END SPI1_MspDeInit 0 */ | ||||||
|     /* Peripheral clock disable */ |         /* Peripheral clock disable */ | ||||||
|     __HAL_RCC_SPI1_CLK_DISABLE(); |         __HAL_RCC_SPI1_CLK_DISABLE(); | ||||||
|    | 
 | ||||||
|     /**SPI1 GPIO Configuration    
 |         /**SPI1 GPIO Configuration    
 | ||||||
|     PB3 (JTDO-TRACESWO)     ------> SPI1_SCK |     PB3 (JTDO-TRACESWO)     ------> SPI1_SCK | ||||||
|     PB5     ------> SPI1_MOSI  |     PB5     ------> SPI1_MOSI  | ||||||
|     */ |     */ | ||||||
|     HAL_GPIO_DeInit(GPIOB, GPIO_PIN_3|GPIO_PIN_5); |         HAL_GPIO_DeInit(GPIOB, GPIO_PIN_3 | GPIO_PIN_5); | ||||||
| 
 | 
 | ||||||
|   /* USER CODE BEGIN SPI1_MspDeInit 1 */ |         /* USER CODE BEGIN SPI1_MspDeInit 1 */ | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END SPI1_MspDeInit 1 */ |         /* USER CODE END SPI1_MspDeInit 1 */ | ||||||
|   } |     } else if(hspi->Instance == SPI3) { | ||||||
|   else if(hspi->Instance==SPI3) |         /* USER CODE BEGIN SPI3_MspDeInit 0 */ | ||||||
|   { |  | ||||||
|   /* USER CODE BEGIN SPI3_MspDeInit 0 */ |  | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END SPI3_MspDeInit 0 */ |         /* USER CODE END SPI3_MspDeInit 0 */ | ||||||
|     /* Peripheral clock disable */ |         /* Peripheral clock disable */ | ||||||
|     __HAL_RCC_SPI3_CLK_DISABLE(); |         __HAL_RCC_SPI3_CLK_DISABLE(); | ||||||
|    | 
 | ||||||
|     /**SPI3 GPIO Configuration    
 |         /**SPI3 GPIO Configuration    
 | ||||||
|     PC10     ------> SPI3_SCK |     PC10     ------> SPI3_SCK | ||||||
|     PC11     ------> SPI3_MISO |     PC11     ------> SPI3_MISO | ||||||
|     PC12     ------> SPI3_MOSI  |     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 BEGIN SPI3_MspDeInit 1 */ | ||||||
| 
 |  | ||||||
|   /* USER CODE END SPI3_MspDeInit 1 */ |  | ||||||
|   } |  | ||||||
| 
 | 
 | ||||||
|  |         /* USER CODE END SPI3_MspDeInit 1 */ | ||||||
|  |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
| @ -324,20 +301,17 @@ void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi) | |||||||
| * @param htim_pwm: TIM_PWM handle pointer | * @param htim_pwm: TIM_PWM handle pointer | ||||||
| * @retval None | * @retval None | ||||||
| */ | */ | ||||||
| void HAL_TIM_PWM_MspInit(TIM_HandleTypeDef* htim_pwm) | void HAL_TIM_PWM_MspInit(TIM_HandleTypeDef* htim_pwm) { | ||||||
| { |     if(htim_pwm->Instance == TIM5) { | ||||||
|   if(htim_pwm->Instance==TIM5) |         /* USER CODE BEGIN TIM5_MspInit 0 */ | ||||||
|   { |  | ||||||
|   /* USER CODE BEGIN TIM5_MspInit 0 */ |  | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END TIM5_MspInit 0 */ |         /* USER CODE END TIM5_MspInit 0 */ | ||||||
|     /* Peripheral clock enable */ |         /* Peripheral clock enable */ | ||||||
|     __HAL_RCC_TIM5_CLK_ENABLE(); |         __HAL_RCC_TIM5_CLK_ENABLE(); | ||||||
|   /* USER CODE BEGIN TIM5_MspInit 1 */ |         /* USER CODE BEGIN TIM5_MspInit 1 */ | ||||||
| 
 |  | ||||||
|   /* USER CODE END TIM5_MspInit 1 */ |  | ||||||
|   } |  | ||||||
| 
 | 
 | ||||||
|  |         /* USER CODE END TIM5_MspInit 1 */ | ||||||
|  |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
| @ -346,36 +320,33 @@ void HAL_TIM_PWM_MspInit(TIM_HandleTypeDef* htim_pwm) | |||||||
| * @param htim_base: TIM_Base handle pointer | * @param htim_base: TIM_Base handle pointer | ||||||
| * @retval None | * @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}; | ||||||
|   GPIO_InitTypeDef GPIO_InitStruct = {0}; |     if(htim_base->Instance == TIM8) { | ||||||
|   if(htim_base->Instance==TIM8) |         /* USER CODE BEGIN TIM8_MspInit 0 */ | ||||||
|   { |  | ||||||
|   /* USER CODE BEGIN TIM8_MspInit 0 */ |  | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END TIM8_MspInit 0 */ |         /* USER CODE END TIM8_MspInit 0 */ | ||||||
|     /* Peripheral clock enable */ |         /* Peripheral clock enable */ | ||||||
|     __HAL_RCC_TIM8_CLK_ENABLE(); |         __HAL_RCC_TIM8_CLK_ENABLE(); | ||||||
|    | 
 | ||||||
|     __HAL_RCC_GPIOC_CLK_ENABLE(); |         __HAL_RCC_GPIOC_CLK_ENABLE(); | ||||||
|     /**TIM8 GPIO Configuration    
 |         /**TIM8 GPIO Configuration    
 | ||||||
|     PC7     ------> TIM8_CH2  |     PC7     ------> TIM8_CH2  | ||||||
|     */ |     */ | ||||||
|     GPIO_InitStruct.Pin = iButton_Pin; |         GPIO_InitStruct.Pin = iButton_Pin; | ||||||
|     GPIO_InitStruct.Mode = GPIO_MODE_AF_OD; |         GPIO_InitStruct.Mode = GPIO_MODE_AF_OD; | ||||||
|     GPIO_InitStruct.Pull = GPIO_NOPULL; |         GPIO_InitStruct.Pull = GPIO_NOPULL; | ||||||
|     GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM; |         GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM; | ||||||
|     GPIO_InitStruct.Alternate = GPIO_AF3_TIM8; |         GPIO_InitStruct.Alternate = GPIO_AF3_TIM8; | ||||||
|     HAL_GPIO_Init(iButton_GPIO_Port, &GPIO_InitStruct); |         HAL_GPIO_Init(iButton_GPIO_Port, &GPIO_InitStruct); | ||||||
| 
 | 
 | ||||||
|     /* TIM8 interrupt Init */ |         /* TIM8 interrupt Init */ | ||||||
|     HAL_NVIC_SetPriority(TIM8_CC_IRQn, 5, 0); |         HAL_NVIC_SetPriority(TIM8_CC_IRQn, 5, 0); | ||||||
|     HAL_NVIC_EnableIRQ(TIM8_CC_IRQn); |         HAL_NVIC_EnableIRQ(TIM8_CC_IRQn); | ||||||
|   /* USER CODE BEGIN TIM8_MspInit 1 */ |         /* USER CODE BEGIN TIM8_MspInit 1 */ | ||||||
| 
 |  | ||||||
|   /* USER CODE END TIM8_MspInit 1 */ |  | ||||||
|   } |  | ||||||
| 
 | 
 | ||||||
|  |         /* USER CODE END TIM8_MspInit 1 */ | ||||||
|  |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
| @ -384,68 +355,60 @@ void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base) | |||||||
| * @param htim_oc: TIM_OC handle pointer | * @param htim_oc: TIM_OC handle pointer | ||||||
| * @retval None | * @retval None | ||||||
| */ | */ | ||||||
| void HAL_TIM_OC_MspInit(TIM_HandleTypeDef* htim_oc) | void HAL_TIM_OC_MspInit(TIM_HandleTypeDef* htim_oc) { | ||||||
| { |     if(htim_oc->Instance == TIM15) { | ||||||
|   if(htim_oc->Instance==TIM15) |         /* USER CODE BEGIN TIM15_MspInit 0 */ | ||||||
|   { |  | ||||||
|   /* USER CODE BEGIN TIM15_MspInit 0 */ |  | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END TIM15_MspInit 0 */ |         /* USER CODE END TIM15_MspInit 0 */ | ||||||
|     /* Peripheral clock enable */ |         /* Peripheral clock enable */ | ||||||
|     __HAL_RCC_TIM15_CLK_ENABLE(); |         __HAL_RCC_TIM15_CLK_ENABLE(); | ||||||
|   /* USER CODE BEGIN TIM15_MspInit 1 */ |         /* USER CODE BEGIN TIM15_MspInit 1 */ | ||||||
| 
 |  | ||||||
|   /* USER CODE END TIM15_MspInit 1 */ |  | ||||||
|   } |  | ||||||
| 
 | 
 | ||||||
|  |         /* 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}; | ||||||
|   GPIO_InitTypeDef GPIO_InitStruct = {0}; |     if(htim->Instance == TIM5) { | ||||||
|   if(htim->Instance==TIM5) |         /* USER CODE BEGIN TIM5_MspPostInit 0 */ | ||||||
|   { |  | ||||||
|   /* USER CODE BEGIN TIM5_MspPostInit 0 */ |  | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END TIM5_MspPostInit 0 */ |         /* USER CODE END TIM5_MspPostInit 0 */ | ||||||
|     __HAL_RCC_GPIOA_CLK_ENABLE(); |         __HAL_RCC_GPIOA_CLK_ENABLE(); | ||||||
|     /**TIM5 GPIO Configuration    
 |         /**TIM5 GPIO Configuration    
 | ||||||
|     PA3     ------> TIM5_CH4  |     PA3     ------> TIM5_CH4  | ||||||
|     */ |     */ | ||||||
|     GPIO_InitStruct.Pin = SPEAKER_Pin; |         GPIO_InitStruct.Pin = SPEAKER_Pin; | ||||||
|     GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; |         GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; | ||||||
|     GPIO_InitStruct.Pull = GPIO_NOPULL; |         GPIO_InitStruct.Pull = GPIO_NOPULL; | ||||||
|     GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |         GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; | ||||||
|     GPIO_InitStruct.Alternate = GPIO_AF2_TIM5; |         GPIO_InitStruct.Alternate = GPIO_AF2_TIM5; | ||||||
|     HAL_GPIO_Init(SPEAKER_GPIO_Port, &GPIO_InitStruct); |         HAL_GPIO_Init(SPEAKER_GPIO_Port, &GPIO_InitStruct); | ||||||
| 
 | 
 | ||||||
|   /* USER CODE BEGIN TIM5_MspPostInit 1 */ |         /* USER CODE BEGIN TIM5_MspPostInit 1 */ | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END TIM5_MspPostInit 1 */ |         /* USER CODE END TIM5_MspPostInit 1 */ | ||||||
|   } |     } else if(htim->Instance == TIM15) { | ||||||
|   else if(htim->Instance==TIM15) |         /* USER CODE BEGIN TIM15_MspPostInit 0 */ | ||||||
|   { |  | ||||||
|   /* USER CODE BEGIN TIM15_MspPostInit 0 */ |  | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END TIM15_MspPostInit 0 */ |         /* USER CODE END TIM15_MspPostInit 0 */ | ||||||
|    | 
 | ||||||
|     __HAL_RCC_GPIOB_CLK_ENABLE(); |         __HAL_RCC_GPIOB_CLK_ENABLE(); | ||||||
|     /**TIM15 GPIO Configuration    
 |         /**TIM15 GPIO Configuration    
 | ||||||
|     PB13     ------> TIM15_CH1N |     PB13     ------> TIM15_CH1N | ||||||
|     PB15     ------> TIM15_CH2  |     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.Mode = GPIO_MODE_AF_PP; | ||||||
|     GPIO_InitStruct.Pull = GPIO_NOPULL; |         GPIO_InitStruct.Pull = GPIO_NOPULL; | ||||||
|     GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |         GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; | ||||||
|     GPIO_InitStruct.Alternate = GPIO_AF14_TIM15; |         GPIO_InitStruct.Alternate = GPIO_AF14_TIM15; | ||||||
|     HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); |         HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); | ||||||
| 
 | 
 | ||||||
|   /* USER CODE BEGIN TIM15_MspPostInit 1 */ |         /* USER CODE BEGIN TIM15_MspPostInit 1 */ | ||||||
| 
 |  | ||||||
|   /* USER CODE END TIM15_MspPostInit 1 */ |  | ||||||
|   } |  | ||||||
| 
 | 
 | ||||||
|  |         /* USER CODE END TIM15_MspPostInit 1 */ | ||||||
|  |     } | ||||||
| } | } | ||||||
| /**
 | /**
 | ||||||
| * @brief TIM_PWM MSP De-Initialization | * @brief TIM_PWM MSP De-Initialization | ||||||
| @ -453,20 +416,17 @@ void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim) | |||||||
| * @param htim_pwm: TIM_PWM handle pointer | * @param htim_pwm: TIM_PWM handle pointer | ||||||
| * @retval None | * @retval None | ||||||
| */ | */ | ||||||
| void HAL_TIM_PWM_MspDeInit(TIM_HandleTypeDef* htim_pwm) | void HAL_TIM_PWM_MspDeInit(TIM_HandleTypeDef* htim_pwm) { | ||||||
| { |     if(htim_pwm->Instance == TIM5) { | ||||||
|   if(htim_pwm->Instance==TIM5) |         /* USER CODE BEGIN TIM5_MspDeInit 0 */ | ||||||
|   { |  | ||||||
|   /* USER CODE BEGIN TIM5_MspDeInit 0 */ |  | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END TIM5_MspDeInit 0 */ |         /* USER CODE END TIM5_MspDeInit 0 */ | ||||||
|     /* Peripheral clock disable */ |         /* Peripheral clock disable */ | ||||||
|     __HAL_RCC_TIM5_CLK_DISABLE(); |         __HAL_RCC_TIM5_CLK_DISABLE(); | ||||||
|   /* USER CODE BEGIN TIM5_MspDeInit 1 */ |         /* USER CODE BEGIN TIM5_MspDeInit 1 */ | ||||||
| 
 |  | ||||||
|   /* USER CODE END TIM5_MspDeInit 1 */ |  | ||||||
|   } |  | ||||||
| 
 | 
 | ||||||
|  |         /* USER CODE END TIM5_MspDeInit 1 */ | ||||||
|  |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
| @ -475,28 +435,25 @@ void HAL_TIM_PWM_MspDeInit(TIM_HandleTypeDef* htim_pwm) | |||||||
| * @param htim_base: TIM_Base handle pointer | * @param htim_base: TIM_Base handle pointer | ||||||
| * @retval None | * @retval None | ||||||
| */ | */ | ||||||
| void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* htim_base) | void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* htim_base) { | ||||||
| { |     if(htim_base->Instance == TIM8) { | ||||||
|   if(htim_base->Instance==TIM8) |         /* USER CODE BEGIN TIM8_MspDeInit 0 */ | ||||||
|   { |  | ||||||
|   /* USER CODE BEGIN TIM8_MspDeInit 0 */ |  | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END TIM8_MspDeInit 0 */ |         /* USER CODE END TIM8_MspDeInit 0 */ | ||||||
|     /* Peripheral clock disable */ |         /* Peripheral clock disable */ | ||||||
|     __HAL_RCC_TIM8_CLK_DISABLE(); |         __HAL_RCC_TIM8_CLK_DISABLE(); | ||||||
|    | 
 | ||||||
|     /**TIM8 GPIO Configuration    
 |         /**TIM8 GPIO Configuration    
 | ||||||
|     PC7     ------> TIM8_CH2  |     PC7     ------> TIM8_CH2  | ||||||
|     */ |     */ | ||||||
|     HAL_GPIO_DeInit(iButton_GPIO_Port, iButton_Pin); |         HAL_GPIO_DeInit(iButton_GPIO_Port, iButton_Pin); | ||||||
| 
 | 
 | ||||||
|     /* TIM8 interrupt DeInit */ |         /* TIM8 interrupt DeInit */ | ||||||
|     HAL_NVIC_DisableIRQ(TIM8_CC_IRQn); |         HAL_NVIC_DisableIRQ(TIM8_CC_IRQn); | ||||||
|   /* USER CODE BEGIN TIM8_MspDeInit 1 */ |         /* USER CODE BEGIN TIM8_MspDeInit 1 */ | ||||||
| 
 |  | ||||||
|   /* USER CODE END TIM8_MspDeInit 1 */ |  | ||||||
|   } |  | ||||||
| 
 | 
 | ||||||
|  |         /* USER CODE END TIM8_MspDeInit 1 */ | ||||||
|  |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
| @ -505,20 +462,17 @@ void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* htim_base) | |||||||
| * @param htim_oc: TIM_OC handle pointer | * @param htim_oc: TIM_OC handle pointer | ||||||
| * @retval None | * @retval None | ||||||
| */ | */ | ||||||
| void HAL_TIM_OC_MspDeInit(TIM_HandleTypeDef* htim_oc) | void HAL_TIM_OC_MspDeInit(TIM_HandleTypeDef* htim_oc) { | ||||||
| { |     if(htim_oc->Instance == TIM15) { | ||||||
|   if(htim_oc->Instance==TIM15) |         /* USER CODE BEGIN TIM15_MspDeInit 0 */ | ||||||
|   { |  | ||||||
|   /* USER CODE BEGIN TIM15_MspDeInit 0 */ |  | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END TIM15_MspDeInit 0 */ |         /* USER CODE END TIM15_MspDeInit 0 */ | ||||||
|     /* Peripheral clock disable */ |         /* Peripheral clock disable */ | ||||||
|     __HAL_RCC_TIM15_CLK_DISABLE(); |         __HAL_RCC_TIM15_CLK_DISABLE(); | ||||||
|   /* USER CODE BEGIN TIM15_MspDeInit 1 */ |         /* USER CODE BEGIN TIM15_MspDeInit 1 */ | ||||||
| 
 |  | ||||||
|   /* USER CODE END TIM15_MspDeInit 1 */ |  | ||||||
|   } |  | ||||||
| 
 | 
 | ||||||
|  |         /* USER CODE END TIM15_MspDeInit 1 */ | ||||||
|  |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
| @ -527,34 +481,31 @@ void HAL_TIM_OC_MspDeInit(TIM_HandleTypeDef* htim_oc) | |||||||
| * @param huart: UART handle pointer | * @param huart: UART handle pointer | ||||||
| * @retval None | * @retval None | ||||||
| */ | */ | ||||||
| void HAL_UART_MspInit(UART_HandleTypeDef* huart) | void HAL_UART_MspInit(UART_HandleTypeDef* huart) { | ||||||
| { |     GPIO_InitTypeDef GPIO_InitStruct = {0}; | ||||||
|   GPIO_InitTypeDef GPIO_InitStruct = {0}; |     if(huart->Instance == USART1) { | ||||||
|   if(huart->Instance==USART1) |         /* USER CODE BEGIN USART1_MspInit 0 */ | ||||||
|   { |  | ||||||
|   /* USER CODE BEGIN USART1_MspInit 0 */ |  | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END USART1_MspInit 0 */ |         /* USER CODE END USART1_MspInit 0 */ | ||||||
|     /* Peripheral clock enable */ |         /* Peripheral clock enable */ | ||||||
|     __HAL_RCC_USART1_CLK_ENABLE(); |         __HAL_RCC_USART1_CLK_ENABLE(); | ||||||
|    | 
 | ||||||
|     __HAL_RCC_GPIOA_CLK_ENABLE(); |         __HAL_RCC_GPIOA_CLK_ENABLE(); | ||||||
|     /**USART1 GPIO Configuration    
 |         /**USART1 GPIO Configuration    
 | ||||||
|     PA9     ------> USART1_TX |     PA9     ------> USART1_TX | ||||||
|     PA10     ------> USART1_RX  |     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.Mode = GPIO_MODE_AF_PP; | ||||||
|     GPIO_InitStruct.Pull = GPIO_NOPULL; |         GPIO_InitStruct.Pull = GPIO_NOPULL; | ||||||
|     GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; |         GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; | ||||||
|     GPIO_InitStruct.Alternate = GPIO_AF7_USART1; |         GPIO_InitStruct.Alternate = GPIO_AF7_USART1; | ||||||
|     HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); |         HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); | ||||||
| 
 | 
 | ||||||
|   /* USER CODE BEGIN USART1_MspInit 1 */ |         /* USER CODE BEGIN USART1_MspInit 1 */ | ||||||
| 
 |  | ||||||
|   /* USER CODE END USART1_MspInit 1 */ |  | ||||||
|   } |  | ||||||
| 
 | 
 | ||||||
|  |         /* USER CODE END USART1_MspInit 1 */ | ||||||
|  |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
| @ -563,27 +514,24 @@ void HAL_UART_MspInit(UART_HandleTypeDef* huart) | |||||||
| * @param huart: UART handle pointer | * @param huart: UART handle pointer | ||||||
| * @retval None | * @retval None | ||||||
| */ | */ | ||||||
| void HAL_UART_MspDeInit(UART_HandleTypeDef* huart) | void HAL_UART_MspDeInit(UART_HandleTypeDef* huart) { | ||||||
| { |     if(huart->Instance == USART1) { | ||||||
|   if(huart->Instance==USART1) |         /* USER CODE BEGIN USART1_MspDeInit 0 */ | ||||||
|   { |  | ||||||
|   /* USER CODE BEGIN USART1_MspDeInit 0 */ |  | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END USART1_MspDeInit 0 */ |         /* USER CODE END USART1_MspDeInit 0 */ | ||||||
|     /* Peripheral clock disable */ |         /* Peripheral clock disable */ | ||||||
|     __HAL_RCC_USART1_CLK_DISABLE(); |         __HAL_RCC_USART1_CLK_DISABLE(); | ||||||
|    | 
 | ||||||
|     /**USART1 GPIO Configuration    
 |         /**USART1 GPIO Configuration    
 | ||||||
|     PA9     ------> USART1_TX |     PA9     ------> USART1_TX | ||||||
|     PA10     ------> USART1_RX  |     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 BEGIN USART1_MspDeInit 1 */ | ||||||
| 
 |  | ||||||
|   /* USER CODE END USART1_MspDeInit 1 */ |  | ||||||
|   } |  | ||||||
| 
 | 
 | ||||||
|  |         /* USER CODE END USART1_MspDeInit 1 */ | ||||||
|  |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /* USER CODE BEGIN 1 */ | /* USER CODE BEGIN 1 */ | ||||||
|  | |||||||
| @ -34,7 +34,7 @@ | |||||||
| 
 | 
 | ||||||
| /* Private define ------------------------------------------------------------*/ | /* Private define ------------------------------------------------------------*/ | ||||||
| /* USER CODE BEGIN PD */ | /* USER CODE BEGIN PD */ | ||||||
|   | 
 | ||||||
| /* USER CODE END PD */ | /* USER CODE END PD */ | ||||||
| 
 | 
 | ||||||
| /* Private macro -------------------------------------------------------------*/ | /* Private macro -------------------------------------------------------------*/ | ||||||
| @ -65,114 +65,102 @@ extern TIM_HandleTypeDef htim8; | |||||||
| /* USER CODE END EV */ | /* USER CODE END EV */ | ||||||
| 
 | 
 | ||||||
| /******************************************************************************/ | /******************************************************************************/ | ||||||
| /*           Cortex-M4 Processor Interruption and Exception Handlers          */  | /*           Cortex-M4 Processor Interruption and Exception Handlers          */ | ||||||
| /******************************************************************************/ | /******************************************************************************/ | ||||||
| /**
 | /**
 | ||||||
|   * @brief This function handles Non maskable interrupt. |   * @brief This function handles Non maskable interrupt. | ||||||
|   */ |   */ | ||||||
| void NMI_Handler(void) | void NMI_Handler(void) { | ||||||
| { |     /* USER CODE BEGIN NonMaskableInt_IRQn 0 */ | ||||||
|   /* USER CODE BEGIN NonMaskableInt_IRQn 0 */ |  | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END NonMaskableInt_IRQn 0 */ |     /* USER CODE END NonMaskableInt_IRQn 0 */ | ||||||
|   /* USER CODE BEGIN NonMaskableInt_IRQn 1 */ |     /* USER CODE BEGIN NonMaskableInt_IRQn 1 */ | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END NonMaskableInt_IRQn 1 */ |     /* USER CODE END NonMaskableInt_IRQn 1 */ | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
|   * @brief This function handles Hard fault interrupt. |   * @brief This function handles Hard fault interrupt. | ||||||
|   */ |   */ | ||||||
| void HardFault_Handler(void) | void HardFault_Handler(void) { | ||||||
| { |     /* USER CODE BEGIN HardFault_IRQn 0 */ | ||||||
|   /* USER CODE BEGIN HardFault_IRQn 0 */ |  | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END HardFault_IRQn 0 */ |     /* USER CODE END HardFault_IRQn 0 */ | ||||||
|   while (1) |     while(1) { | ||||||
|   { |         /* USER CODE BEGIN W1_HardFault_IRQn 0 */ | ||||||
|     /* USER CODE BEGIN W1_HardFault_IRQn 0 */ |         /* USER CODE END W1_HardFault_IRQn 0 */ | ||||||
|     /* USER CODE END W1_HardFault_IRQn 0 */ |     } | ||||||
|   } |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
|   * @brief This function handles Memory management fault. |   * @brief This function handles Memory management fault. | ||||||
|   */ |   */ | ||||||
| void MemManage_Handler(void) | void MemManage_Handler(void) { | ||||||
| { |     /* USER CODE BEGIN MemoryManagement_IRQn 0 */ | ||||||
|   /* USER CODE BEGIN MemoryManagement_IRQn 0 */ |  | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END MemoryManagement_IRQn 0 */ |     /* USER CODE END MemoryManagement_IRQn 0 */ | ||||||
|   while (1) |     while(1) { | ||||||
|   { |         /* USER CODE BEGIN W1_MemoryManagement_IRQn 0 */ | ||||||
|     /* USER CODE BEGIN W1_MemoryManagement_IRQn 0 */ |         /* USER CODE END W1_MemoryManagement_IRQn 0 */ | ||||||
|     /* USER CODE END W1_MemoryManagement_IRQn 0 */ |     } | ||||||
|   } |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
|   * @brief This function handles Prefetch fault, memory access fault. |   * @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 BEGIN BusFault_IRQn 0 */ |  | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END BusFault_IRQn 0 */ |     /* USER CODE END BusFault_IRQn 0 */ | ||||||
|   while (1) |     while(1) { | ||||||
|   { |         /* USER CODE BEGIN W1_BusFault_IRQn 0 */ | ||||||
|     /* USER CODE BEGIN W1_BusFault_IRQn 0 */ |         /* USER CODE END W1_BusFault_IRQn 0 */ | ||||||
|     /* USER CODE END W1_BusFault_IRQn 0 */ |     } | ||||||
|   } |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
|   * @brief This function handles Undefined instruction or illegal state. |   * @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 BEGIN UsageFault_IRQn 0 */ |  | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END UsageFault_IRQn 0 */ |     /* USER CODE END UsageFault_IRQn 0 */ | ||||||
|   while (1) |     while(1) { | ||||||
|   { |         /* USER CODE BEGIN W1_UsageFault_IRQn 0 */ | ||||||
|     /* USER CODE BEGIN W1_UsageFault_IRQn 0 */ |         /* USER CODE END W1_UsageFault_IRQn 0 */ | ||||||
|     /* USER CODE END W1_UsageFault_IRQn 0 */ |     } | ||||||
|   } |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
|   * @brief This function handles Debug monitor. |   * @brief This function handles Debug monitor. | ||||||
|   */ |   */ | ||||||
| void DebugMon_Handler(void) | void DebugMon_Handler(void) { | ||||||
| { |     /* USER CODE BEGIN DebugMonitor_IRQn 0 */ | ||||||
|   /* USER CODE BEGIN DebugMonitor_IRQn 0 */ |  | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END DebugMonitor_IRQn 0 */ |     /* USER CODE END DebugMonitor_IRQn 0 */ | ||||||
|   /* USER CODE BEGIN DebugMonitor_IRQn 1 */ |     /* USER CODE BEGIN DebugMonitor_IRQn 1 */ | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END DebugMonitor_IRQn 1 */ |     /* USER CODE END DebugMonitor_IRQn 1 */ | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
|   * @brief This function handles System tick timer. |   * @brief This function handles System tick timer. | ||||||
|   */ |   */ | ||||||
| void SysTick_Handler(void) | void SysTick_Handler(void) { | ||||||
| { |     /* USER CODE BEGIN SysTick_IRQn 0 */ | ||||||
|   /* USER CODE BEGIN SysTick_IRQn 0 */ |  | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END SysTick_IRQn 0 */ |     /* USER CODE END SysTick_IRQn 0 */ | ||||||
|   HAL_IncTick(); |     HAL_IncTick(); | ||||||
| #if (INCLUDE_xTaskGetSchedulerState == 1 ) | #if(INCLUDE_xTaskGetSchedulerState == 1) | ||||||
|   if (xTaskGetSchedulerState() != taskSCHEDULER_NOT_STARTED) |     if(xTaskGetSchedulerState() != taskSCHEDULER_NOT_STARTED) { | ||||||
|   { |  | ||||||
| #endif /* INCLUDE_xTaskGetSchedulerState */ | #endif /* INCLUDE_xTaskGetSchedulerState */ | ||||||
|   xPortSysTickHandler(); |         xPortSysTickHandler(); | ||||||
| #if (INCLUDE_xTaskGetSchedulerState == 1 ) | #if(INCLUDE_xTaskGetSchedulerState == 1) | ||||||
|   } |     } | ||||||
| #endif /* INCLUDE_xTaskGetSchedulerState */ | #endif /* INCLUDE_xTaskGetSchedulerState */ | ||||||
|   /* USER CODE BEGIN SysTick_IRQn 1 */ |     /* USER CODE BEGIN SysTick_IRQn 1 */ | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END SysTick_IRQn 1 */ |     /* USER CODE END SysTick_IRQn 1 */ | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /******************************************************************************/ | /******************************************************************************/ | ||||||
| @ -185,115 +173,105 @@ void SysTick_Handler(void) | |||||||
| /**
 | /**
 | ||||||
|   * @brief This function handles EXTI line0 interrupt. |   * @brief This function handles EXTI line0 interrupt. | ||||||
|   */ |   */ | ||||||
| void EXTI0_IRQHandler(void) | void EXTI0_IRQHandler(void) { | ||||||
| { |     /* USER CODE BEGIN EXTI0_IRQn 0 */ | ||||||
|   /* USER CODE BEGIN EXTI0_IRQn 0 */ |  | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END EXTI0_IRQn 0 */ |     /* USER CODE END EXTI0_IRQn 0 */ | ||||||
|   HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_0); |     HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_0); | ||||||
|   /* USER CODE BEGIN EXTI0_IRQn 1 */ |     /* USER CODE BEGIN EXTI0_IRQn 1 */ | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END EXTI0_IRQn 1 */ |     /* USER CODE END EXTI0_IRQn 1 */ | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
|   * @brief This function handles EXTI line1 interrupt. |   * @brief This function handles EXTI line1 interrupt. | ||||||
|   */ |   */ | ||||||
| void EXTI1_IRQHandler(void) | void EXTI1_IRQHandler(void) { | ||||||
| { |     /* USER CODE BEGIN EXTI1_IRQn 0 */ | ||||||
|   /* USER CODE BEGIN EXTI1_IRQn 0 */ |  | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END EXTI1_IRQn 0 */ |     /* USER CODE END EXTI1_IRQn 0 */ | ||||||
|   HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_1); |     HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_1); | ||||||
|   /* USER CODE BEGIN EXTI1_IRQn 1 */ |     /* USER CODE BEGIN EXTI1_IRQn 1 */ | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END EXTI1_IRQn 1 */ |     /* USER CODE END EXTI1_IRQn 1 */ | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
|   * @brief This function handles EXTI line2 interrupt. |   * @brief This function handles EXTI line2 interrupt. | ||||||
|   */ |   */ | ||||||
| void EXTI2_IRQHandler(void) | void EXTI2_IRQHandler(void) { | ||||||
| { |     /* USER CODE BEGIN EXTI2_IRQn 0 */ | ||||||
|   /* USER CODE BEGIN EXTI2_IRQn 0 */ |  | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END EXTI2_IRQn 0 */ |     /* USER CODE END EXTI2_IRQn 0 */ | ||||||
|   HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_2); |     HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_2); | ||||||
|   /* USER CODE BEGIN EXTI2_IRQn 1 */ |     /* USER CODE BEGIN EXTI2_IRQn 1 */ | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END EXTI2_IRQn 1 */ |     /* USER CODE END EXTI2_IRQn 1 */ | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
|   * @brief This function handles EXTI line4 interrupt. |   * @brief This function handles EXTI line4 interrupt. | ||||||
|   */ |   */ | ||||||
| void EXTI4_IRQHandler(void) | void EXTI4_IRQHandler(void) { | ||||||
| { |     /* USER CODE BEGIN EXTI4_IRQn 0 */ | ||||||
|   /* USER CODE BEGIN EXTI4_IRQn 0 */ |  | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END EXTI4_IRQn 0 */ |     /* USER CODE END EXTI4_IRQn 0 */ | ||||||
|   HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_4); |     HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_4); | ||||||
|   /* USER CODE BEGIN EXTI4_IRQn 1 */ |     /* USER CODE BEGIN EXTI4_IRQn 1 */ | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END EXTI4_IRQn 1 */ |     /* USER CODE END EXTI4_IRQn 1 */ | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
|   * @brief This function handles EXTI line[9:5] interrupts. |   * @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 BEGIN EXTI9_5_IRQn 0 */ |  | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END EXTI9_5_IRQn 0 */ |     /* USER CODE END EXTI9_5_IRQn 0 */ | ||||||
|   HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_6); |     HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_6); | ||||||
|   HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_8); |     HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_8); | ||||||
|   HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_9); |     HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_9); | ||||||
|   /* USER CODE BEGIN EXTI9_5_IRQn 1 */ |     /* USER CODE BEGIN EXTI9_5_IRQn 1 */ | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END EXTI9_5_IRQn 1 */ |     /* USER CODE END EXTI9_5_IRQn 1 */ | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void(*tim8_callback_ch2)(uint16_t ccr, TimerEvent tim_event); | void (*tim8_callback_ch2)(uint16_t ccr, TimerEvent tim_event); | ||||||
| 
 | 
 | ||||||
| void register_tim8_callback_ch2(void(*callback)(uint16_t ccr, TimerEvent tim_event)) { | void register_tim8_callback_ch2(void (*callback)(uint16_t ccr, TimerEvent tim_event)) { | ||||||
|   tim8_callback_ch2 = callback; |     tim8_callback_ch2 = callback; | ||||||
| } | } | ||||||
| /**
 | /**
 | ||||||
|   * @brief This function handles TIM8 capture compare interrupt. |   * @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 */ | ||||||
|   /* USER CODE BEGIN TIM8_CC_IRQn 0 */ |  | ||||||
| 
 | 
 | ||||||
|   /* Capture compare 2 event */ |     /* Capture compare 2 event */ | ||||||
|   if (__HAL_TIM_GET_FLAG(&htim8, TIM_FLAG_CC2) != RESET) |     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_IT_SOURCE(&htim8, TIM_IT_CC2) != RESET) |             __HAL_TIM_CLEAR_IT(&htim8, TIM_IT_CC2); | ||||||
|     { |             htim8.Channel = HAL_TIM_ACTIVE_CHANNEL_2; | ||||||
|       __HAL_TIM_CLEAR_IT(&htim8, TIM_IT_CC2); |             /* Input capture event */ | ||||||
|       htim8.Channel = HAL_TIM_ACTIVE_CHANNEL_2; |             if((htim8.Instance->CCMR1 & TIM_CCMR1_CC2S) != 0x00U) { | ||||||
|       /* Input capture event */ |                 /*
 | ||||||
|       if ((htim8.Instance->CCMR1 & TIM_CCMR1_CC2S) != 0x00U) |  | ||||||
|       { |  | ||||||
| /*
 |  | ||||||
| #if (USE_HAL_TIM_REGISTER_CALLBACKS == 1) | #if (USE_HAL_TIM_REGISTER_CALLBACKS == 1) | ||||||
|         htim->IC_CaptureCallback(htim); |         htim->IC_CaptureCallback(htim); | ||||||
| #else | #else | ||||||
|         HAL_TIM_IC_CaptureCallback(htim); |         HAL_TIM_IC_CaptureCallback(htim); | ||||||
| #endif | #endif | ||||||
| */ | */ | ||||||
|         if(tim8_callback_ch2 != NULL) { |                 if(tim8_callback_ch2 != NULL) { | ||||||
|           tim8_callback_ch2(htim8.Instance->CCR2, TimerEventInputCapture); |                     tim8_callback_ch2(htim8.Instance->CCR2, TimerEventInputCapture); | ||||||
|         } |                 } | ||||||
|       } |             } | ||||||
|       /* Output compare event */ |             /* Output compare event */ | ||||||
|       else |             else { | ||||||
|       { |                 if(tim8_callback_ch2 != NULL) { | ||||||
|         if(tim8_callback_ch2 != NULL) { |                     tim8_callback_ch2(0, TimerEventEndOfPulse); | ||||||
|           tim8_callback_ch2(0, TimerEventEndOfPulse); |                 } | ||||||
|         } |                 /*
 | ||||||
| /*
 |  | ||||||
| #if (USE_HAL_TIM_REGISTER_CALLBACKS == 1) | #if (USE_HAL_TIM_REGISTER_CALLBACKS == 1) | ||||||
|         htim->OC_DelayElapsedCallback(htim); |         htim->OC_DelayElapsedCallback(htim); | ||||||
|         htim->PWM_PulseFinishedCallback(htim); |         htim->PWM_PulseFinishedCallback(htim); | ||||||
| @ -302,31 +280,29 @@ void TIM8_CC_IRQHandler(void) | |||||||
|         HAL_TIM_PWM_PulseFinishedCallback(htim); |         HAL_TIM_PWM_PulseFinishedCallback(htim); | ||||||
| #endif | #endif | ||||||
| */ | */ | ||||||
|       } |             } | ||||||
|       htim8.Channel = HAL_TIM_ACTIVE_CHANNEL_CLEARED; |             htim8.Channel = HAL_TIM_ACTIVE_CHANNEL_CLEARED; | ||||||
|  |         } | ||||||
|     } |     } | ||||||
|   } |  | ||||||
| 
 | 
 | ||||||
|  |     /* USER CODE END TIM8_CC_IRQn 0 */ | ||||||
|  |     // HAL_TIM_IRQHandler(&htim8);
 | ||||||
|  |     /* USER CODE BEGIN TIM8_CC_IRQn 1 */ | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END TIM8_CC_IRQn 0 */ |     /* USER CODE END TIM8_CC_IRQn 1 */ | ||||||
|   // HAL_TIM_IRQHandler(&htim8);
 |  | ||||||
|   /* USER CODE BEGIN TIM8_CC_IRQn 1 */ |  | ||||||
| 
 |  | ||||||
|   /* USER CODE END TIM8_CC_IRQn 1 */ |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
|   * @brief This function handles USB OTG FS global interrupt. |   * @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 BEGIN OTG_FS_IRQn 0 */ |  | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END OTG_FS_IRQn 0 */ |     /* USER CODE END OTG_FS_IRQn 0 */ | ||||||
|   HAL_PCD_IRQHandler(&hpcd_USB_OTG_FS); |     HAL_PCD_IRQHandler(&hpcd_USB_OTG_FS); | ||||||
|   /* USER CODE BEGIN OTG_FS_IRQn 1 */ |     /* USER CODE BEGIN OTG_FS_IRQn 1 */ | ||||||
| 
 | 
 | ||||||
|   /* USER CODE END OTG_FS_IRQn 1 */ |     /* USER CODE END OTG_FS_IRQn 1 */ | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /* USER CODE BEGIN 1 */ | /* USER CODE BEGIN 1 */ | ||||||
|  | |||||||
| @ -91,16 +91,16 @@ | |||||||
| 
 | 
 | ||||||
| #include "stm32l4xx.h" | #include "stm32l4xx.h" | ||||||
| 
 | 
 | ||||||
| #if !defined  (HSE_VALUE) | #if !defined(HSE_VALUE) | ||||||
|   #define HSE_VALUE    8000000U  /*!< Value of the External oscillator in Hz */ | #define HSE_VALUE 8000000U /*!< Value of the External oscillator in Hz */ | ||||||
| #endif /* HSE_VALUE */ | #endif /* HSE_VALUE */ | ||||||
| 
 | 
 | ||||||
| #if !defined  (MSI_VALUE) | #if !defined(MSI_VALUE) | ||||||
|   #define MSI_VALUE    4000000U  /*!< Value of the Internal oscillator in Hz*/ | #define MSI_VALUE 4000000U /*!< Value of the Internal oscillator in Hz*/ | ||||||
| #endif /* MSI_VALUE */ | #endif /* MSI_VALUE */ | ||||||
| 
 | 
 | ||||||
| #if !defined  (HSI_VALUE) | #if !defined(HSI_VALUE) | ||||||
|   #define HSI_VALUE    16000000U /*!< Value of the Internal oscillator in Hz*/ | #define HSI_VALUE 16000000U /*!< Value of the Internal oscillator in Hz*/ | ||||||
| #endif /* HSI_VALUE */ | #endif /* HSI_VALUE */ | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
| @ -123,7 +123,8 @@ | |||||||
| /*!< Uncomment the following line if you need to relocate your vector Table in
 | /*!< Uncomment the following line if you need to relocate your vector Table in
 | ||||||
|      Internal SRAM. */ |      Internal SRAM. */ | ||||||
| /* #define VECT_TAB_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. */ |                                    This value must be a multiple of 0x200. */ | ||||||
| /******************************************************************************/ | /******************************************************************************/ | ||||||
| /**
 | /**
 | ||||||
| @ -141,7 +142,7 @@ | |||||||
| /** @addtogroup STM32L4xx_System_Private_Variables
 | /** @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() |       1) by calling CMSIS function SystemCoreClockUpdate() | ||||||
|       2) by calling HAL API function HAL_RCC_GetHCLKFreq() |       2) by calling HAL API function HAL_RCC_GetHCLKFreq() | ||||||
|       3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency |       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 |                is no need to call the 2 first functions listed above, since SystemCoreClock | ||||||
|                variable is updated automatically. |                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 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 uint8_t APBPrescTable[8] = {0U, 0U, 0U, 0U, 1U, 2U, 3U, 4U}; | ||||||
|   const uint32_t MSIRangeTable[12] = {100000U,   200000U,   400000U,   800000U,  1000000U,  2000000U, \ | const uint32_t MSIRangeTable[12] = {100000U, | ||||||
|                                       4000000U, 8000000U, 16000000U, 24000000U, 32000000U, 48000000U}; |                                     200000U, | ||||||
|  |                                     400000U, | ||||||
|  |                                     800000U, | ||||||
|  |                                     1000000U, | ||||||
|  |                                     2000000U, | ||||||
|  |                                     4000000U, | ||||||
|  |                                     8000000U, | ||||||
|  |                                     16000000U, | ||||||
|  |                                     24000000U, | ||||||
|  |                                     32000000U, | ||||||
|  |                                     48000000U}; | ||||||
| /**
 | /**
 | ||||||
|   * @} |   * @} | ||||||
|   */ |   */ | ||||||
| @ -177,37 +188,36 @@ | |||||||
|   * @retval None |   * @retval None | ||||||
|   */ |   */ | ||||||
| 
 | 
 | ||||||
| void SystemInit(void) | void SystemInit(void) { | ||||||
| { | /* FPU settings ------------------------------------------------------------*/ | ||||||
|   /* FPU settings ------------------------------------------------------------*/ | #if(__FPU_PRESENT == 1) && (__FPU_USED == 1) | ||||||
|   #if (__FPU_PRESENT == 1) && (__FPU_USED == 1) |     SCB->CPACR |= ((3UL << 10 * 2) | (3UL << 11 * 2)); /* set CP10 and CP11 Full Access */ | ||||||
|     SCB->CPACR |= ((3UL << 10*2)|(3UL << 11*2));  /* set CP10 and CP11 Full Access */ | #endif | ||||||
|   #endif |  | ||||||
| 
 | 
 | ||||||
|   /* Reset the RCC clock configuration to the default reset state ------------*/ |     /* Reset the RCC clock configuration to the default reset state ------------*/ | ||||||
|   /* Set MSION bit */ |     /* Set MSION bit */ | ||||||
|   RCC->CR |= RCC_CR_MSION; |     RCC->CR |= RCC_CR_MSION; | ||||||
| 
 | 
 | ||||||
|   /* Reset CFGR register */ |     /* Reset CFGR register */ | ||||||
|   RCC->CFGR = 0x00000000U; |     RCC->CFGR = 0x00000000U; | ||||||
| 
 | 
 | ||||||
|   /* Reset HSEON, CSSON , HSION, and PLLON bits */ |     /* Reset HSEON, CSSON , HSION, and PLLON bits */ | ||||||
|   RCC->CR &= 0xEAF6FFFFU; |     RCC->CR &= 0xEAF6FFFFU; | ||||||
| 
 | 
 | ||||||
|   /* Reset PLLCFGR register */ |     /* Reset PLLCFGR register */ | ||||||
|   RCC->PLLCFGR = 0x00001000U; |     RCC->PLLCFGR = 0x00001000U; | ||||||
| 
 | 
 | ||||||
|   /* Reset HSEBYP bit */ |     /* Reset HSEBYP bit */ | ||||||
|   RCC->CR &= 0xFFFBFFFFU; |     RCC->CR &= 0xFFFBFFFFU; | ||||||
| 
 | 
 | ||||||
|   /* Disable all interrupts */ |     /* Disable all interrupts */ | ||||||
|   RCC->CIER = 0x00000000U; |     RCC->CIER = 0x00000000U; | ||||||
| 
 | 
 | ||||||
|   /* Configure the Vector Table location add offset address ------------------*/ |     /* Configure the Vector Table location add offset address ------------------*/ | ||||||
| #ifdef VECT_TAB_SRAM | #ifdef VECT_TAB_SRAM | ||||||
|   SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */ |     SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */ | ||||||
| #else | #else | ||||||
|   SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */ |     SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */ | ||||||
| #endif | #endif | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -253,75 +263,68 @@ void SystemInit(void) | |||||||
|   * @param  None |   * @param  None | ||||||
|   * @retval None |   * @retval None | ||||||
|   */ |   */ | ||||||
| void SystemCoreClockUpdate(void) | void SystemCoreClockUpdate(void) { | ||||||
| { |     uint32_t tmp = 0U, msirange = 0U, pllvco = 0U, pllr = 2U, pllsource = 0U, pllm = 2U; | ||||||
|   uint32_t tmp = 0U, msirange = 0U, pllvco = 0U, pllr = 2U, pllsource = 0U, pllm = 2U; |  | ||||||
| 
 | 
 | ||||||
|   /* Get MSI Range frequency--------------------------------------------------*/ |     /* Get MSI Range frequency--------------------------------------------------*/ | ||||||
|   if((RCC->CR & RCC_CR_MSIRGSEL) == RESET) |     if((RCC->CR & RCC_CR_MSIRGSEL) == RESET) { /* MSISRANGE from RCC_CSR applies */ | ||||||
|   { /* MSISRANGE from RCC_CSR applies */ |         msirange = (RCC->CSR & RCC_CSR_MSISRANGE) >> 8U; | ||||||
|     msirange = (RCC->CSR & RCC_CSR_MSISRANGE) >> 8U; |     } else { /* MSIRANGE from RCC_CR applies */ | ||||||
|   } |         msirange = (RCC->CR & RCC_CR_MSIRANGE) >> 4U; | ||||||
|   else |     } | ||||||
|   { /* MSIRANGE from RCC_CR applies */ |     /*MSI frequency range in HZ*/ | ||||||
|     msirange = (RCC->CR & RCC_CR_MSIRANGE) >> 4U; |     msirange = MSIRangeTable[msirange]; | ||||||
|   } |  | ||||||
|   /*MSI frequency range in HZ*/ |  | ||||||
|   msirange = MSIRangeTable[msirange]; |  | ||||||
| 
 | 
 | ||||||
|   /* Get SYSCLK source -------------------------------------------------------*/ |     /* Get SYSCLK source -------------------------------------------------------*/ | ||||||
|   switch (RCC->CFGR & RCC_CFGR_SWS) |     switch(RCC->CFGR & RCC_CFGR_SWS) { | ||||||
|   { |     case 0x00: /* MSI used as system clock source */ | ||||||
|     case 0x00:  /* MSI used as system clock source */ |         SystemCoreClock = msirange; | ||||||
|       SystemCoreClock = msirange; |         break; | ||||||
|       break; |  | ||||||
| 
 | 
 | ||||||
|     case 0x04:  /* HSI used as system clock source */ |     case 0x04: /* HSI used as system clock source */ | ||||||
|       SystemCoreClock = HSI_VALUE; |         SystemCoreClock = HSI_VALUE; | ||||||
|       break; |         break; | ||||||
| 
 | 
 | ||||||
|     case 0x08:  /* HSE used as system clock source */ |     case 0x08: /* HSE used as system clock source */ | ||||||
|       SystemCoreClock = HSE_VALUE; |         SystemCoreClock = HSE_VALUE; | ||||||
|       break; |         break; | ||||||
| 
 | 
 | ||||||
|     case 0x0C:  /* PLL used as system clock  source */ |     case 0x0C: /* PLL used as system clock  source */ | ||||||
|       /* PLL_VCO = (HSE_VALUE or HSI_VALUE or MSI_VALUE/ PLLM) * PLLN
 |         /* PLL_VCO = (HSE_VALUE or HSI_VALUE or MSI_VALUE/ PLLM) * PLLN
 | ||||||
|          SYSCLK = PLL_VCO / PLLR |          SYSCLK = PLL_VCO / PLLR | ||||||
|          */ |          */ | ||||||
|       pllsource = (RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC); |         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 */ | ||||||
|         case 0x02:  /* HSI used as PLL clock source */ |             pllvco = (HSI_VALUE / pllm); | ||||||
|           pllvco = (HSI_VALUE / pllm); |             break; | ||||||
|           break; |  | ||||||
| 
 | 
 | ||||||
|         case 0x03:  /* HSE used as PLL clock source */ |         case 0x03: /* HSE used as PLL clock source */ | ||||||
|           pllvco = (HSE_VALUE / pllm); |             pllvco = (HSE_VALUE / pllm); | ||||||
|           break; |             break; | ||||||
| 
 | 
 | ||||||
|         default:    /* MSI used as PLL clock source */ |         default: /* MSI used as PLL clock source */ | ||||||
|           pllvco = (msirange / pllm); |             pllvco = (msirange / pllm); | ||||||
|           break; |             break; | ||||||
|       } |         } | ||||||
|       pllvco = pllvco * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 8U); |         pllvco = pllvco * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 8U); | ||||||
|       pllr = (((RCC->PLLCFGR & RCC_PLLCFGR_PLLR) >> 25U) + 1U) * 2U; |         pllr = (((RCC->PLLCFGR & RCC_PLLCFGR_PLLR) >> 25U) + 1U) * 2U; | ||||||
|       SystemCoreClock = pllvco/pllr; |         SystemCoreClock = pllvco / pllr; | ||||||
|       break; |         break; | ||||||
| 
 | 
 | ||||||
|     default: |     default: | ||||||
|       SystemCoreClock = msirange; |         SystemCoreClock = msirange; | ||||||
|       break; |         break; | ||||||
|   } |     } | ||||||
|   /* Compute HCLK clock frequency --------------------------------------------*/ |     /* Compute HCLK clock frequency --------------------------------------------*/ | ||||||
|   /* Get HCLK prescaler */ |     /* Get HCLK prescaler */ | ||||||
|   tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4U)]; |     tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4U)]; | ||||||
|   /* HCLK clock frequency */ |     /* HCLK clock frequency */ | ||||||
|   SystemCoreClock >>= tmp; |     SystemCoreClock >>= tmp; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| /**
 | /**
 | ||||||
|   * @} |   * @} | ||||||
|   */ |   */ | ||||||
|  | |||||||
| @ -63,32 +63,27 @@ extern USBD_DescriptorsTypeDef FS_Desc; | |||||||
|   * Init USB device Library, add supported class and start the library |   * Init USB device Library, add supported class and start the library | ||||||
|   * @retval None |   * @retval None | ||||||
|   */ |   */ | ||||||
| void MX_USB_DEVICE_Init(void) | void MX_USB_DEVICE_Init(void) { | ||||||
| { |     /* USER CODE BEGIN USB_DEVICE_Init_PreTreatment */ | ||||||
|   /* USER CODE BEGIN USB_DEVICE_Init_PreTreatment */ | 
 | ||||||
|    |     /* USER CODE END USB_DEVICE_Init_PreTreatment */ | ||||||
|   /* USER CODE END USB_DEVICE_Init_PreTreatment */ | 
 | ||||||
|    |     /* Init Device Library, add supported class and start the library. */ | ||||||
|   /* 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(); | ||||||
|   { |     } | ||||||
|     Error_Handler(); |     if(USBD_RegisterClass(&hUsbDeviceFS, &USBD_CDC) != USBD_OK) { | ||||||
|   } |         Error_Handler(); | ||||||
|   if (USBD_RegisterClass(&hUsbDeviceFS, &USBD_CDC) != USBD_OK) |     } | ||||||
|   { |     if(USBD_CDC_RegisterInterface(&hUsbDeviceFS, &USBD_Interface_fops_FS) != USBD_OK) { | ||||||
|     Error_Handler(); |         Error_Handler(); | ||||||
|   } |     } | ||||||
|   if (USBD_CDC_RegisterInterface(&hUsbDeviceFS, &USBD_Interface_fops_FS) != USBD_OK) |     if(USBD_Start(&hUsbDeviceFS) != USBD_OK) { | ||||||
|   { |         Error_Handler(); | ||||||
|     Error_Handler(); |     } | ||||||
|   } |     /* USER CODE BEGIN USB_DEVICE_Init_PostTreatment */ | ||||||
|   if (USBD_Start(&hUsbDeviceFS) != USBD_OK) | 
 | ||||||
|   { |     /* USER CODE END USB_DEVICE_Init_PostTreatment */ | ||||||
|     Error_Handler(); |  | ||||||
|   } |  | ||||||
|   /* USER CODE BEGIN USB_DEVICE_Init_PostTreatment */ |  | ||||||
|    |  | ||||||
|   /* USER CODE END USB_DEVICE_Init_PostTreatment */ |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
|  | |||||||
| @ -65,8 +65,8 @@ | |||||||
| /* USER CODE BEGIN PRIVATE_DEFINES */ | /* USER CODE BEGIN PRIVATE_DEFINES */ | ||||||
| /* Define size for the receive and transmit buffer over CDC */ | /* Define size for the receive and transmit buffer over CDC */ | ||||||
| /* It's up to user to redefine and/or remove those define */ | /* It's up to user to redefine and/or remove those define */ | ||||||
| #define APP_RX_DATA_SIZE  2048 | #define APP_RX_DATA_SIZE 2048 | ||||||
| #define APP_TX_DATA_SIZE  2048 | #define APP_TX_DATA_SIZE 2048 | ||||||
| /* USER CODE END PRIVATE_DEFINES */ | /* USER CODE END PRIVATE_DEFINES */ | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
| @ -129,7 +129,7 @@ extern USBD_HandleTypeDef hUsbDeviceFS; | |||||||
| static int8_t CDC_Init_FS(void); | static int8_t CDC_Init_FS(void); | ||||||
| static int8_t CDC_DeInit_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_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 */ | /* USER CODE BEGIN PRIVATE_FUNCTIONS_DECLARATION */ | ||||||
| 
 | 
 | ||||||
| @ -139,38 +139,33 @@ static int8_t CDC_Receive_FS(uint8_t* pbuf, uint32_t *Len); | |||||||
|   * @} |   * @} | ||||||
|   */ |   */ | ||||||
| 
 | 
 | ||||||
| USBD_CDC_ItfTypeDef USBD_Interface_fops_FS = | USBD_CDC_ItfTypeDef USBD_Interface_fops_FS = {CDC_Init_FS, | ||||||
| { |                                               CDC_DeInit_FS, | ||||||
|   CDC_Init_FS, |                                               CDC_Control_FS, | ||||||
|   CDC_DeInit_FS, |                                               CDC_Receive_FS}; | ||||||
|   CDC_Control_FS, |  | ||||||
|   CDC_Receive_FS |  | ||||||
| }; |  | ||||||
| 
 | 
 | ||||||
| /* Private functions ---------------------------------------------------------*/ | /* Private functions ---------------------------------------------------------*/ | ||||||
| /**
 | /**
 | ||||||
|   * @brief  Initializes the CDC media low layer over the FS USB IP |   * @brief  Initializes the CDC media low layer over the FS USB IP | ||||||
|   * @retval USBD_OK if all operations are OK else USBD_FAIL |   * @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 */ | ||||||
|   /* USER CODE BEGIN 3 */ |     /* Set Application Buffers */ | ||||||
|   /* Set Application Buffers */ |     USBD_CDC_SetTxBuffer(&hUsbDeviceFS, UserTxBufferFS, 0); | ||||||
|   USBD_CDC_SetTxBuffer(&hUsbDeviceFS, UserTxBufferFS, 0); |     USBD_CDC_SetRxBuffer(&hUsbDeviceFS, UserRxBufferFS); | ||||||
|   USBD_CDC_SetRxBuffer(&hUsbDeviceFS, UserRxBufferFS); |     return (USBD_OK); | ||||||
|   return (USBD_OK); |     /* USER CODE END 3 */ | ||||||
|   /* USER CODE END 3 */ |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
|   * @brief  DeInitializes the CDC media low layer |   * @brief  DeInitializes the CDC media low layer | ||||||
|   * @retval USBD_OK if all operations are OK else USBD_FAIL |   * @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 */ | ||||||
|   /* USER CODE BEGIN 4 */ |     return (USBD_OK); | ||||||
|   return (USBD_OK); |     /* USER CODE END 4 */ | ||||||
|   /* USER CODE END 4 */ |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
| @ -180,70 +175,68 @@ static int8_t CDC_DeInit_FS(void) | |||||||
|   * @param  length: Number of data to be sent (in bytes) |   * @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 |   * @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 */ | ||||||
|   /* USER CODE BEGIN 5 */ |     switch(cmd) { | ||||||
|   switch(cmd) |  | ||||||
|   { |  | ||||||
|     case CDC_SEND_ENCAPSULATED_COMMAND: |     case CDC_SEND_ENCAPSULATED_COMMAND: | ||||||
| 
 | 
 | ||||||
|     break; |         break; | ||||||
| 
 | 
 | ||||||
|     case CDC_GET_ENCAPSULATED_RESPONSE: |     case CDC_GET_ENCAPSULATED_RESPONSE: | ||||||
| 
 | 
 | ||||||
|     break; |         break; | ||||||
| 
 | 
 | ||||||
|     case CDC_SET_COMM_FEATURE: |     case CDC_SET_COMM_FEATURE: | ||||||
| 
 | 
 | ||||||
|     break; |         break; | ||||||
| 
 | 
 | ||||||
|     case CDC_GET_COMM_FEATURE: |     case CDC_GET_COMM_FEATURE: | ||||||
| 
 | 
 | ||||||
|     break; |         break; | ||||||
| 
 | 
 | ||||||
|     case CDC_CLEAR_COMM_FEATURE: |     case CDC_CLEAR_COMM_FEATURE: | ||||||
| 
 | 
 | ||||||
|     break; |         break; | ||||||
| 
 | 
 | ||||||
|   /*******************************************************************************/ |         /*******************************************************************************/ | ||||||
|   /* Line Coding Structure                                                       */ |         /* Line Coding Structure                                                       */ | ||||||
|   /*-----------------------------------------------------------------------------*/ |         /*-----------------------------------------------------------------------------*/ | ||||||
|   /* Offset | Field       | Size | Value  | Description                          */ |         /* Offset | Field       | Size | Value  | Description                          */ | ||||||
|   /* 0      | dwDTERate   |   4  | Number |Data terminal rate, in bits per second*/ |         /* 0      | dwDTERate   |   4  | Number |Data terminal rate, in bits per second*/ | ||||||
|   /* 4      | bCharFormat |   1  | Number | Stop bits                            */ |         /* 4      | bCharFormat |   1  | Number | Stop bits                            */ | ||||||
|   /*                                        0 - 1 Stop bit                       */ |         /*                                        0 - 1 Stop bit                       */ | ||||||
|   /*                                        1 - 1.5 Stop bits                    */ |         /*                                        1 - 1.5 Stop bits                    */ | ||||||
|   /*                                        2 - 2 Stop bits                      */ |         /*                                        2 - 2 Stop bits                      */ | ||||||
|   /* 5      | bParityType |  1   | Number | Parity                               */ |         /* 5      | bParityType |  1   | Number | Parity                               */ | ||||||
|   /*                                        0 - None                             */ |         /*                                        0 - None                             */ | ||||||
|   /*                                        1 - Odd                              */ |         /*                                        1 - Odd                              */ | ||||||
|   /*                                        2 - Even                             */ |         /*                                        2 - Even                             */ | ||||||
|   /*                                        3 - Mark                             */ |         /*                                        3 - Mark                             */ | ||||||
|   /*                                        4 - Space                            */ |         /*                                        4 - Space                            */ | ||||||
|   /* 6      | bDataBits  |   1   | Number Data bits (5, 6, 7, 8 or 16).          */ |         /* 6      | bDataBits  |   1   | Number Data bits (5, 6, 7, 8 or 16).          */ | ||||||
|   /*******************************************************************************/ |         /*******************************************************************************/ | ||||||
|     case CDC_SET_LINE_CODING: |     case CDC_SET_LINE_CODING: | ||||||
| 
 | 
 | ||||||
|     break; |         break; | ||||||
| 
 | 
 | ||||||
|     case CDC_GET_LINE_CODING: |     case CDC_GET_LINE_CODING: | ||||||
| 
 | 
 | ||||||
|     break; |         break; | ||||||
| 
 | 
 | ||||||
|     case CDC_SET_CONTROL_LINE_STATE: |     case CDC_SET_CONTROL_LINE_STATE: | ||||||
| 
 | 
 | ||||||
|     break; |         break; | ||||||
| 
 | 
 | ||||||
|     case CDC_SEND_BREAK: |     case CDC_SEND_BREAK: | ||||||
| 
 | 
 | ||||||
|     break; |         break; | ||||||
| 
 | 
 | ||||||
|   default: |     default: | ||||||
|     break; |         break; | ||||||
|   } |     } | ||||||
| 
 | 
 | ||||||
|   return (USBD_OK); |     return (USBD_OK); | ||||||
|   /* USER CODE END 5 */ |     /* USER CODE END 5 */ | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
| @ -260,13 +253,12 @@ static int8_t CDC_Control_FS(uint8_t cmd, uint8_t* pbuf, uint16_t length) | |||||||
|   * @param  Len: Number of data received (in bytes) |   * @param  Len: Number of data received (in bytes) | ||||||
|   * @retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL |   * @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 */ | ||||||
|   /* USER CODE BEGIN 6 */ |     USBD_CDC_SetRxBuffer(&hUsbDeviceFS, &Buf[0]); | ||||||
|   USBD_CDC_SetRxBuffer(&hUsbDeviceFS, &Buf[0]); |     USBD_CDC_ReceivePacket(&hUsbDeviceFS); | ||||||
|   USBD_CDC_ReceivePacket(&hUsbDeviceFS); |     return (USBD_OK); | ||||||
|   return (USBD_OK); |     /* USER CODE END 6 */ | ||||||
|   /* USER CODE END 6 */ |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
| @ -280,18 +272,17 @@ static int8_t CDC_Receive_FS(uint8_t* Buf, uint32_t *Len) | |||||||
|   * @param  Len: Number of data to be sent (in bytes) |   * @param  Len: Number of data to be sent (in bytes) | ||||||
|   * @retval USBD_OK if all operations are OK else USBD_FAIL or USBD_BUSY |   * @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; | ||||||
|   uint8_t result = USBD_OK; |     /* USER CODE BEGIN 7 */ | ||||||
|   /* USER CODE BEGIN 7 */ |     USBD_CDC_HandleTypeDef* hcdc = (USBD_CDC_HandleTypeDef*)hUsbDeviceFS.pClassData; | ||||||
|   USBD_CDC_HandleTypeDef *hcdc = (USBD_CDC_HandleTypeDef*)hUsbDeviceFS.pClassData; |     if(hcdc->TxState != 0) { | ||||||
|   if (hcdc->TxState != 0){ |         return USBD_BUSY; | ||||||
|     return USBD_BUSY; |     } | ||||||
|   } |     USBD_CDC_SetTxBuffer(&hUsbDeviceFS, Buf, Len); | ||||||
|   USBD_CDC_SetTxBuffer(&hUsbDeviceFS, Buf, Len); |     result = USBD_CDC_TransmitPacket(&hUsbDeviceFS); | ||||||
|   result = USBD_CDC_TransmitPacket(&hUsbDeviceFS); |     /* USER CODE END 7 */ | ||||||
|   /* USER CODE END 7 */ |     return result; | ||||||
|   return result; |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /* USER CODE BEGIN PRIVATE_FUNCTIONS_IMPLEMENTATION */ | /* USER CODE BEGIN PRIVATE_FUNCTIONS_IMPLEMENTATION */ | ||||||
|  | |||||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @ -63,15 +63,15 @@ | |||||||
|   * @{ |   * @{ | ||||||
|   */ |   */ | ||||||
| 
 | 
 | ||||||
| #define USBD_VID     1155 | #define USBD_VID 1155 | ||||||
| #define USBD_LANGID_STRING     1033 | #define USBD_LANGID_STRING 1033 | ||||||
| #define USBD_MANUFACTURER_STRING     "STMicroelectronics" | #define USBD_MANUFACTURER_STRING "STMicroelectronics" | ||||||
| #define USBD_PID_FS     22336 | #define USBD_PID_FS 22336 | ||||||
| #define USBD_PRODUCT_STRING_FS     "Flipper Zero Virtual ComPort" | #define USBD_PRODUCT_STRING_FS "Flipper Zero Virtual ComPort" | ||||||
| #define USBD_CONFIGURATION_STRING_FS     "CDC Config" | #define USBD_CONFIGURATION_STRING_FS "CDC Config" | ||||||
| #define USBD_INTERFACE_STRING_FS     "CDC Interface" | #define USBD_INTERFACE_STRING_FS "CDC Interface" | ||||||
| 
 | 
 | ||||||
| #define USB_SIZ_BOS_DESC            0x0C | #define USB_SIZ_BOS_DESC 0x0C | ||||||
| 
 | 
 | ||||||
| /* USER CODE BEGIN PRIVATE_DEFINES */ | /* USER CODE BEGIN PRIVATE_DEFINES */ | ||||||
| 
 | 
 | ||||||
| @ -97,34 +97,33 @@ | |||||||
| /**
 | /**
 | ||||||
|   * @} |   * @} | ||||||
|   */ |   */ | ||||||
|    | 
 | ||||||
| /** @defgroup USBD_DESC_Private_FunctionPrototypes USBD_DESC_Private_FunctionPrototypes
 | /** @defgroup USBD_DESC_Private_FunctionPrototypes USBD_DESC_Private_FunctionPrototypes
 | ||||||
|   * @brief Private functions declaration. |   * @brief Private functions declaration. | ||||||
|   * @{ |   * @{ | ||||||
|   */ |   */ | ||||||
|    | 
 | ||||||
| static void Get_SerialNum(void); | 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
 | /** @defgroup USBD_DESC_Private_FunctionPrototypes USBD_DESC_Private_FunctionPrototypes
 | ||||||
|   * @brief Private functions declaration for FS. |   * @brief Private functions declaration for FS. | ||||||
|   * @{ |   * @{ | ||||||
|   */ |   */ | ||||||
| 
 | 
 | ||||||
| uint8_t * USBD_FS_DeviceDescriptor(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_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t* length); | ||||||
| uint8_t * USBD_FS_ManufacturerStrDescriptor(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_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t* length); | ||||||
| uint8_t * USBD_FS_SerialStrDescriptor(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_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t* length); | ||||||
| uint8_t * USBD_FS_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); | uint8_t* USBD_FS_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t* length); | ||||||
| #if (USBD_LPM_ENABLED == 1) | #if(USBD_LPM_ENABLED == 1) | ||||||
| uint8_t * USBD_FS_USR_BOSDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); | uint8_t* USBD_FS_USR_BOSDescriptor(USBD_SpeedTypeDef speed, uint16_t* length); | ||||||
| #endif /* (USBD_LPM_ENABLED == 1) */ | #endif /* (USBD_LPM_ENABLED == 1) */ | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
| @ -136,74 +135,71 @@ uint8_t * USBD_FS_USR_BOSDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); | |||||||
|   * @{ |   * @{ | ||||||
|   */ |   */ | ||||||
| 
 | 
 | ||||||
| USBD_DescriptorsTypeDef FS_Desc = | USBD_DescriptorsTypeDef FS_Desc = {USBD_FS_DeviceDescriptor, | ||||||
| { |                                    USBD_FS_LangIDStrDescriptor, | ||||||
|   USBD_FS_DeviceDescriptor |                                    USBD_FS_ManufacturerStrDescriptor, | ||||||
| , USBD_FS_LangIDStrDescriptor |                                    USBD_FS_ProductStrDescriptor, | ||||||
| , USBD_FS_ManufacturerStrDescriptor |                                    USBD_FS_SerialStrDescriptor, | ||||||
| , USBD_FS_ProductStrDescriptor |                                    USBD_FS_ConfigStrDescriptor, | ||||||
| , USBD_FS_SerialStrDescriptor |                                    USBD_FS_InterfaceStrDescriptor | ||||||
| , USBD_FS_ConfigStrDescriptor | #if(USBD_LPM_ENABLED == 1) | ||||||
| , USBD_FS_InterfaceStrDescriptor |                                    , | ||||||
| #if (USBD_LPM_ENABLED == 1) |                                    USBD_FS_USR_BOSDescriptor | ||||||
| , USBD_FS_USR_BOSDescriptor |  | ||||||
| #endif /* (USBD_LPM_ENABLED == 1) */ | #endif /* (USBD_LPM_ENABLED == 1) */ | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| #if defined ( __ICCARM__ ) /* IAR Compiler */ | #if defined(__ICCARM__) /* IAR Compiler */ | ||||||
|   #pragma data_alignment=4 | #pragma data_alignment = 4 | ||||||
| #endif /* defined ( __ICCARM__ ) */ | #endif /* defined ( __ICCARM__ ) */ | ||||||
| /** USB standard device descriptor. */ | /** 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 */ | ||||||
|   0x12,                       /*bLength */ |     USB_DESC_TYPE_DEVICE, /*bDescriptorType*/ | ||||||
|   USB_DESC_TYPE_DEVICE,       /*bDescriptorType*/ | #if(USBD_LPM_ENABLED == 1) | ||||||
| #if (USBD_LPM_ENABLED == 1) |     0x01, | ||||||
|   0x01,                       /*bcdUSB */ /* changed to USB version 2.01
 | /*bcdUSB */ /* changed to USB version 2.01
 | ||||||
|                                              in order to support LPM L1 suspend |                                              in order to support LPM L1 suspend | ||||||
|                                              resume test of USBCV3.0*/ |                                              resume test of USBCV3.0*/ | ||||||
| #else | #else | ||||||
|   0x00,                       /*bcdUSB */ |     0x00, /*bcdUSB */ | ||||||
| #endif /* (USBD_LPM_ENABLED == 1) */ | #endif /* (USBD_LPM_ENABLED == 1) */ | ||||||
|   0x02, |     0x02, | ||||||
|   0x02,                       /*bDeviceClass*/ |     0x02, /*bDeviceClass*/ | ||||||
|   0x02,                       /*bDeviceSubClass*/ |     0x02, /*bDeviceSubClass*/ | ||||||
|   0x00,                       /*bDeviceProtocol*/ |     0x00, /*bDeviceProtocol*/ | ||||||
|   USB_MAX_EP0_SIZE,           /*bMaxPacketSize*/ |     USB_MAX_EP0_SIZE, /*bMaxPacketSize*/ | ||||||
|   LOBYTE(USBD_VID),           /*idVendor*/ |     LOBYTE(USBD_VID), /*idVendor*/ | ||||||
|   HIBYTE(USBD_VID),           /*idVendor*/ |     HIBYTE(USBD_VID), /*idVendor*/ | ||||||
|   LOBYTE(USBD_PID_FS),        /*idProduct*/ |     LOBYTE(USBD_PID_FS), /*idProduct*/ | ||||||
|   HIBYTE(USBD_PID_FS),        /*idProduct*/ |     HIBYTE(USBD_PID_FS), /*idProduct*/ | ||||||
|   0x00,                       /*bcdDevice rel. 2.00*/ |     0x00, /*bcdDevice rel. 2.00*/ | ||||||
|   0x02, |     0x02, | ||||||
|   USBD_IDX_MFC_STR,           /*Index of manufacturer  string*/ |     USBD_IDX_MFC_STR, /*Index of manufacturer  string*/ | ||||||
|   USBD_IDX_PRODUCT_STR,       /*Index of product string*/ |     USBD_IDX_PRODUCT_STR, /*Index of product string*/ | ||||||
|   USBD_IDX_SERIAL_STR,        /*Index of serial number string*/ |     USBD_IDX_SERIAL_STR, /*Index of serial number string*/ | ||||||
|   USBD_MAX_NUM_CONFIGURATION  /*bNumConfigurations*/ |     USBD_MAX_NUM_CONFIGURATION /*bNumConfigurations*/ | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| /* USB_DeviceDescriptor */ | /* USB_DeviceDescriptor */ | ||||||
| /** BOS descriptor. */ | /** BOS descriptor. */ | ||||||
| #if (USBD_LPM_ENABLED == 1) | #if(USBD_LPM_ENABLED == 1) | ||||||
| #if defined ( __ICCARM__ ) /* IAR Compiler */ | #if defined(__ICCARM__) /* IAR Compiler */ | ||||||
|   #pragma data_alignment=4 | #pragma data_alignment = 4 | ||||||
| #endif /* defined ( __ICCARM__ ) */ | #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, | ||||||
|   0x5, |     USB_DESC_TYPE_BOS, | ||||||
|   USB_DESC_TYPE_BOS, |     0xC, | ||||||
|   0xC, |     0x0, | ||||||
|   0x0, |     0x1, /* 1 device capability*/ | ||||||
|   0x1,  /* 1 device capability*/ |     /* device capability*/ | ||||||
|         /* device capability*/ |     0x7, | ||||||
|   0x7, |     USB_DEVICE_CAPABITY_TYPE, | ||||||
|   USB_DEVICE_CAPABITY_TYPE, |     0x2, | ||||||
|   0x2, |     0x2, /* LPM capability bit set*/ | ||||||
|   0x2,  /* LPM capability bit set*/ |     0x0, | ||||||
|   0x0, |     0x0, | ||||||
|   0x0, |     0x0}; | ||||||
|   0x0 |  | ||||||
| }; |  | ||||||
| #endif /* (USBD_LPM_ENABLED == 1) */ | #endif /* (USBD_LPM_ENABLED == 1) */ | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
| @ -215,31 +211,29 @@ __ALIGN_BEGIN uint8_t USBD_FS_BOSDesc[USB_SIZ_BOS_DESC] __ALIGN_END = | |||||||
|   * @{ |   * @{ | ||||||
|   */ |   */ | ||||||
| 
 | 
 | ||||||
| #if defined ( __ICCARM__ ) /* IAR Compiler */ | #if defined(__ICCARM__) /* IAR Compiler */ | ||||||
|   #pragma data_alignment=4 | #pragma data_alignment = 4 | ||||||
| #endif /* defined ( __ICCARM__ ) */ | #endif /* defined ( __ICCARM__ ) */ | ||||||
| 
 | 
 | ||||||
| /** USB lang indentifier descriptor. */ | /** 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_LEN_LANGID_STR_DESC, |     USB_DESC_TYPE_STRING, | ||||||
|      USB_DESC_TYPE_STRING, |     LOBYTE(USBD_LANGID_STRING), | ||||||
|      LOBYTE(USBD_LANGID_STRING), |     HIBYTE(USBD_LANGID_STRING)}; | ||||||
|      HIBYTE(USBD_LANGID_STRING) |  | ||||||
| }; |  | ||||||
| 
 | 
 | ||||||
| #if defined ( __ICCARM__ ) /* IAR Compiler */ | #if defined(__ICCARM__) /* IAR Compiler */ | ||||||
|   #pragma data_alignment=4 | #pragma data_alignment = 4 | ||||||
| #endif /* defined ( __ICCARM__ ) */ | #endif /* defined ( __ICCARM__ ) */ | ||||||
| /* Internal string descriptor. */ | /* Internal string descriptor. */ | ||||||
| __ALIGN_BEGIN uint8_t USBD_StrDesc[USBD_MAX_STR_DESC_SIZ] __ALIGN_END; | __ALIGN_BEGIN uint8_t USBD_StrDesc[USBD_MAX_STR_DESC_SIZ] __ALIGN_END; | ||||||
| 
 | 
 | ||||||
| #if defined ( __ICCARM__ ) /*!< IAR Compiler */ | #if defined(__ICCARM__) /*!< IAR Compiler */ | ||||||
|   #pragma data_alignment=4    | #pragma data_alignment = 4 | ||||||
| #endif | #endif | ||||||
| __ALIGN_BEGIN uint8_t USBD_StringSerial[USB_SIZ_STRING_SERIAL] __ALIGN_END = { | __ALIGN_BEGIN uint8_t USBD_StringSerial[USB_SIZ_STRING_SERIAL] __ALIGN_END = { | ||||||
|   USB_SIZ_STRING_SERIAL, |     USB_SIZ_STRING_SERIAL, | ||||||
|   USB_DESC_TYPE_STRING, |     USB_DESC_TYPE_STRING, | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
| @ -257,11 +251,10 @@ __ALIGN_BEGIN uint8_t USBD_StringSerial[USB_SIZ_STRING_SERIAL] __ALIGN_END = { | |||||||
|   * @param  length : Pointer to data length variable |   * @param  length : Pointer to data length variable | ||||||
|   * @retval Pointer to descriptor buffer |   * @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); | ||||||
|   UNUSED(speed); |     *length = sizeof(USBD_FS_DeviceDesc); | ||||||
|   *length = sizeof(USBD_FS_DeviceDesc); |     return USBD_FS_DeviceDesc; | ||||||
|   return USBD_FS_DeviceDesc; |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
| @ -270,11 +263,10 @@ uint8_t * USBD_FS_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) | |||||||
|   * @param  length : Pointer to data length variable |   * @param  length : Pointer to data length variable | ||||||
|   * @retval Pointer to descriptor buffer |   * @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); | ||||||
|   UNUSED(speed); |     *length = sizeof(USBD_LangIDDesc); | ||||||
|   *length = sizeof(USBD_LangIDDesc); |     return USBD_LangIDDesc; | ||||||
|   return USBD_LangIDDesc; |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
| @ -283,17 +275,13 @@ uint8_t * USBD_FS_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) | |||||||
|   * @param  length : Pointer to data length variable |   * @param  length : Pointer to data length variable | ||||||
|   * @retval Pointer to descriptor buffer |   * @retval Pointer to descriptor buffer | ||||||
|   */ |   */ | ||||||
| uint8_t * USBD_FS_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) | uint8_t* USBD_FS_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t* length) { | ||||||
| { |     if(speed == 0) { | ||||||
|   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); |         USBD_GetString((uint8_t*)USBD_PRODUCT_STRING_FS, USBD_StrDesc, length); | ||||||
|   } |     } | ||||||
|   else |     return USBD_StrDesc; | ||||||
|   { |  | ||||||
|     USBD_GetString((uint8_t *)USBD_PRODUCT_STRING_FS, USBD_StrDesc, length); |  | ||||||
|   } |  | ||||||
|   return USBD_StrDesc; |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
| @ -302,11 +290,10 @@ uint8_t * USBD_FS_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length | |||||||
|   * @param  length : Pointer to data length variable |   * @param  length : Pointer to data length variable | ||||||
|   * @retval Pointer to descriptor buffer |   * @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); | ||||||
|   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; | ||||||
|   return USBD_StrDesc; |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
| @ -315,18 +302,17 @@ uint8_t * USBD_FS_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *l | |||||||
|   * @param  length : Pointer to data length variable |   * @param  length : Pointer to data length variable | ||||||
|   * @retval Pointer to descriptor buffer |   * @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); | ||||||
|   UNUSED(speed); |     *length = USB_SIZ_STRING_SERIAL; | ||||||
|   *length = USB_SIZ_STRING_SERIAL; |  | ||||||
| 
 | 
 | ||||||
|   /* Update the serial number string descriptor with the data from the unique
 |     /* Update the serial number string descriptor with the data from the unique
 | ||||||
|    * ID */ |    * ID */ | ||||||
|   Get_SerialNum(); |     Get_SerialNum(); | ||||||
|   /* USER CODE BEGIN USBD_FS_SerialStrDescriptor */ |     /* USER CODE BEGIN USBD_FS_SerialStrDescriptor */ | ||||||
|    | 
 | ||||||
|   /* USER CODE END USBD_FS_SerialStrDescriptor */ |     /* USER CODE END USBD_FS_SerialStrDescriptor */ | ||||||
|   return (uint8_t *) USBD_StringSerial; |     return (uint8_t*)USBD_StringSerial; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
| @ -335,17 +321,13 @@ uint8_t * USBD_FS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) | |||||||
|   * @param  length : Pointer to data length variable |   * @param  length : Pointer to data length variable | ||||||
|   * @retval Pointer to descriptor buffer |   * @retval Pointer to descriptor buffer | ||||||
|   */ |   */ | ||||||
| uint8_t * USBD_FS_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) | uint8_t* USBD_FS_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t* length) { | ||||||
| { |     if(speed == USBD_SPEED_HIGH) { | ||||||
|   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); |         USBD_GetString((uint8_t*)USBD_CONFIGURATION_STRING_FS, USBD_StrDesc, length); | ||||||
|   } |     } | ||||||
|   else |     return USBD_StrDesc; | ||||||
|   { |  | ||||||
|     USBD_GetString((uint8_t *)USBD_CONFIGURATION_STRING_FS, USBD_StrDesc, length); |  | ||||||
|   } |  | ||||||
|   return USBD_StrDesc; |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
| @ -354,31 +336,26 @@ uint8_t * USBD_FS_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) | |||||||
|   * @param  length : Pointer to data length variable |   * @param  length : Pointer to data length variable | ||||||
|   * @retval Pointer to descriptor buffer |   * @retval Pointer to descriptor buffer | ||||||
|   */ |   */ | ||||||
| uint8_t * USBD_FS_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) | uint8_t* USBD_FS_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t* length) { | ||||||
| { |     if(speed == 0) { | ||||||
|   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); |         USBD_GetString((uint8_t*)USBD_INTERFACE_STRING_FS, USBD_StrDesc, length); | ||||||
|   } |     } | ||||||
|   else |     return USBD_StrDesc; | ||||||
|   { |  | ||||||
|     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 |   * @brief  Return the BOS descriptor | ||||||
|   * @param  speed : Current device speed |   * @param  speed : Current device speed | ||||||
|   * @param  length : Pointer to data length variable |   * @param  length : Pointer to data length variable | ||||||
|   * @retval Pointer to descriptor buffer |   * @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); | ||||||
|   UNUSED(speed); |     *length = sizeof(USBD_FS_BOSDesc); | ||||||
|   *length = sizeof(USBD_FS_BOSDesc); |     return (uint8_t*)USBD_FS_BOSDesc; | ||||||
|   return (uint8_t*)USBD_FS_BOSDesc; |  | ||||||
| } | } | ||||||
| #endif /* (USBD_LPM_ENABLED == 1) */ | #endif /* (USBD_LPM_ENABLED == 1) */ | ||||||
| 
 | 
 | ||||||
| @ -387,21 +364,19 @@ uint8_t * USBD_FS_USR_BOSDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) | |||||||
|   * @param  None  |   * @param  None  | ||||||
|   * @retval None |   * @retval None | ||||||
|   */ |   */ | ||||||
| static void Get_SerialNum(void) | static void Get_SerialNum(void) { | ||||||
| { |     uint32_t deviceserial0, deviceserial1, deviceserial2; | ||||||
|   uint32_t deviceserial0, deviceserial1, deviceserial2; |  | ||||||
| 
 | 
 | ||||||
|   deviceserial0 = *(uint32_t *) DEVICE_ID1; |     deviceserial0 = *(uint32_t*)DEVICE_ID1; | ||||||
|   deviceserial1 = *(uint32_t *) DEVICE_ID2; |     deviceserial1 = *(uint32_t*)DEVICE_ID2; | ||||||
|   deviceserial2 = *(uint32_t *) DEVICE_ID3; |     deviceserial2 = *(uint32_t*)DEVICE_ID3; | ||||||
| 
 | 
 | ||||||
|   deviceserial0 += deviceserial2; |     deviceserial0 += deviceserial2; | ||||||
| 
 | 
 | ||||||
|   if (deviceserial0 != 0) |     if(deviceserial0 != 0) { | ||||||
|   { |         IntToUnicode(deviceserial0, &USBD_StringSerial[2], 8); | ||||||
|     IntToUnicode(deviceserial0, &USBD_StringSerial[2], 8); |         IntToUnicode(deviceserial1, &USBD_StringSerial[18], 4); | ||||||
|     IntToUnicode(deviceserial1, &USBD_StringSerial[18], 4); |     } | ||||||
|   } |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
| @ -411,25 +386,20 @@ static void Get_SerialNum(void) | |||||||
|   * @param  len: buffer length |   * @param  len: buffer length | ||||||
|   * @retval None |   * @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; | ||||||
|   uint8_t idx = 0; |  | ||||||
| 
 | 
 | ||||||
|   for (idx = 0; idx < len; idx++) |     for(idx = 0; idx < len; idx++) { | ||||||
|   { |         if(((value >> 28)) < 0xA) { | ||||||
|     if (((value >> 28)) < 0xA) |             pbuf[2 * idx] = (value >> 28) + '0'; | ||||||
|     { |         } else { | ||||||
|       pbuf[2 * idx] = (value >> 28) + '0'; |             pbuf[2 * idx] = (value >> 28) + 'A' - 10; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         value = value << 4; | ||||||
|  | 
 | ||||||
|  |         pbuf[2 * idx + 1] = 0; | ||||||
|     } |     } | ||||||
|     else |  | ||||||
|     { |  | ||||||
|       pbuf[2 * idx] = (value >> 28) + 'A' - 10; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     value = value << 4; |  | ||||||
| 
 |  | ||||||
|     pbuf[2 * idx + 1] = 0; |  | ||||||
|   } |  | ||||||
| } | } | ||||||
| /**
 | /**
 | ||||||
|   * @} |   * @} | ||||||
|  | |||||||
| @ -6,13 +6,12 @@ | |||||||
| void osDelay(uint32_t ms); | void osDelay(uint32_t ms); | ||||||
| 
 | 
 | ||||||
| // some FreeRTOS types
 | // some FreeRTOS types
 | ||||||
| typedef void(*TaskFunction_t)(void*); | typedef void (*TaskFunction_t)(void*); | ||||||
| typedef size_t UBaseType_t; | typedef size_t UBaseType_t; | ||||||
| typedef uint32_t StackType_t; | typedef uint32_t StackType_t; | ||||||
| typedef uint32_t StaticTask_t; | typedef uint32_t StaticTask_t; | ||||||
| typedef pthread_t* TaskHandle_t; | typedef pthread_t* TaskHandle_t; | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| typedef enum { | typedef enum { | ||||||
|     SemaphoreTypeMutex, |     SemaphoreTypeMutex, | ||||||
|     SemaphoreTypeCounting, |     SemaphoreTypeCounting, | ||||||
| @ -30,48 +29,37 @@ typedef StaticQueue_t* QueueHandle_t; | |||||||
| 
 | 
 | ||||||
| #define portMAX_DELAY -1 | #define portMAX_DELAY -1 | ||||||
| 
 | 
 | ||||||
| typedef enum { | typedef enum { pdTRUE = 1, pdFALSE = 0 } BaseType_t; | ||||||
|     pdTRUE = 1, |  | ||||||
|     pdFALSE = 0 |  | ||||||
| } BaseType_t; |  | ||||||
| 
 | 
 | ||||||
| typedef int32_t TickType_t; | typedef int32_t TickType_t; | ||||||
| 
 | 
 | ||||||
| #define tskIDLE_PRIORITY 0 | #define tskIDLE_PRIORITY 0 | ||||||
| 
 | 
 | ||||||
| TaskHandle_t xTaskCreateStatic( | TaskHandle_t xTaskCreateStatic(TaskFunction_t pxTaskCode, | ||||||
|     TaskFunction_t pxTaskCode, |                                const char* const pcName, | ||||||
|     const char * const pcName, |                                const uint32_t ulStackDepth, | ||||||
|     const uint32_t ulStackDepth, |                                void* const pvParameters, | ||||||
|     void * const pvParameters, |                                UBaseType_t uxPriority, | ||||||
|     UBaseType_t uxPriority, |                                StackType_t* const puxStackBuffer, | ||||||
|     StackType_t * const puxStackBuffer, |                                StaticTask_t* const pxTaskBuffer); | ||||||
|     StaticTask_t * const pxTaskBuffer |  | ||||||
| ); |  | ||||||
| 
 | 
 | ||||||
| void vTaskDelete(TaskHandle_t xTask); | void vTaskDelete(TaskHandle_t xTask); | ||||||
| TaskHandle_t xTaskGetCurrentTaskHandle(void); | TaskHandle_t xTaskGetCurrentTaskHandle(void); | ||||||
| SemaphoreHandle_t xSemaphoreCreateMutexStatic(StaticSemaphore_t* pxMutexBuffer); | SemaphoreHandle_t xSemaphoreCreateMutexStatic(StaticSemaphore_t* pxMutexBuffer); | ||||||
| bool task_equal(TaskHandle_t a, TaskHandle_t b); | bool task_equal(TaskHandle_t a, TaskHandle_t b); | ||||||
| 
 | 
 | ||||||
| QueueHandle_t xQueueCreateStatic( | QueueHandle_t xQueueCreateStatic(UBaseType_t uxQueueLength, | ||||||
|     UBaseType_t uxQueueLength, |                                  UBaseType_t uxItemSize, | ||||||
|     UBaseType_t uxItemSize, |                                  uint8_t* pucQueueStorageBuffer, | ||||||
|     uint8_t* pucQueueStorageBuffer, |                                  StaticQueue_t* pxQueueBuffer); | ||||||
|     StaticQueue_t* pxQueueBuffer |  | ||||||
| ); |  | ||||||
| 
 | 
 | ||||||
| SemaphoreHandle_t xSemaphoreCreateCountingStatic( | SemaphoreHandle_t xSemaphoreCreateCountingStatic(UBaseType_t uxMaxCount, | ||||||
|     UBaseType_t uxMaxCount, |                                                  UBaseType_t uxInitialCount, | ||||||
|     UBaseType_t uxInitialCount, |                                                  StaticSemaphore_t* pxSemaphoreBuffer); | ||||||
|     StaticSemaphore_t *pxSemaphoreBuffer |  | ||||||
| ); |  | ||||||
| BaseType_t xSemaphoreTake(SemaphoreHandle_t xSemaphore, TickType_t xTicksToWait); | BaseType_t xSemaphoreTake(SemaphoreHandle_t xSemaphore, TickType_t xTicksToWait); | ||||||
| BaseType_t xSemaphoreGive(SemaphoreHandle_t xSemaphore); | BaseType_t xSemaphoreGive(SemaphoreHandle_t xSemaphore); | ||||||
| 
 | 
 | ||||||
| BaseType_t xQueueSend( | BaseType_t xQueueSend(QueueHandle_t xQueue, const void* pvItemToQueue, TickType_t xTicksToWait); | ||||||
|     QueueHandle_t xQueue, const void * pvItemToQueue, TickType_t xTicksToWait |  | ||||||
| ); |  | ||||||
| 
 | 
 | ||||||
| BaseType_t xQueueReceive(QueueHandle_t xQueue, void *pvBuffer, 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 <stdbool.h> | ||||||
| #include "main.h" | #include "main.h" | ||||||
| 
 | 
 | ||||||
| typedef enum { | typedef enum { GpioModeInput, GpioModeOutput, GpioModeOpenDrain } GpioMode; | ||||||
|     GpioModeInput, |  | ||||||
|     GpioModeOutput, |  | ||||||
|     GpioModeOpenDrain |  | ||||||
| } GpioMode; |  | ||||||
| 
 | 
 | ||||||
| typedef struct { | typedef struct { | ||||||
|     const char* port; |     const char* port; | ||||||
| @ -42,10 +38,7 @@ inline bool app_gpio_read(GpioPin gpio) { | |||||||
|     return false; |     return false; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| typedef enum { | typedef enum { GPIO_PIN_SET = 1, GPIO_PIN_RESET = 0 } HAL_GPIO_PIN_STATE; | ||||||
|     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); | 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; | 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 | #define HAL_MAX_DELAY INT_MAX | ||||||
| 
 | 
 | ||||||
| typedef uint32_t UART_HandleTypeDef; | typedef uint32_t UART_HandleTypeDef; | ||||||
| uint16_t HAL_UART_Transmit( | uint16_t | ||||||
|     UART_HandleTypeDef* handle, | HAL_UART_Transmit(UART_HandleTypeDef* handle, uint8_t* bufer, uint16_t size, uint32_t wait_ms); | ||||||
|     uint8_t* bufer, |  | ||||||
|     uint16_t size, |  | ||||||
|     uint32_t wait_ms |  | ||||||
| ); |  | ||||||
| 
 | 
 | ||||||
| typedef uint32_t TIM_HandleTypeDef; | typedef uint32_t TIM_HandleTypeDef; | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -10,18 +10,17 @@ GPIO and HAL implementations | |||||||
| 
 | 
 | ||||||
| void app_gpio_init(GpioPin gpio, GpioMode mode) { | void app_gpio_init(GpioPin gpio, GpioMode mode) { | ||||||
|     if(gpio.pin != 0) { |     if(gpio.pin != 0) { | ||||||
| 
 |  | ||||||
|         switch(mode) { |         switch(mode) { | ||||||
|             case GpioModeInput: |         case GpioModeInput: | ||||||
|                 printf("[GPIO] %s%d input\n", gpio.port, gpio.pin); |             printf("[GPIO] %s%d input\n", gpio.port, gpio.pin); | ||||||
|             break; |             break; | ||||||
| 
 | 
 | ||||||
|             case GpioModeOutput:  |         case GpioModeOutput: | ||||||
|                 printf("[GPIO] %s%d push pull\n", gpio.port, gpio.pin); |             printf("[GPIO] %s%d push pull\n", gpio.port, gpio.pin); | ||||||
|             break; |             break; | ||||||
| 
 | 
 | ||||||
|             case GpioModeOpenDrain: |         case GpioModeOpenDrain: | ||||||
|                 printf("[GPIO] %s%d open drain\n", gpio.port, gpio.pin); |             printf("[GPIO] %s%d open drain\n", gpio.port, gpio.pin); | ||||||
|             break; |             break; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
| @ -44,13 +43,14 @@ 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); |     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); |     printf("[SPI] write %d to %s: ", size, *hspi); | ||||||
|     for(size_t i = 0; i < size; i++) { |     for(size_t i = 0; i < size; i++) { | ||||||
|         printf("%02X ", pData[i]); |         printf("%02X ", pData[i]); | ||||||
|     } |     } | ||||||
|     printf("\n"); |     printf("\n"); | ||||||
|      | 
 | ||||||
|     return 0; |     return 0; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -10,12 +10,8 @@ Dummy hal for local fw build | |||||||
| 
 | 
 | ||||||
| UART_HandleTypeDef DEBUG_UART = 0; | UART_HandleTypeDef DEBUG_UART = 0; | ||||||
| 
 | 
 | ||||||
| uint16_t HAL_UART_Transmit( | uint16_t | ||||||
|     UART_HandleTypeDef* handle, | HAL_UART_Transmit(UART_HandleTypeDef* handle, uint8_t* bufer, uint16_t size, uint32_t wait_ms) { | ||||||
|     uint8_t* bufer, |  | ||||||
|     uint16_t size, |  | ||||||
|     uint32_t wait_ms |  | ||||||
| ) { |  | ||||||
|     uint16_t res = write(1, (const char*)bufer, size); |     uint16_t res = write(1, (const char*)bufer, size); | ||||||
|     return res; |     return res; | ||||||
| } | } | ||||||
| @ -16,7 +16,7 @@ void osDelay(uint32_t ms) { | |||||||
| // temporary struct to pass function ptr and param to wrapper
 | // temporary struct to pass function ptr and param to wrapper
 | ||||||
| typedef struct { | typedef struct { | ||||||
|     TaskFunction_t func; |     TaskFunction_t func; | ||||||
|     void * param; |     void* param; | ||||||
| } PthreadTask; | } PthreadTask; | ||||||
| 
 | 
 | ||||||
| void* pthread_wrapper(void* p) { | void* pthread_wrapper(void* p) { | ||||||
| @ -24,21 +24,19 @@ void* pthread_wrapper(void* p) { | |||||||
|     pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, 0x00); |     pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, 0x00); | ||||||
| 
 | 
 | ||||||
|     PthreadTask* task = (PthreadTask*)p; |     PthreadTask* task = (PthreadTask*)p; | ||||||
|      | 
 | ||||||
|     task->func(task->param); |     task->func(task->param); | ||||||
| 
 | 
 | ||||||
|     return NULL; |     return NULL; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| TaskHandle_t xTaskCreateStatic( | TaskHandle_t xTaskCreateStatic(TaskFunction_t pxTaskCode, | ||||||
|     TaskFunction_t pxTaskCode, |                                const char* const pcName, | ||||||
|     const char * const pcName, |                                const uint32_t ulStackDepth, | ||||||
|     const uint32_t ulStackDepth, |                                void* const pvParameters, | ||||||
|     void * const pvParameters, |                                UBaseType_t uxPriority, | ||||||
|     UBaseType_t uxPriority, |                                StackType_t* const puxStackBuffer, | ||||||
|     StackType_t * const puxStackBuffer, |                                StaticTask_t* const pxTaskBuffer) { | ||||||
|     StaticTask_t * const pxTaskBuffer |  | ||||||
| ) { |  | ||||||
|     TaskHandle_t thread = malloc(sizeof(TaskHandle_t)); |     TaskHandle_t thread = malloc(sizeof(TaskHandle_t)); | ||||||
|     PthreadTask* task = malloc(sizeof(PthreadTask)); |     PthreadTask* task = malloc(sizeof(PthreadTask)); | ||||||
| 
 | 
 | ||||||
| @ -51,14 +49,13 @@ TaskHandle_t xTaskCreateStatic( | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void vTaskDelete(TaskHandle_t xTask) { | void vTaskDelete(TaskHandle_t xTask) { | ||||||
| 
 |  | ||||||
|     if(xTask == NULL) { |     if(xTask == NULL) { | ||||||
|         // kill itself
 |         // kill itself
 | ||||||
|         pthread_exit(NULL); |         pthread_exit(NULL); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     // maybe thread already join
 |     // 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 сигнал, который ее завершает
 |     // send thread_child signal to stop it сигнал, который ее завершает
 | ||||||
|     pthread_cancel(*xTask); |     pthread_cancel(*xTask); | ||||||
| @ -78,20 +75,16 @@ TaskHandle_t xTaskGetCurrentTaskHandle(void) { | |||||||
| 
 | 
 | ||||||
| bool task_equal(TaskHandle_t a, TaskHandle_t b) { | bool task_equal(TaskHandle_t a, TaskHandle_t b) { | ||||||
|     if(a == NULL || b == NULL) return false; |     if(a == NULL || b == NULL) return false; | ||||||
|      | 
 | ||||||
|     return pthread_equal(*a, *b) != 0; |     return pthread_equal(*a, *b) != 0; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| BaseType_t xQueueSend( | BaseType_t xQueueSend(QueueHandle_t xQueue, const void* pvItemToQueue, TickType_t xTicksToWait) { | ||||||
|     QueueHandle_t xQueue, const void * pvItemToQueue, TickType_t xTicksToWait |  | ||||||
| ) { |  | ||||||
|     // TODO: add implementation
 |     // TODO: add implementation
 | ||||||
|     return pdTRUE; |     return pdTRUE; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| BaseType_t xQueueReceive( | BaseType_t xQueueReceive(QueueHandle_t xQueue, void* pvBuffer, TickType_t xTicksToWait) { | ||||||
|     QueueHandle_t xQueue, void *pvBuffer, TickType_t xTicksToWait |  | ||||||
| ) { |  | ||||||
|     // TODO: add implementation
 |     // TODO: add implementation
 | ||||||
|     osDelay(100); |     osDelay(100); | ||||||
| 
 | 
 | ||||||
| @ -100,12 +93,10 @@ BaseType_t xQueueReceive( | |||||||
| 
 | 
 | ||||||
| static uint32_t queue_global_id = 0; | static uint32_t queue_global_id = 0; | ||||||
| 
 | 
 | ||||||
| QueueHandle_t xQueueCreateStatic( | QueueHandle_t xQueueCreateStatic(UBaseType_t uxQueueLength, | ||||||
|     UBaseType_t uxQueueLength, |                                  UBaseType_t uxItemSize, | ||||||
|     UBaseType_t uxItemSize, |                                  uint8_t* pucQueueStorageBuffer, | ||||||
|     uint8_t* pucQueueStorageBuffer, |                                  StaticQueue_t* pxQueueBuffer) { | ||||||
|     StaticQueue_t *pxQueueBuffer |  | ||||||
| ) { |  | ||||||
|     // TODO: check this implementation
 |     // TODO: check this implementation
 | ||||||
|     int* msgid = malloc(sizeof(int)); |     int* msgid = malloc(sizeof(int)); | ||||||
| 
 | 
 | ||||||
| @ -117,11 +108,9 @@ QueueHandle_t xQueueCreateStatic( | |||||||
|     return (QueueHandle_t)msgid; |     return (QueueHandle_t)msgid; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| SemaphoreHandle_t xSemaphoreCreateCountingStatic( | SemaphoreHandle_t xSemaphoreCreateCountingStatic(UBaseType_t uxMaxCount, | ||||||
|     UBaseType_t uxMaxCount, |                                                  UBaseType_t uxInitialCount, | ||||||
|     UBaseType_t uxInitialCount, |                                                  StaticSemaphore_t* pxSemaphoreBuffer) { | ||||||
|     StaticSemaphore_t* pxSemaphoreBuffer |  | ||||||
| ) { |  | ||||||
|     pxSemaphoreBuffer->type = SemaphoreTypeCounting; |     pxSemaphoreBuffer->type = SemaphoreTypeCounting; | ||||||
|     pxSemaphoreBuffer->take_counter = 0; |     pxSemaphoreBuffer->take_counter = 0; | ||||||
|     pxSemaphoreBuffer->give_counter = 0; |     pxSemaphoreBuffer->give_counter = 0; | ||||||
| @ -136,24 +125,23 @@ SemaphoreHandle_t xSemaphoreCreateMutexStatic(StaticSemaphore_t* pxMutexBuffer) | |||||||
|     return pxMutexBuffer; |     return pxMutexBuffer; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| BaseType_t xSemaphoreTake(volatile SemaphoreHandle_t xSemaphore, TickType_t xTicksToWait) { | BaseType_t xSemaphoreTake(volatile SemaphoreHandle_t xSemaphore, TickType_t xTicksToWait) { | ||||||
|     if(xSemaphore == NULL) return pdFALSE; |     if(xSemaphore == NULL) return pdFALSE; | ||||||
| 
 | 
 | ||||||
|     if (xSemaphore->type == SemaphoreTypeMutex) { |     if(xSemaphore->type == SemaphoreTypeMutex) { | ||||||
|         if (xTicksToWait == portMAX_DELAY) { |         if(xTicksToWait == portMAX_DELAY) { | ||||||
|             if (pthread_mutex_lock(&xSemaphore->mutex) == 0) { |             if(pthread_mutex_lock(&xSemaphore->mutex) == 0) { | ||||||
|                 return pdTRUE; |                 return pdTRUE; | ||||||
|             } else { |             } else { | ||||||
|                 return pdFALSE; |                 return pdFALSE; | ||||||
|             } |             } | ||||||
|         } else { |         } else { | ||||||
|             TickType_t ticks = xTicksToWait; |             TickType_t ticks = xTicksToWait; | ||||||
|             while (ticks >= 0) { |             while(ticks >= 0) { | ||||||
|                 if (pthread_mutex_trylock(&xSemaphore->mutex) == 0) { |                 if(pthread_mutex_trylock(&xSemaphore->mutex) == 0) { | ||||||
|                     return pdTRUE; |                     return pdTRUE; | ||||||
|                 } |                 } | ||||||
|                 if (ticks > 0) { |                 if(ticks > 0) { | ||||||
|                     osDelay(1); |                     osDelay(1); | ||||||
|                 } |                 } | ||||||
|                 ticks--; |                 ticks--; | ||||||
| @ -167,10 +155,8 @@ BaseType_t xSemaphoreTake(volatile SemaphoreHandle_t xSemaphore, TickType_t xTic | |||||||
| 
 | 
 | ||||||
|     TickType_t ticks = xTicksToWait; |     TickType_t ticks = xTicksToWait; | ||||||
| 
 | 
 | ||||||
|     while( |     while(xSemaphore->take_counter != xSemaphore->give_counter && | ||||||
|         xSemaphore->take_counter != xSemaphore->give_counter |           (ticks > 0 || xTicksToWait == portMAX_DELAY)) { | ||||||
|         && (ticks > 0 || xTicksToWait == portMAX_DELAY) |  | ||||||
|     ) { |  | ||||||
|         osDelay(1); |         osDelay(1); | ||||||
|         ticks--; |         ticks--; | ||||||
|     } |     } | ||||||
| @ -183,8 +169,8 @@ BaseType_t xSemaphoreTake(volatile SemaphoreHandle_t xSemaphore, TickType_t xTic | |||||||
| BaseType_t xSemaphoreGive(SemaphoreHandle_t xSemaphore) { | BaseType_t xSemaphoreGive(SemaphoreHandle_t xSemaphore) { | ||||||
|     if(xSemaphore == NULL) return pdFALSE; |     if(xSemaphore == NULL) return pdFALSE; | ||||||
| 
 | 
 | ||||||
|     if (xSemaphore->type == SemaphoreTypeMutex) { |     if(xSemaphore->type == SemaphoreTypeMutex) { | ||||||
|         if (pthread_mutex_unlock(&xSemaphore->mutex) == 0) { |         if(pthread_mutex_unlock(&xSemaphore->mutex) == 0) { | ||||||
|             return pdTRUE; |             return pdTRUE; | ||||||
|         } else { |         } else { | ||||||
|             return pdFALSE; |             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 pthread_once_t tls_keys_once = PTHREAD_ONCE_INIT; | ||||||
| 
 | 
 | ||||||
| static void create_tls_keys() { | 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); |         pthread_key_create(&tls_keys[i], NULL); | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void* pvTaskGetThreadLocalStoragePointer( | void* pvTaskGetThreadLocalStoragePointer(TaskHandle_t xTaskToQuery, BaseType_t xIndex) { | ||||||
|     TaskHandle_t xTaskToQuery, BaseType_t xIndex |  | ||||||
| ) { |  | ||||||
|     // Non-current task TLS access is not allowed
 |     // Non-current task TLS access is not allowed
 | ||||||
|     if (xTaskToQuery != NULL) { |     if(xTaskToQuery != NULL) { | ||||||
|         return NULL; |         return NULL; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     if (xIndex >= TLS_ITEM_COUNT) { |     if(xIndex >= TLS_ITEM_COUNT) { | ||||||
|         return NULL; |         return NULL; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -224,15 +208,13 @@ void* pvTaskGetThreadLocalStoragePointer( | |||||||
|     return pthread_getspecific(tls_keys[xIndex]); |     return pthread_getspecific(tls_keys[xIndex]); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void vTaskSetThreadLocalStoragePointer( | void vTaskSetThreadLocalStoragePointer(TaskHandle_t xTaskToSet, BaseType_t xIndex, void* pvValue) { | ||||||
|     TaskHandle_t xTaskToSet, BaseType_t xIndex, void *pvValue |  | ||||||
| ) { |  | ||||||
|     // Non-current task TLS access is not allowed
 |     // Non-current task TLS access is not allowed
 | ||||||
|     if (xTaskToSet != NULL) { |     if(xTaskToSet != NULL) { | ||||||
|         return; |         return; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     if (xIndex >= TLS_ITEM_COUNT) { |     if(xIndex >= TLS_ITEM_COUNT) { | ||||||
|         return; |         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 | 	* 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. | 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 | ## Pull requests | ||||||
| 
 | 
 | ||||||
| 1. Don't forget reference issues or other PR | 1. Don't forget reference issues or other PR | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Nikita Beletskii
						Nikita Beletskii