aliexpress sucks

fake-chip
Ondřej Hruška 2 years ago
parent 2521cd75c7
commit ddde12e4c3
  1. 6
      BluepillTrouba.ioc
  2. 29
      Core/Inc/FreeRTOSConfig.h
  3. 8
      Core/Src/app_main.c
  4. 2
      Core/Src/main.c
  5. 2
      Core/Src/spi.c
  6. 4
      Makefile
  7. 5
      Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM3/port.c
  8. 6
      STM32F103C8Tx_FLASH.ld

@ -42,7 +42,7 @@ IWDG.IPParameters=Prescaler,Reload
IWDG.Prescaler=IWDG_PRESCALER_256 IWDG.Prescaler=IWDG_PRESCALER_256
IWDG.Reload=624 IWDG.Reload=624
KeepUserPlacement=false KeepUserPlacement=false
Mcu.CPN=STM32F103CBT6 Mcu.CPN=STM32F103C8T6
Mcu.Family=STM32F1 Mcu.Family=STM32F1
Mcu.IP0=ADC1 Mcu.IP0=ADC1
Mcu.IP1=DMA Mcu.IP1=DMA
@ -86,7 +86,7 @@ Mcu.Pin9=PA9
Mcu.PinsNb=24 Mcu.PinsNb=24
Mcu.ThirdPartyNb=0 Mcu.ThirdPartyNb=0
Mcu.UserConstants= Mcu.UserConstants=
Mcu.UserName=STM32F103CBTx Mcu.UserName=STM32F103C8Tx
MxCube.Version=6.5.0 MxCube.Version=6.5.0
MxDb.Version=DB.6.0.50 MxDb.Version=DB.6.0.50
NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:true NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:true
@ -172,7 +172,7 @@ ProjectManager.CoupleFile=true
ProjectManager.CustomerFirmwarePackage= ProjectManager.CustomerFirmwarePackage=
ProjectManager.DefaultFWLocation=true ProjectManager.DefaultFWLocation=true
ProjectManager.DeletePrevious=true ProjectManager.DeletePrevious=true
ProjectManager.DeviceId=STM32F103CBTx ProjectManager.DeviceId=STM32F103C8Tx
ProjectManager.FirmwarePackage=STM32Cube FW_F1 V1.8.4 ProjectManager.FirmwarePackage=STM32Cube FW_F1 V1.8.4
ProjectManager.FreePins=true ProjectManager.FreePins=true
ProjectManager.HalAssertFull=true ProjectManager.HalAssertFull=true

@ -106,6 +106,30 @@ to exclude the API function. */
*/ */
#define USE_FreeRTOS_HEAP_4 #define USE_FreeRTOS_HEAP_4
#define FAKE_STM32 1
#if FAKE_STM32
/* Cortex-M specific definitions. */
#ifdef __NVIC_PRIO_BITS
/* __BVIC_PRIO_BITS will be specified when CMSIS is being used. */
#define configPRIO_BITS __NVIC_PRIO_BITS
#else
#define configPRIO_BITS 3
#endif
/* The lowest interrupt priority that can be used in a call to a "set priority"
function. */
#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY 7
/* 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
INTERRUPT SAFE FREERTOS API FUNCTIONS FROM ANY INTERRUPT THAT HAS A HIGHER
PRIORITY THAN THIS! (higher priorities are lower numeric values. */
#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 5
#else
/* 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. */
@ -124,6 +148,8 @@ INTERRUPT SAFE FREERTOS API FUNCTIONS FROM ANY INTERRUPT THAT HAS A HIGHER
PRIORITY THAN THIS! (higher priorities are lower numeric values. */ PRIORITY THAN THIS! (higher priorities are lower numeric values. */
#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 5 #define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 5
#endif
/* 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) )
@ -134,7 +160,8 @@ See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */
/* 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( ;; );} #include <stdio.h>
#define configASSERT( x ) if ((x) == 0) {taskDISABLE_INTERRUPTS(); printf("configASSERT "__FILE__":%d\r\n",__LINE__); 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

@ -97,6 +97,7 @@ void app_task_main(void *argument)
bool any_change = true; bool any_change = true;
uint32_t last_redraw = osKernelGetTickCount(); uint32_t last_redraw = osKernelGetTickCount();
uint32_t last_blink = xTaskGetTickCount();
for (;;) { for (;;) {
// sampling is done in the heater loop // sampling is done in the heater loop
@ -144,11 +145,16 @@ void app_task_main(void *argument)
any_change = false; any_change = false;
// Blink // Blink
HAL_GPIO_TogglePin(LED_GPIO_Port, LED_Pin);
} }
vTaskDelay(pdMS_TO_TICKS(10)); vTaskDelay(pdMS_TO_TICKS(10));
now = osKernelGetTickCount();
if (now - last_blink > 250) {
HAL_GPIO_TogglePin(LED_GPIO_Port, LED_Pin);
last_blink = now;
}
// feed dogs // feed dogs
HAL_IWDG_Refresh(&hiwdg); HAL_IWDG_Refresh(&hiwdg);
} }

@ -106,6 +106,7 @@ int main(void)
MX_TIM3_Init(); MX_TIM3_Init();
MX_SPI2_Init(); MX_SPI2_Init();
/* USER CODE BEGIN 2 */ /* USER CODE BEGIN 2 */
printf("Kernel start\r\n");
/* USER CODE END 2 */ /* USER CODE END 2 */
/* Init scheduler */ /* Init scheduler */
@ -224,6 +225,7 @@ void Error_Handler(void)
void assert_failed(uint8_t *file, uint32_t line) void assert_failed(uint8_t *file, uint32_t line)
{ {
/* USER CODE BEGIN 6 */ /* USER CODE BEGIN 6 */
printf("assert_failed %s:%d\r\n", file, line);
/* User can add his own implementation to report the file name and line number, /* User can add his own implementation to report the file name and line number,
ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
/* USER CODE END 6 */ /* USER CODE END 6 */

@ -44,7 +44,7 @@ void MX_SPI2_Init(void)
hspi2.Init.CLKPolarity = SPI_POLARITY_LOW; hspi2.Init.CLKPolarity = SPI_POLARITY_LOW;
hspi2.Init.CLKPhase = SPI_PHASE_1EDGE; hspi2.Init.CLKPhase = SPI_PHASE_1EDGE;
hspi2.Init.NSS = SPI_NSS_SOFT; hspi2.Init.NSS = SPI_NSS_SOFT;
hspi2.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_8; hspi2.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_64;
hspi2.Init.FirstBit = SPI_FIRSTBIT_MSB; hspi2.Init.FirstBit = SPI_FIRSTBIT_MSB;
hspi2.Init.TIMode = SPI_TIMODE_DISABLE; hspi2.Init.TIMode = SPI_TIMODE_DISABLE;
hspi2.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE; hspi2.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;

@ -1,5 +1,5 @@
########################################################################################################################## ##########################################################################################################################
# File automatically-generated by tool: [projectgenerator] version: [3.16.0] date: [Tue Mar 07 00:54:18 CET 2023] # File automatically-generated by tool: [projectgenerator] version: [3.16.0] date: [Sun Mar 12 01:37:39 CET 2023]
########################################################################################################################## ##########################################################################################################################
# ------------------------------------------------ # ------------------------------------------------
@ -172,7 +172,7 @@ CFLAGS += -MMD -MP -MF"$(@:%.o=%.d)"
# LDFLAGS # LDFLAGS
####################################### #######################################
# link script # link script
LDSCRIPT = STM32F103CBTx_FLASH.ld LDSCRIPT = STM32F103C8Tx_FLASH.ld
# libraries # libraries
LIBS = -lc -lm -lnosys LIBS = -lc -lm -lnosys

@ -281,6 +281,8 @@ BaseType_t xPortStartScheduler( void )
/* Read the value back to see how many bits stuck. */ /* Read the value back to see how many bits stuck. */
ucMaxPriorityValue = *pucFirstUserPriorityRegister; ucMaxPriorityValue = *pucFirstUserPriorityRegister;
printf("ucMaxPriorityValue %02x, \r\n", ucMaxPriorityValue);
/* Use the same mask on the maximum system call priority. */ /* Use the same mask on the maximum system call priority. */
ucMaxSysCallPriority = configMAX_SYSCALL_INTERRUPT_PRIORITY & ucMaxPriorityValue; ucMaxSysCallPriority = configMAX_SYSCALL_INTERRUPT_PRIORITY & ucMaxPriorityValue;
@ -292,6 +294,7 @@ BaseType_t xPortStartScheduler( void )
ulMaxPRIGROUPValue--; ulMaxPRIGROUPValue--;
ucMaxPriorityValue <<= ( uint8_t ) 0x01; ucMaxPriorityValue <<= ( uint8_t ) 0x01;
} }
printf("portMAX_PRIGROUP_BITS %02x, ulMaxPRIGROUPValue %02x \r\n", portMAX_PRIGROUP_BITS, ulMaxPRIGROUPValue);
#ifdef __NVIC_PRIO_BITS #ifdef __NVIC_PRIO_BITS
{ {
@ -304,6 +307,8 @@ BaseType_t xPortStartScheduler( void )
#ifdef configPRIO_BITS #ifdef configPRIO_BITS
{ {
printf("( portMAX_PRIGROUP_BITS %d - ulMaxPRIGROUPValue %d ) == configPRIO_BITS %d \r\n",
portMAX_PRIGROUP_BITS, ulMaxPRIGROUPValue, configPRIO_BITS );
/* Check the FreeRTOS configuration that defines the number of /* Check the FreeRTOS configuration that defines the number of
priority bits matches the number of priority bits actually queried priority bits matches the number of priority bits actually queried
from the hardware. */ from the hardware. */

@ -6,8 +6,8 @@
** **
** Author : STM32CubeMX ** Author : STM32CubeMX
** **
** Abstract : Linker script for STM32F103CBTx series ** Abstract : Linker script for STM32F103C8Tx series
** 128Kbytes FLASH and 20Kbytes RAM ** 64Kbytes FLASH and 20Kbytes RAM
** **
** Set heap size, stack size and stack location according ** Set heap size, stack size and stack location according
** to application requirements. ** to application requirements.
@ -62,7 +62,7 @@ _Min_Stack_Size = 0x400; /* required amount of stack */
MEMORY MEMORY
{ {
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 20K RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 20K
FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 128K FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 64K
} }
/* Define output sections */ /* Define output sections */
Loading…
Cancel
Save