├── .gitattributes ├── .gitignore ├── README ├── demos ├── adc_single │ ├── main.c │ └── stm32f10x_conf.h ├── blink_flash │ ├── main.c │ └── stm32f10x_conf.h ├── blink_flash_asm │ └── main.s ├── button │ ├── main.c │ └── stm32f10x_conf.h ├── button_int │ ├── main.c │ └── stm32f10x_conf.h ├── button_int_infinite │ └── README ├── c_mem_model │ ├── main.c │ └── stm32f10x_conf.h ├── common │ ├── myprintk.c │ ├── myprintk.h │ ├── stm32_p103.c │ └── stm32_p103.h ├── dac │ ├── main.c │ └── stm32f10x_conf.h ├── freertos_cycletask │ ├── FreeRTOSConfig.h │ ├── main.c │ └── stm32f10x_conf.h ├── freertos_multithread │ ├── FreeRTOSConfig.h │ ├── main.c │ └── stm32f10x_conf.h ├── freertos_semaphore1 │ ├── FreeRTOSConfig.h │ ├── main.c │ └── stm32f10x_conf.h ├── freertos_singlethread │ ├── FreeRTOSConfig.h │ ├── main.c │ └── stm32f10x_conf.h ├── freertos_streambuffer │ ├── FreeRTOSConfig.h │ ├── main.c │ └── stm32f10x_conf.h ├── main.ld ├── printf_demo │ ├── main.c │ └── stm32f10x_conf.h ├── qemu_test │ ├── main.c │ └── stm32f10x_conf.h ├── rtc │ ├── main.c │ └── stm32f10x_conf.h ├── software_int │ ├── main.c │ └── stm32f10x_conf.h ├── stkalign │ ├── main.c │ └── stm32f10x_conf.h ├── systick │ ├── main.c │ └── stm32f10x_conf.h ├── timer │ ├── main.c │ └── stm32f10x_conf.h ├── uart_echo │ ├── main.c │ └── stm32f10x_conf.h ├── uart_echo_int │ ├── main.c │ └── stm32f10x_conf.h ├── uart_repeat_write │ ├── main.c │ └── stm32f10x_conf.h └── uart_repeat_write_int │ ├── main.c │ └── stm32f10x_conf.h ├── eclipse ├── Debug QEMU (blink_flash).launch └── Debug blink_flash.launch ├── libraries ├── CMSIS │ ├── CM3 │ │ ├── CoreSupport │ │ │ ├── core_cm3.c │ │ │ └── core_cm3.h │ │ └── DeviceSupport │ │ │ └── ST │ │ │ └── STM32F10x │ │ │ ├── Release_Notes.html │ │ │ ├── startup │ │ │ ├── TrueSTUDIO │ │ │ │ ├── startup_stm32f10x_cl.s │ │ │ │ ├── startup_stm32f10x_hd.s │ │ │ │ ├── startup_stm32f10x_hd_vl.s │ │ │ │ ├── startup_stm32f10x_ld.s │ │ │ │ ├── startup_stm32f10x_ld_vl.s │ │ │ │ ├── startup_stm32f10x_md.s │ │ │ │ ├── startup_stm32f10x_md_vl.s │ │ │ │ └── startup_stm32f10x_xl.s │ │ │ ├── arm │ │ │ │ ├── startup_stm32f10x_cl.s │ │ │ │ ├── startup_stm32f10x_hd.s │ │ │ │ ├── startup_stm32f10x_hd_vl.s │ │ │ │ ├── startup_stm32f10x_ld.s │ │ │ │ ├── startup_stm32f10x_ld_vl.s │ │ │ │ ├── startup_stm32f10x_md.s │ │ │ │ ├── startup_stm32f10x_md_vl.s │ │ │ │ └── startup_stm32f10x_xl.s │ │ │ ├── gcc_ride7 │ │ │ │ ├── startup_stm32f10x_cl.s │ │ │ │ ├── startup_stm32f10x_hd.s │ │ │ │ ├── startup_stm32f10x_hd_vl.s │ │ │ │ ├── startup_stm32f10x_ld.s │ │ │ │ ├── startup_stm32f10x_ld_vl.s │ │ │ │ ├── startup_stm32f10x_md.s │ │ │ │ ├── startup_stm32f10x_md_vl.s │ │ │ │ └── startup_stm32f10x_xl.s │ │ │ └── iar │ │ │ │ ├── startup_stm32f10x_cl.s │ │ │ │ ├── startup_stm32f10x_hd.s │ │ │ │ ├── startup_stm32f10x_hd_vl.s │ │ │ │ ├── startup_stm32f10x_ld.s │ │ │ │ ├── startup_stm32f10x_ld_vl.s │ │ │ │ ├── startup_stm32f10x_md.s │ │ │ │ ├── startup_stm32f10x_md_vl.s │ │ │ │ └── startup_stm32f10x_xl.s │ │ │ ├── stm32f10x.h │ │ │ ├── system_stm32f10x.c │ │ │ └── system_stm32f10x.h │ ├── CMSIS debug support.htm │ ├── CMSIS_changes.htm │ ├── Documentation │ │ └── CMSIS_Core.htm │ └── License.doc ├── FreeRTOS │ ├── croutine.c │ ├── event_groups.c │ ├── include │ │ ├── FreeRTOS.h │ │ ├── StackMacros.h │ │ ├── croutine.h │ │ ├── deprecated_definitions.h │ │ ├── event_groups.h │ │ ├── list.h │ │ ├── message_buffer.h │ │ ├── mpu_prototypes.h │ │ ├── mpu_wrappers.h │ │ ├── portable.h │ │ ├── projdefs.h │ │ ├── queue.h │ │ ├── semphr.h │ │ ├── stack_macros.h │ │ ├── stdint.readme │ │ ├── stream_buffer.h │ │ ├── task.h │ │ └── timers.h │ ├── list.c │ ├── portable │ │ ├── Common │ │ │ └── mpu_wrappers.c │ │ ├── GCC │ │ │ └── ARM_CM3 │ │ │ │ ├── port.c │ │ │ │ └── portmacro.h │ │ ├── MemMang │ │ │ ├── ReadMe.url │ │ │ ├── heap_1.c │ │ │ ├── heap_2.c │ │ │ ├── heap_3.c │ │ │ ├── heap_4.c │ │ │ └── heap_5.c │ │ └── readme.txt │ ├── queue.c │ ├── readme.txt │ ├── stream_buffer.c │ ├── tasks.c │ └── timers.c └── STM32F10x_StdPeriph_Driver │ ├── Release_Notes.html │ ├── inc │ ├── misc.h │ ├── stm32f10x_adc.h │ ├── stm32f10x_bkp.h │ ├── stm32f10x_can.h │ ├── stm32f10x_cec.h │ ├── stm32f10x_crc.h │ ├── stm32f10x_dac.h │ ├── stm32f10x_dbgmcu.h │ ├── stm32f10x_dma.h │ ├── stm32f10x_exti.h │ ├── stm32f10x_flash.h │ ├── stm32f10x_fsmc.h │ ├── stm32f10x_gpio.h │ ├── stm32f10x_i2c.h │ ├── stm32f10x_iwdg.h │ ├── stm32f10x_pwr.h │ ├── stm32f10x_rcc.h │ ├── stm32f10x_rtc.h │ ├── stm32f10x_sdio.h │ ├── stm32f10x_spi.h │ ├── stm32f10x_tim.h │ ├── stm32f10x_usart.h │ └── stm32f10x_wwdg.h │ └── src │ ├── misc.c │ ├── stm32f10x_adc.c │ ├── stm32f10x_bkp.c │ ├── stm32f10x_can.c │ ├── stm32f10x_cec.c │ ├── stm32f10x_crc.c │ ├── stm32f10x_dac.c │ ├── stm32f10x_dbgmcu.c │ ├── stm32f10x_dma.c │ ├── stm32f10x_exti.c │ ├── stm32f10x_flash.c │ ├── stm32f10x_fsmc.c │ ├── stm32f10x_gpio.c │ ├── stm32f10x_i2c.c │ ├── stm32f10x_iwdg.c │ ├── stm32f10x_pwr.c │ ├── stm32f10x_rcc.c │ ├── stm32f10x_rtc.c │ ├── stm32f10x_sdio.c │ ├── stm32f10x_spi.c │ ├── stm32f10x_tim.c │ ├── stm32f10x_usart.c │ └── stm32f10x_wwdg.c ├── makefile └── openocd ├── README └── openocd_stm32_p103.cfg /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled source # 2 | ################### 3 | *.o 4 | *.bin 5 | *.elf 6 | *.list 7 | 8 | # Eclipse 9 | .project 10 | .cproject 11 | tags 12 | DAC_OUT_PUT1.txt 13 | DAC_OUT_PUT2.txt 14 | -------------------------------------------------------------------------------- /demos/adc_single/main.c: -------------------------------------------------------------------------------- 1 | #define USE_STDPERIPH_DRIVER 2 | #include "stm32_p103.h" 3 | 4 | #include 5 | 6 | /* Flag whenever the button is pressed. 7 | * Note that the interrupt handler is initialized to only 8 | * fire when the button is pressed, not released. 9 | */ 10 | uint8_t button_pressed = 0; 11 | void EXTI0_IRQHandler(void) 12 | { 13 | /* Make sure the line has a pending interrupt 14 | * (should this always be true if we are inside the interrupt handle?) */ 15 | if(EXTI_GetITStatus(EXTI_Line0) != RESET) { 16 | button_pressed = 1; 17 | EXTI_ClearITPendingBit(EXTI_Line0); 18 | } 19 | } 20 | 21 | void send_adc_sample(unsigned int sample) 22 | { 23 | send_byte(hex_to_char((sample >> 8) & 0xf)); 24 | send_byte(hex_to_char((sample >> 4) & 0xf)); 25 | send_byte(hex_to_char(sample & 0xf)); 26 | } 27 | 28 | /* ADC functions */ 29 | void init_adc(void) { 30 | ADC_InitTypeDef ADC_InitStructure; 31 | GPIO_InitTypeDef GPIO_InitStructure; 32 | /* Configure peripheral clock. */ 33 | /* Per the STM32F103xB datasheet, the maximum frequency for the 34 | * the ADC is 14 Mhz. Using a ADC prescaler value of 6 gives 35 | * 72 Mhz / 6 = 12 Mhz 36 | */ 37 | RCC_ADCCLKConfig(RCC_PCLK2_Div6); 38 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1 | RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOC | RCC_APB2Periph_AFIO, ENABLE); 39 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB,ENABLE); 40 | ADC_InitStructure.ADC_Mode = ADC_Mode_Independent; 41 | ADC_InitStructure.ADC_ScanConvMode = DISABLE; 42 | ADC_InitStructure.ADC_ContinuousConvMode = DISABLE; 43 | ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None; 44 | ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right; 45 | ADC_InitStructure.ADC_NbrOfChannel = 1; 46 | ADC_Init(ADC1, &ADC_InitStructure); 47 | 48 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0; 49 | // GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 50 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN;//_FLOATING; 51 | GPIO_Init(GPIOB, &GPIO_InitStructure); 52 | 53 | ADC_Cmd(ADC1, ENABLE); 54 | 55 | /* Enable ADC1 reset calibration register */ 56 | ADC_ResetCalibration(ADC1); 57 | /* Check the end of ADC1 reset calibration register */ 58 | while(ADC_GetResetCalibrationStatus(ADC1)); 59 | 60 | /* Start ADC1 calibration */ 61 | ADC_StartCalibration(ADC1); 62 | /* Check the end of ADC1 calibration */ 63 | while(ADC_GetCalibrationStatus(ADC1)); 64 | 65 | ADC_TempSensorVrefintCmd(ENABLE); 66 | } 67 | 68 | uint16_t sample_adc(uint8_t adc_channel) { 69 | /* Is it safe to set the channel immediately before a conversion? 70 | * As long as the channel does not change since the last sampling, 71 | * I assume it is OK. 72 | */ 73 | ADC_RegularChannelConfig(ADC1, adc_channel, 1, ADC_SampleTime_239Cycles5); 74 | ADC_SoftwareStartConvCmd(ADC1, ENABLE); 75 | 76 | while(ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC) == RESET); 77 | 78 | return ADC_GetConversionValue(ADC1); 79 | } 80 | 81 | 82 | 83 | int main(void) 84 | { 85 | /* Initialization */ 86 | init_led(); 87 | 88 | init_button(); 89 | enable_button_interrupts(); 90 | 91 | init_rs232(); 92 | enable_rs232(); 93 | 94 | init_adc(); 95 | 96 | rs232_print_str("Starting...\n"); 97 | 98 | /* Infinite loop to sample ADC and print results. 99 | * There are several modes - see the README. */ 100 | int mode = 1; 101 | while(1) { 102 | uint16_t adc_value; 103 | switch(mode) { 104 | case 1: 105 | adc_value = sample_adc(ADC_Channel_16); 106 | rs232_print_str("MODE 1 Temp(Raw)="); 107 | send_adc_sample(adc_value); 108 | /* Also try converting the raw value to an actual 109 | * temperature using the formula from the reference manual. 110 | * TODO: validate this formula or adjust it to make it 111 | * accurate. 112 | */ 113 | 114 | int tempC = (((1.43*0xFFF/3.3) - adc_value)/4.3) + 25; 115 | rs232_print_str(" Temp(Deg Celsius)="); 116 | send_number(tempC, 10); 117 | send_byte('\n'); 118 | break; 119 | case 2: 120 | adc_value = sample_adc(ADC_Channel_17); 121 | rs232_print_str("MODE 2 VREF="); 122 | send_number(adc_value, 10); 123 | //send_adc_sample(adc_value); 124 | send_byte('\n'); 125 | break; 126 | case 3: 127 | adc_value = sample_adc(ADC_Channel_8); 128 | rs232_print_str("MODE 3 PC0="); 129 | send_adc_sample(adc_value); 130 | send_byte('\n'); 131 | break; 132 | } 133 | 134 | /* A button has been pressed. Update the mode. */ 135 | if(button_pressed) { 136 | button_pressed = 0; 137 | 138 | mode++; 139 | if(mode > 4) { 140 | mode = 1; 141 | } 142 | 143 | if(mode == 4) { 144 | RCC_ClocksTypeDef RCC_Clocks; 145 | RCC_GetClocksFreq(&RCC_Clocks); 146 | rs232_print_str("\nMODE 4\n"); 147 | rs232_print_str("SYSCLK="); 148 | send_number(RCC_Clocks.SYSCLK_Frequency, 10); 149 | rs232_print_str("\n"); 150 | rs232_print_str("HCLK="); 151 | send_number(RCC_Clocks.HCLK_Frequency, 10); 152 | rs232_print_str("\n"); 153 | rs232_print_str("PCLK2="); 154 | send_number(RCC_Clocks.PCLK2_Frequency, 10); 155 | rs232_print_str("\n"); 156 | rs232_print_str("ADCCLK="); 157 | send_number(RCC_Clocks.ADCCLK_Frequency, 10); 158 | rs232_print_str("\n\n"); 159 | } 160 | } 161 | } 162 | } 163 | -------------------------------------------------------------------------------- /demos/adc_single/stm32f10x_conf.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file USART/HalfDuplex/stm32f10x_conf.h 4 | * @author MCD Application Team 5 | * @version V3.3.0 6 | * @date 04/16/2010 7 | * @brief Library configuration file. 8 | ****************************************************************************** 9 | * @copy 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2010 STMicroelectronics

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

© COPYRIGHT 2010 STMicroelectronics

19 | */ 20 | 21 | /* Define to prevent recursive inclusion -------------------------------------*/ 22 | #ifndef __STM32F10x_CONF_H 23 | #define __STM32F10x_CONF_H 24 | 25 | /* Includes ------------------------------------------------------------------*/ 26 | /* Uncomment the line below to enable peripheral header file inclusion */ 27 | /* #include "stm32f10x_adc.h" */ 28 | /* #include "stm32f10x_bkp.h" */ 29 | /* #include "stm32f10x_can.h" */ 30 | /* #include "stm32f10x_cec.h" */ 31 | /* #include "stm32f10x_crc.h" */ 32 | /* #include "stm32f10x_dac.h" */ 33 | /* #include "stm32f10x_dbgmcu.h" */ 34 | /* #include "stm32f10x_dma.h" */ 35 | /* #include "stm32f10x_exti.h" */ 36 | /* #include "stm32f10x_flash.h" */ 37 | /* #include "stm32f10x_fsmc.h" */ 38 | #include "stm32f10x_gpio.h" 39 | /* #include "stm32f10x_i2c.h" */ 40 | /* #include "stm32f10x_iwdg.h" */ 41 | /* #include "stm32f10x_pwr.h" */ 42 | /* #include "stm32f10x_rcc.h" */ 43 | /* #include "stm32f10x_rtc.h" */ 44 | /* #include "stm32f10x_sdio.h" */ 45 | /* #include "stm32f10x_spi.h" */ 46 | /* #include "stm32f10x_tim.h" */ 47 | /* #include "stm32f10x_usart.h" */ 48 | /* #include "stm32f10x_wwdg.h" */ 49 | /* #include "misc.h" */ /* High level functions for NVIC and SysTick (add-on to CMSIS functions) */ 50 | 51 | /* Exported types ------------------------------------------------------------*/ 52 | /* Exported constants --------------------------------------------------------*/ 53 | /* Uncomment the line below to expanse the "assert_param" macro in the 54 | Standard Peripheral Library drivers code */ 55 | /* #define USE_FULL_ASSERT 1 */ 56 | 57 | /* Exported macro ------------------------------------------------------------*/ 58 | #ifdef USE_FULL_ASSERT 59 | 60 | /** 61 | * @brief The assert_param macro is used for function's parameters check. 62 | * @param expr: If expr is false, it calls assert_failed function 63 | * which reports the name of the source file and the source 64 | * line number of the call that failed. 65 | * If expr is true, it returns no value. 66 | * @retval None 67 | */ 68 | #define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__)) 69 | /* Exported functions ------------------------------------------------------- */ 70 | void assert_failed(uint8_t* file, uint32_t line); 71 | #else 72 | #define assert_param(expr) ((void)0) 73 | #endif /* USE_FULL_ASSERT */ 74 | 75 | #endif /* __STM32F10x_CONF_H */ 76 | 77 | /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/ 78 | -------------------------------------------------------------------------------- /demos/blink_flash_asm/main.s: -------------------------------------------------------------------------------- 1 | .text 2 | 3 | /* See https://www.codesourcery.com/archives/arm-gnu/msg01396.html 4 | and http://www.sourceware.org/ml/binutils/2005-04/msg00902.html 5 | This avoids unshifted register error which occurs when compiling for Thumb */ 6 | .syntax unified 7 | .thumb 8 | 9 | .global main 10 | main: 11 | /* I have to use +1 in the address abel, otherwise the processor triggers 12 | an exception. The ARM documentation explains that thumb bx 13 | instructions require odd addresses. The C compiler does this 14 | automatically - I have examined the assembly generated by the C compiler, 15 | but still don't understand how they do it without manually appending 16 | a +1 to the address label. */ 17 | .word 0x20000800 /* stack pointer */ 18 | .word _c_entry+1 /* Entry point (reset vector) */ 19 | .rept 82 /* interrupt handlers */ 20 | .word _handler+1 21 | .endr 22 | 23 | 24 | 25 | 26 | _c_entry: 27 | /* Enable clock to Port C */ 28 | movw r3, #4096 29 | movt r3, #16386 30 | ldr r2, [r3, #24] 31 | orr r2, r2, #16 32 | str r2, [r3, #24] 33 | 34 | /* Turn LED off */ 35 | movw r3, #4096 36 | movt r3, #16385 37 | movw r2, #4096 38 | str r2, [r3, #16] 39 | 40 | ldr r2, [r3, #4] /* Change CRH pin 12 */ 41 | and r2, r2, #4293984255 42 | orr r2, r2, #196608 43 | str r2, [r3, #4] /* MODE = general purpose I/O, speed 50 Mhz */ 44 | 45 | ldr r2, [r3, #4] /* Get CRH */ 46 | 47 | _flash_loop: 48 | /* Turn LED on */ 49 | movw r2, #4096 50 | str r2, [r3, #20] 51 | 52 | 53 | 54 | movw r4, #0 55 | movt r4, #20 56 | delay1: 57 | sub.w r4, r4, #1 58 | cmp r4, #0 59 | bne delay1 60 | 61 | 62 | /* Turn LED off */ 63 | movw r2, #4096 64 | str r2, [r3, #16] 65 | 66 | 67 | 68 | movw r4, #0 69 | movt r4, #3 70 | delay2: 71 | sub.w r4, r4, #1 72 | cmp r4, #0 73 | bne delay2 74 | 75 | 76 | 77 | B _flash_loop 78 | 79 | 80 | 81 | _handler: 82 | bx lr /* Return immediately */ 83 | nop 84 | 85 | 86 | -------------------------------------------------------------------------------- /demos/button/main.c: -------------------------------------------------------------------------------- 1 | #define USE_STDPERIPH_DRIVER 2 | #include "stm32_p103.h" 3 | #include "stm32_p103.h" 4 | 5 | int main(void) 6 | { 7 | int last_button_state, new_button_state; 8 | 9 | init_led(); 10 | init_button(); 11 | 12 | /* Infinite loop - when the button changes state, toggle the LED. 13 | */ 14 | last_button_state = GPIOA->IDR & 0x00000001; 15 | while(1) { 16 | new_button_state = GPIOA->IDR & 0x00000001; 17 | if(new_button_state ^ last_button_state) { 18 | if(new_button_state) { 19 | GPIOC->ODR = GPIOC->ODR ^ 0x00001000; 20 | } 21 | } 22 | last_button_state = new_button_state; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /demos/button/stm32f10x_conf.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file GPIO/IOToggle/stm32f10x_conf.h 4 | * @author MCD Application Team 5 | * @version V3.3.0 6 | * @date 04/16/2010 7 | * @brief Library configuration file. 8 | ****************************************************************************** 9 | * @copy 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2010 STMicroelectronics

19 | */ 20 | 21 | /* Define to prevent recursive inclusion -------------------------------------*/ 22 | #ifndef __STM32F10x_CONF_H 23 | #define __STM32F10x_CONF_H 24 | 25 | /* Includes ------------------------------------------------------------------*/ 26 | /* Uncomment the line below to enable peripheral header file inclusion */ 27 | /* #include "stm32f10x_adc.h" */ 28 | /* #include "stm32f10x_bkp.h" */ 29 | /* #include "stm32f10x_can.h" */ 30 | /* #include "stm32f10x_cec.h" */ 31 | /* #include "stm32f10x_crc.h" */ 32 | /* #include "stm32f10x_dac.h" */ 33 | /* #include "stm32f10x_dbgmcu.h" */ 34 | /* #include "stm32f10x_dma.h" */ 35 | /* #include "stm32f10x_exti.h" */ 36 | /* #include "stm32f10x_flash.h" */ 37 | /* #include "stm32f10x_fsmc.h" */ 38 | #include "stm32f10x_gpio.h" 39 | /* #include "stm32f10x_i2c.h" */ 40 | /* #include "stm32f10x_iwdg.h" */ 41 | /* #include "stm32f10x_pwr.h" */ 42 | /* #include "stm32f10x_rcc.h" */ 43 | /* #include "stm32f10x_rtc.h" */ 44 | /* #include "stm32f10x_sdio.h" */ 45 | /* #include "stm32f10x_spi.h" */ 46 | /* #include "stm32f10x_tim.h" */ 47 | /* #include "stm32f10x_usart.h" */ 48 | /* #include "stm32f10x_wwdg.h" */ 49 | /* #include "misc.h" */ /* High level functions for NVIC and SysTick (add-on to CMSIS functions) */ 50 | 51 | /* Exported types ------------------------------------------------------------*/ 52 | /* Exported constants --------------------------------------------------------*/ 53 | /* Uncomment the line below to expanse the "assert_param" macro in the 54 | Standard Peripheral Library drivers code */ 55 | /* #define USE_FULL_ASSERT 1 */ 56 | 57 | /* Exported macro ------------------------------------------------------------*/ 58 | #ifdef USE_FULL_ASSERT 59 | 60 | /** 61 | * @brief The assert_param macro is used for function's parameters check. 62 | * @param expr: If expr is false, it calls assert_failed function 63 | * which reports the name of the source file and the source 64 | * line number of the call that failed. 65 | * If expr is true, it returns no value. 66 | * @retval None 67 | */ 68 | #define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__)) 69 | /* Exported functions ------------------------------------------------------- */ 70 | void assert_failed(uint8_t* file, uint32_t line); 71 | #else 72 | #define assert_param(expr) ((void)0) 73 | #endif /* USE_FULL_ASSERT */ 74 | 75 | #endif /* __STM32F10x_CONF_H */ 76 | 77 | /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/ 78 | -------------------------------------------------------------------------------- /demos/button_int/main.c: -------------------------------------------------------------------------------- 1 | #define USE_STDPERIPH_DRIVER 2 | #include "stm32_p103.h" 3 | #include "stm32_p103.h" 4 | 5 | /* Handler predefined by STM32 library to handle interrupts on EXTI line 0 6 | * (which is mapped to the button on GPIO A Line 0). 7 | */ 8 | void EXTI0_IRQHandler(void) 9 | { 10 | /* Make sure the line has a pending interrupt 11 | * (should this always be true if we are inside the interrupt handle?) */ 12 | if(EXTI_GetITStatus(EXTI_Line0) != RESET) { 13 | /* Toggle the LED */ 14 | GPIOC->ODR = GPIOC->ODR ^ 0x00001000; 15 | 16 | /* Clear the pending interrupt flag that triggered this interrupt. 17 | * If DO_NOT_CLEAR_IT_PENDING_FLAG is defined, this part is skipped. 18 | * This will cause the interrupt handler to repeatedly run in an 19 | * infinite loop (which will cause the LED to repeatedly toggle too 20 | * fast to be seen). 21 | */ 22 | #ifndef DO_NOT_CLEAR_IT_PENDING_FLAG 23 | EXTI_ClearITPendingBit(EXTI_Line0); 24 | #endif 25 | } 26 | } 27 | 28 | int main(void) 29 | { 30 | init_led(); 31 | 32 | init_button(); 33 | enable_button_interrupts(); 34 | 35 | /* Go into an infinite loop. When the button is pressed, the interrupt 36 | * routine will be called. 37 | */ 38 | while(1); 39 | } 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /demos/button_int/stm32f10x_conf.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file GPIO/IOToggle/stm32f10x_conf.h 4 | * @author MCD Application Team 5 | * @version V3.3.0 6 | * @date 04/16/2010 7 | * @brief Library configuration file. 8 | ****************************************************************************** 9 | * @copy 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2010 STMicroelectronics

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

© COPYRIGHT 2010 STMicroelectronics

19 | */ 20 | 21 | /* Define to prevent recursive inclusion -------------------------------------*/ 22 | #ifndef __STM32F10x_CONF_H 23 | #define __STM32F10x_CONF_H 24 | 25 | /* Includes ------------------------------------------------------------------*/ 26 | /* Uncomment the line below to enable peripheral header file inclusion */ 27 | /* #include "stm32f10x_adc.h" */ 28 | /* #include "stm32f10x_bkp.h" */ 29 | /* #include "stm32f10x_can.h" */ 30 | /* #include "stm32f10x_cec.h" */ 31 | /* #include "stm32f10x_crc.h" */ 32 | /* #include "stm32f10x_dac.h" */ 33 | /* #include "stm32f10x_dbgmcu.h" */ 34 | /* #include "stm32f10x_dma.h" */ 35 | /* #include "stm32f10x_exti.h" */ 36 | /* #include "stm32f10x_flash.h" */ 37 | /* #include "stm32f10x_fsmc.h" */ 38 | /* #include "stm32f10x_gpio.h" */ 39 | /* #include "stm32f10x_i2c.h" */ 40 | /* #include "stm32f10x_iwdg.h" */ 41 | /* #include "stm32f10x_pwr.h" */ 42 | /* #include "stm32f10x_rcc.h" */ 43 | /* #include "stm32f10x_rtc.h" */ 44 | /* #include "stm32f10x_sdio.h" */ 45 | /* #include "stm32f10x_spi.h" */ 46 | /* #include "stm32f10x_tim.h" */ 47 | /* #include "stm32f10x_usart.h" */ 48 | /* #include "stm32f10x_wwdg.h" */ 49 | /* #include "misc.h" */ /* High level functions for NVIC and SysTick (add-on to CMSIS functions) */ 50 | 51 | /* Exported types ------------------------------------------------------------*/ 52 | /* Exported constants --------------------------------------------------------*/ 53 | /* Uncomment the line below to expanse the "assert_param" macro in the 54 | Standard Peripheral Library drivers code */ 55 | /* #define USE_FULL_ASSERT 1 */ 56 | 57 | /* Exported macro ------------------------------------------------------------*/ 58 | #ifdef USE_FULL_ASSERT 59 | 60 | /** 61 | * @brief The assert_param macro is used for function's parameters check. 62 | * @param expr: If expr is false, it calls assert_failed function 63 | * which reports the name of the source file and the source 64 | * line number of the call that failed. 65 | * If expr is true, it returns no value. 66 | * @retval None 67 | */ 68 | #define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__)) 69 | /* Exported functions ------------------------------------------------------- */ 70 | void assert_failed(uint8_t* file, uint32_t line); 71 | #else 72 | #define assert_param(expr) ((void)0) 73 | #endif /* USE_FULL_ASSERT */ 74 | 75 | #endif /* __STM32F10x_CONF_H */ 76 | 77 | /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/ 78 | -------------------------------------------------------------------------------- /demos/common/myprintk.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef NULL 4 | #define NULL ((void *)0) 5 | #endif 6 | 7 | //equal to printf 8 | //not support : float,64bit integer, 9 | //support: %d, %x, %s, %c, %p 10 | void myprintf (const char *fmt, ...); 11 | //init usart2 for printf 12 | void myprintf_init(); 13 | 14 | 15 | -------------------------------------------------------------------------------- /demos/common/stm32_p103.c: -------------------------------------------------------------------------------- 1 | #include "stm32_p103.h" 2 | #include "stm32f10x.h" 3 | #include "stm32f10x_gpio.h" 4 | #include "stm32f10x_rcc.h" 5 | #include "stm32f10x_usart.h" 6 | #include "stm32f10x_exti.h" 7 | #include "stm32f10x_adc.h" 8 | #include "misc.h" 9 | 10 | void init_led(void) 11 | { 12 | GPIO_InitTypeDef GPIO_InitStructure; 13 | 14 | /* Enable GPIO C clock. */ 15 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE); 16 | 17 | /* Set the LED pin state such that the LED is off. The LED is connected 18 | * between power and the microcontroller pin, which makes it turn on when 19 | * the pin is low. 20 | */ 21 | GPIO_WriteBit(GPIOC,GPIO_Pin_12,Bit_SET); 22 | 23 | /* Configure the LED pin as push-pull output. */ 24 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12; 25 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; 26 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 27 | GPIO_Init(GPIOC, &GPIO_InitStructure); 28 | } 29 | 30 | void init_button(void) 31 | { 32 | GPIO_InitTypeDef GPIO_InitStructure; 33 | 34 | /* Enable GPIO A clock */ 35 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); 36 | 37 | /* Configure the button pin as a floating input. */ 38 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0; 39 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; 40 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 41 | GPIO_Init(GPIOC, &GPIO_InitStructure); 42 | } 43 | 44 | void enable_button_interrupts(void) 45 | { 46 | EXTI_InitTypeDef EXTI_InitStructure; 47 | NVIC_InitTypeDef NVIC_InitStructure; 48 | 49 | /* Enable the AFIO clock. GPIO_EXTILineConfig sets registers in 50 | * the AFIO. 51 | */ 52 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE); 53 | 54 | /* Connect EXTI Line 0 to the button GPIO Pin */ 55 | GPIO_EXTILineConfig(GPIO_PortSourceGPIOA, GPIO_PinSource0); 56 | 57 | /* Configure the EXTI line to generate an interrupt when the button is 58 | * pressed. The button pin is high when pressed, so it needs to trigger 59 | * when rising from low to high. */ 60 | EXTI_InitStructure.EXTI_Line = EXTI_Line0; 61 | EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt; 62 | EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising; 63 | EXTI_InitStructure.EXTI_LineCmd = ENABLE; 64 | EXTI_Init(&EXTI_InitStructure); 65 | 66 | /* Enable and set Button EXTI Interrupt to the lowest priority */ 67 | NVIC_InitStructure.NVIC_IRQChannel = EXTI0_IRQn; 68 | NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x0F; 69 | NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x0F; 70 | NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; 71 | NVIC_Init(&NVIC_InitStructure); 72 | } 73 | 74 | void init_rs232(void) 75 | { 76 | USART_InitTypeDef USART_InitStructure; 77 | GPIO_InitTypeDef GPIO_InitStructure; 78 | 79 | /* Enable peripheral clocks. */ 80 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_AFIO, ENABLE); 81 | RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE); 82 | 83 | /* Configure USART2 Rx pin as floating input. */ 84 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3; 85 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; 86 | GPIO_Init(GPIOA, &GPIO_InitStructure); 87 | 88 | /* Configure USART2 Tx as alternate function push-pull. */ 89 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2; 90 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 91 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; 92 | GPIO_Init(GPIOA, &GPIO_InitStructure); 93 | 94 | /* Configure the USART2 */ 95 | USART_InitStructure.USART_BaudRate = 9600; 96 | USART_InitStructure.USART_WordLength = USART_WordLength_8b; 97 | USART_InitStructure.USART_StopBits = USART_StopBits_1; 98 | USART_InitStructure.USART_Parity = USART_Parity_No; 99 | USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; 100 | USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; 101 | USART_Init(USART2, &USART_InitStructure); 102 | USART_Cmd(USART2, ENABLE); 103 | } 104 | 105 | void enable_rs232_interrupts(void) 106 | { 107 | NVIC_InitTypeDef NVIC_InitStructure; 108 | 109 | /* Enable transmit and receive interrupts for the USART2. */ 110 | USART_ITConfig(USART2, USART_IT_TXE, DISABLE); 111 | USART_ITConfig(USART2, USART_IT_RXNE, ENABLE); 112 | 113 | /* Enable the USART2 IRQ in the NVIC module (so that the USART2 interrupt 114 | * handler is enabled). */ 115 | NVIC_InitStructure.NVIC_IRQChannel = USART2_IRQn; 116 | NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; 117 | NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; 118 | NVIC_Init(&NVIC_InitStructure); 119 | } 120 | 121 | void enable_rs232(void) 122 | { 123 | /* Enable the RS232 port. */ 124 | USART_Cmd(USART2, ENABLE); 125 | } 126 | 127 | void rs232_print_str(const char *str) 128 | { 129 | const char *curr_char = str; 130 | 131 | while(*curr_char != '\0') { 132 | while(USART_GetFlagStatus(USART2, USART_FLAG_TXE) == RESET); 133 | USART_SendData(USART2, *curr_char); 134 | curr_char++; 135 | } 136 | } 137 | 138 | /* Functions for sending numbers through the UART */ 139 | char hex_to_char(unsigned hex_number) 140 | { 141 | if(hex_number < 0xA) { 142 | return hex_number + '0'; 143 | } else { 144 | return hex_number - 0xA + 'A'; 145 | } 146 | } 147 | 148 | void send_byte(uint8_t b) 149 | { 150 | /* Wait until the RS232 port can receive another byte. */ 151 | while(USART_GetFlagStatus(USART2, USART_FLAG_TXE) == RESET); 152 | 153 | /* Toggle the LED just to show that progress is being made. */ 154 | GPIOC->ODR ^= 0x00001000; 155 | 156 | /* Send the byte */ 157 | USART_SendData(USART2, b); 158 | } 159 | 160 | void send_number(unsigned long sample, int radix) 161 | { 162 | int digit; 163 | unsigned long mod; 164 | char str[100]; 165 | 166 | digit = 0; 167 | do { 168 | mod = sample % radix; 169 | str[digit] = hex_to_char(mod); 170 | sample /= radix; 171 | digit++; 172 | } while(sample != 0); 173 | 174 | while(digit != 0) { 175 | digit--; 176 | while(USART_GetFlagStatus(USART2, USART_FLAG_TXE) == RESET); 177 | USART_SendData(USART2, str[digit]); 178 | } 179 | } 180 | -------------------------------------------------------------------------------- /demos/common/stm32_p103.h: -------------------------------------------------------------------------------- 1 | #ifndef __STM32_P103_H 2 | #define __STM32_P103_H 3 | 4 | #include "stm32f10x.h" 5 | 6 | /* This library contains routines for interfacing with the STM32 P103 board. */ 7 | 8 | /* Initialize the LED (the board only has one). */ 9 | void init_led(void); 10 | 11 | /* Initialize the button (the board only has one). */ 12 | void init_button(void); 13 | 14 | /* Configures the RS232 serial port using the following settings: 15 | * 9600 Baud 16 | * 8 bits + 1 stop bit 17 | * No parity bit 18 | * No hardware flow control 19 | * Note that the USART2 is not enabled in this routine. It is left disabled in 20 | * case any additional configuration is needed. 21 | */ 22 | void init_rs232(void); 23 | 24 | void enable_rs232_interrupts(void); 25 | 26 | void enable_rs232(void); 27 | 28 | /* Functions for sending numbers through the UART */ 29 | void send_byte(uint8_t b); 30 | void send_number(unsigned long sample, int radix); 31 | 32 | // Missing prototype declarations 33 | void enable_button_interrupts(void); 34 | void rs232_print_str(const char *str); 35 | char hex_to_char(unsigned hex_number); 36 | 37 | #endif /* __STM32_P103_H */ 38 | -------------------------------------------------------------------------------- /demos/dac/main.c: -------------------------------------------------------------------------------- 1 | #define USE_STDPERIPH_DRIVER 2 | #include "stm32_p103.h" 3 | 4 | /* Flag whenever the button is pressed. 5 | * Note that the interrupt handler is initialized to only 6 | * fire when the button is pressed, not released. 7 | */ 8 | uint8_t button_pressed = 0; 9 | void EXTI0_IRQHandler(void) 10 | { 11 | /* Make sure the line has a pending interrupt 12 | * (should this always be true if we are inside the interrupt handle?) */ 13 | if(EXTI_GetITStatus(EXTI_Line0) != RESET) { 14 | button_pressed = 1; 15 | EXTI_ClearITPendingBit(EXTI_Line0); 16 | } 17 | } 18 | 19 | /* ADC functions */ 20 | 21 | void send_char(char x) 22 | { 23 | while(USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET); 24 | USART_SendData(USART1,x); 25 | } 26 | 27 | void send_str(char* str) 28 | { 29 | int x=0; 30 | while(str[x]) 31 | send_char(str[x++]); 32 | } 33 | 34 | void send_nbr(int nbr) 35 | { 36 | if(nbr/10) 37 | send_nbr(nbr/10); 38 | send_char((nbr%10)+48); 39 | } 40 | 41 | void init_dac(void) { 42 | 43 | DAC_InitTypeDef DAC_InitStructure; 44 | GPIO_InitTypeDef GPIO_InitStructure; 45 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4 | GPIO_Pin_5 ; 46 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN; 47 | GPIO_Init(GPIOA, &GPIO_InitStructure); 48 | 49 | DAC_InitStructure.DAC_Trigger=DAC_Trigger_Software; 50 | DAC_InitStructure.DAC_WaveGeneration = DAC_WaveGeneration_Noise;//DAC_WaveGeneration_Triangle;//DAC_WaveGeneration_Noise 51 | DAC_InitStructure.DAC_LFSRUnmask_TriangleAmplitude=DAC_LFSRUnmask_Bits3_0;//DAC_TriangleAmplitude_255; //DAC_LFSRUnmask_Bits3_0 52 | DAC_InitStructure.DAC_OutputBuffer = DAC_OutputBuffer_Enable; 53 | DAC_Init(DAC_Channel_2, &DAC_InitStructure); 54 | 55 | DAC_Cmd(DAC_Channel_2, ENABLE); 56 | 57 | //set_DAC2_triangle_waveform_amplitude(peak); 58 | //enable_DAC2_channel(true); 59 | 60 | } 61 | void USART1_Init(void) 62 | { 63 | USART_InitTypeDef USART_InitStructure; 64 | GPIO_InitTypeDef GPIO_InitStructure; 65 | 66 | /* Configure USART1 Rx pin as floating input. */ 67 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; 68 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; 69 | GPIO_Init(GPIOA, &GPIO_InitStructure); 70 | 71 | /* Configure USART1 Tx as alternate function push-pull. */ 72 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9; 73 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 74 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; 75 | GPIO_Init(GPIOA, &GPIO_InitStructure); 76 | 77 | 78 | /* Configure the USART1 */ 79 | USART_InitStructure.USART_BaudRate = 9600; 80 | USART_InitStructure.USART_WordLength = USART_WordLength_8b; 81 | USART_InitStructure.USART_StopBits = USART_StopBits_1; 82 | USART_InitStructure.USART_Parity = USART_Parity_No; 83 | USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; 84 | USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; 85 | USART_Init(USART1, &USART_InitStructure); 86 | 87 | } 88 | 89 | void init_RCC() 90 | { 91 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOC | RCC_APB2Periph_USART1 | RCC_APB2Periph_AFIO, ENABLE); 92 | RCC_APB1PeriphClockCmd(RCC_APB1Periph_DAC ,ENABLE); 93 | } 94 | 95 | void sleep() 96 | { 97 | int i=1000000; 98 | while(i-->0); 99 | } 100 | 101 | 102 | int main(void) 103 | { 104 | /* Initialization */ 105 | 106 | init_led(); 107 | USART1_Init(); 108 | init_dac(); 109 | init_RCC(); 110 | USART_Cmd(USART1, ENABLE); 111 | 112 | send_str("*******DEMO of DAC*******"); 113 | DAC_SetChannel2Data(DAC_Align_12b_L,150<<4); 114 | 115 | while(1) 116 | { 117 | DAC->SWTRIGR=0x02; 118 | sleep(); 119 | } 120 | 121 | 122 | return 0; 123 | 124 | } 125 | -------------------------------------------------------------------------------- /demos/dac/stm32f10x_conf.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file USART/HalfDuplex/stm32f10x_conf.h 4 | * @author MCD Application Team 5 | * @version V3.3.0 6 | * @date 04/16/2010 7 | * @brief Library configuration file. 8 | ****************************************************************************** 9 | * @copy 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2010 STMicroelectronics

19 | */ 20 | 21 | /* Define to prevent recursive inclusion -------------------------------------*/ 22 | #ifndef __STM32F10x_CONF_H 23 | #define __STM32F10x_CONF_H 24 | 25 | /* Includes ------------------------------------------------------------------*/ 26 | /* Uncomment the line below to enable peripheral header file inclusion */ 27 | #include "stm32f10x_adc.h" 28 | /* #include "stm32f10x_bkp.h" */ 29 | /* #include "stm32f10x_can.h" */ 30 | /* #include "stm32f10x_cec.h" */ 31 | /* #include "stm32f10x_crc.h" */ 32 | #include "stm32f10x_dac.h" 33 | /* #include "stm32f10x_dbgmcu.h" */ 34 | /* #include "stm32f10x_dma.h" */ 35 | #include "stm32f10x_exti.h" 36 | /* #include "stm32f10x_flash.h" */ 37 | /* #include "stm32f10x_fsmc.h" */ 38 | #include "stm32f10x_gpio.h" 39 | /* #include "stm32f10x_i2c.h" */ 40 | /* #include "stm32f10x_iwdg.h" */ 41 | /* #include "stm32f10x_pwr.h" */ 42 | #include "stm32f10x_rcc.h" 43 | /* #include "stm32f10x_rtc.h" */ 44 | /* #include "stm32f10x_sdio.h" */ 45 | /* #include "stm32f10x_spi.h" */ 46 | /* #include "stm32f10x_tim.h" */ 47 | #include "stm32f10x_usart.h" 48 | /* #include "stm32f10x_wwdg.h" */ 49 | /* #include "misc.h" */ /* High level functions for NVIC and SysTick (add-on to CMSIS functions) */ 50 | 51 | /* Exported types ------------------------------------------------------------*/ 52 | /* Exported constants --------------------------------------------------------*/ 53 | /* Uncomment the line below to expanse the "assert_param" macro in the 54 | Standard Peripheral Library drivers code */ 55 | /* #define USE_FULL_ASSERT 1 */ 56 | 57 | /* Exported macro ------------------------------------------------------------*/ 58 | #ifdef USE_FULL_ASSERT 59 | /** 60 | * @brief The assert_param macro is used for function's parameters check. 61 | * @param expr: If expr is false, it calls assert_failed function 62 | * which reports the name of the source file and the source 63 | * line number of the call that failed. 64 | * If expr is true, it returns no value. 65 | * @retval None 66 | */ 67 | #define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__)) 68 | /* Exported functions ------------------------------------------------------- */ 69 | void assert_failed(uint8_t* file, uint32_t line); 70 | #else 71 | #define assert_param(expr) ((void)0) 72 | #endif /* USE_FULL_ASSERT */ 73 | 74 | #endif /* __STM32F10x_CONF_H */ 75 | 76 | /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/ 77 | -------------------------------------------------------------------------------- /demos/freertos_cycletask/FreeRTOSConfig.h: -------------------------------------------------------------------------------- 1 | /* 2 | FreeRTOS V6.0.5 - Copyright (C) 2010 Real Time Engineers Ltd. 3 | 4 | *************************************************************************** 5 | * * 6 | * If you are: * 7 | * * 8 | * + New to FreeRTOS, * 9 | * + Wanting to learn FreeRTOS or multitasking in general quickly * 10 | * + Looking for basic training, * 11 | * + Wanting to improve your FreeRTOS skills and productivity * 12 | * * 13 | * then take a look at the FreeRTOS eBook * 14 | * * 15 | * "Using the FreeRTOS Real Time Kernel - a Practical Guide" * 16 | * http://www.FreeRTOS.org/Documentation * 17 | * * 18 | * A pdf reference manual is also available. Both are usually delivered * 19 | * to your inbox within 20 minutes to two hours when purchased between 8am * 20 | * and 8pm GMT (although please allow up to 24 hours in case of * 21 | * exceptional circumstances). Thank you for your support! * 22 | * * 23 | *************************************************************************** 24 | 25 | This file is part of the FreeRTOS distribution. 26 | 27 | FreeRTOS is free software; you can redistribute it and/or modify it under 28 | the terms of the GNU General Public License (version 2) as published by the 29 | Free Software Foundation AND MODIFIED BY the FreeRTOS exception. 30 | ***NOTE*** The exception to the GPL is included to allow you to distribute 31 | a combined work that includes FreeRTOS without being obliged to provide the 32 | source code for proprietary components outside of the FreeRTOS kernel. 33 | FreeRTOS is distributed in the hope that it will be useful, but WITHOUT 34 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 35 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 36 | more details. You should have received a copy of the GNU General Public 37 | License and the FreeRTOS license exception along with FreeRTOS; if not it 38 | can be viewed here: http://www.freertos.org/a00114.html and also obtained 39 | by writing to Richard Barry, contact details for whom are available on the 40 | FreeRTOS WEB site. 41 | 42 | 1 tab == 4 spaces! 43 | 44 | http://www.FreeRTOS.org - Documentation, latest information, license and 45 | contact details. 46 | 47 | http://www.SafeRTOS.com - A version that is certified for use in safety 48 | critical systems. 49 | 50 | http://www.OpenRTOS.com - Commercial support, development, porting, 51 | licensing and training services. 52 | */ 53 | 54 | #ifndef FREERTOS_CONFIG_H 55 | #define FREERTOS_CONFIG_H 56 | 57 | #define xPortPendSVHandler PendSV_Handler 58 | #define xPortSysTickHandler SysTick_Handler 59 | #define vPortSVCHandler SVC_Handler 60 | 61 | 62 | #define pdFALSE ( ( BaseType_t ) 0 ) 63 | #define pdTRUE ( ( BaseType_t ) 1 ) 64 | 65 | /*----------------------------------------------------------- 66 | * Application specific definitions. 67 | * 68 | * These definitions should be adjusted for your particular hardware and 69 | * application requirements. 70 | * 71 | * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE 72 | * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE. 73 | * 74 | * See http://www.freertos.org/a00110.html. 75 | *----------------------------------------------------------*/ 76 | 77 | #define configUSE_PREEMPTION 1 78 | #define configUSE_IDLE_HOOK 0 79 | #define configUSE_TICK_HOOK 1 80 | #define configCPU_CLOCK_HZ ( ( unsigned long ) 72000000 ) 81 | #define configTICK_RATE_HZ ( ( portTickType ) 100 ) 82 | #define configMAX_PRIORITIES ( 5 ) 83 | #define configMINIMAL_STACK_SIZE ( ( unsigned short ) 128 ) 84 | #define configTOTAL_HEAP_SIZE ( ( size_t ) ( 17 * 1024 ) ) 85 | #define configMAX_TASK_NAME_LEN ( 16 ) 86 | #define configUSE_TRACE_FACILITY 0 87 | #define configUSE_16_BIT_TICKS 0 88 | #define configIDLE_SHOULD_YIELD 1 89 | #define configUSE_MUTEXES 1 90 | 91 | /* Co-routine definitions. */ 92 | #define configUSE_CO_ROUTINES 0 93 | #define configMAX_CO_ROUTINE_PRIORITIES ( 2 ) 94 | 95 | /* Set the following definitions to 1 to include the API function, or zero 96 | to exclude the API function. */ 97 | 98 | #define INCLUDE_vTaskPrioritySet 1 99 | #define INCLUDE_uxTaskPriorityGet 1 100 | #define INCLUDE_vTaskDelete 1 101 | //#define INCLUDE_vTaskCleanUpResources 0 102 | #define INCLUDE_vTaskSuspend 1 103 | #define INCLUDE_vTaskDelayUntil 1 104 | #define INCLUDE_vTaskDelay 1 105 | 106 | /* This is the raw value as per the Cortex-M3 NVIC. Values can be 255 107 | (lowest) to 0 (1?) (highest). */ 108 | #define configKERNEL_INTERRUPT_PRIORITY 127 //Needs to be below 240 (0xf0) to work with QEMU, since this is the priority mask used 109 | #define configMAX_SYSCALL_INTERRUPT_PRIORITY 191 /* equivalent to 0xb0, or priority 11. */ 110 | 111 | 112 | /* This is the value being used as per the ST library which permits 16 113 | priority values, 0 to 15. This must correspond to the 114 | configKERNEL_INTERRUPT_PRIORITY setting. Here 15 corresponds to the lowest 115 | NVIC value of 255. */ 116 | #define configLIBRARY_KERNEL_INTERRUPT_PRIORITY 15 117 | 118 | #endif /* FREERTOS_CONFIG_H */ 119 | 120 | -------------------------------------------------------------------------------- /demos/freertos_cycletask/main.c: -------------------------------------------------------------------------------- 1 | #define USE_STDPERIPH_DRIVER 2 | #include "stm32_p103.h" 3 | 4 | /* Scheduler includes. */ 5 | #include "FreeRTOS.h" 6 | #include "task.h" 7 | #include "queue.h" 8 | #include "semphr.h" 9 | #include 10 | #include "myprintk.h" 11 | 12 | 13 | 14 | void cycle_task_1(void* param) 15 | { 16 | TickType_t first= xTaskGetTickCount(); 17 | TickType_t next; 18 | TickType_t last=xTaskGetTickCount(); 19 | TickType_t tick; 20 | while(1){ 21 | tick = xTaskGetTickCount(); 22 | myprintf("true cycletask - TaskDelayUntil 100 : current tick : %d delta %d \n",tick,tick-last); 23 | last = tick; 24 | vTaskDelayUntil(&first,100); 25 | } 26 | } 27 | 28 | void cycle_task_2(void* param) 29 | { 30 | TickType_t last=xTaskGetTickCount(); 31 | TickType_t tick; 32 | while(1){ 33 | tick = xTaskGetTickCount(); 34 | myprintf("fake cycletask - TaskDelay 100 : current tick : %d delta %d \n",tick,tick-last); 35 | last=tick; 36 | vTaskDelay(100); 37 | } 38 | } 39 | 40 | int main(void) 41 | { 42 | 43 | myprintf_init(); 44 | 45 | xTaskCreate(cycle_task_1, ( signed portCHAR * ) "cycle", 128/* stack size */, NULL, tskIDLE_PRIORITY + 10, NULL ); 46 | xTaskCreate(cycle_task_2, ( signed portCHAR * ) "fake", 128/* stack size */, NULL, tskIDLE_PRIORITY + 10, NULL ); 47 | 48 | /* Start running the tasks. */ 49 | vTaskStartScheduler(); 50 | 51 | return 0; 52 | } 53 | 54 | void vApplicationTickHook( void ) 55 | { 56 | } 57 | -------------------------------------------------------------------------------- /demos/freertos_cycletask/stm32f10x_conf.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file GPIO/IOToggle/stm32f10x_conf.h 4 | * @author MCD Application Team 5 | * @version V3.3.0 6 | * @date 04/16/2010 7 | * @brief Library configuration file. 8 | ****************************************************************************** 9 | * @copy 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2010 STMicroelectronics

19 | */ 20 | 21 | /* Define to prevent recursive inclusion -------------------------------------*/ 22 | #ifndef __STM32F10x_CONF_H 23 | #define __STM32F10x_CONF_H 24 | 25 | /* Includes ------------------------------------------------------------------*/ 26 | /* Uncomment the line below to enable peripheral header file inclusion */ 27 | /* #include "stm32f10x_adc.h" */ 28 | /* #include "stm32f10x_bkp.h" */ 29 | /* #include "stm32f10x_can.h" */ 30 | /* #include "stm32f10x_cec.h" */ 31 | /* #include "stm32f10x_crc.h" */ 32 | /* #include "stm32f10x_dac.h" */ 33 | /* #include "stm32f10x_dbgmcu.h" */ 34 | /* #include "stm32f10x_dma.h" */ 35 | /* #include "stm32f10x_exti.h" */ 36 | /* #include "stm32f10x_flash.h" */ 37 | /* #include "stm32f10x_fsmc.h" */ 38 | #include "stm32f10x_gpio.h" 39 | /* #include "stm32f10x_i2c.h" */ 40 | /* #include "stm32f10x_iwdg.h" */ 41 | /* #include "stm32f10x_pwr.h" */ 42 | /* #include "stm32f10x_rcc.h" */ 43 | /* #include "stm32f10x_rtc.h" */ 44 | /* #include "stm32f10x_sdio.h" */ 45 | /* #include "stm32f10x_spi.h" */ 46 | /* #include "stm32f10x_tim.h" */ 47 | #include "stm32f10x_usart.h" 48 | /* #include "stm32f10x_wwdg.h" */ 49 | /* #include "misc.h" */ /* High level functions for NVIC and SysTick (add-on to CMSIS functions) */ 50 | 51 | /* Exported types ------------------------------------------------------------*/ 52 | /* Exported constants --------------------------------------------------------*/ 53 | /* Uncomment the line below to expanse the "assert_param" macro in the 54 | Standard Peripheral Library drivers code */ 55 | /* #define USE_FULL_ASSERT 1 */ 56 | 57 | /* Exported macro ------------------------------------------------------------*/ 58 | #ifdef USE_FULL_ASSERT 59 | 60 | /** 61 | * @brief The assert_param macro is used for function's parameters check. 62 | * @param expr: If expr is false, it calls assert_failed function 63 | * which reports the name of the source file and the source 64 | * line number of the call that failed. 65 | * If expr is true, it returns no value. 66 | * @retval None 67 | */ 68 | #define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__)) 69 | /* Exported functions ------------------------------------------------------- */ 70 | void assert_failed(uint8_t* file, uint32_t line); 71 | #else 72 | #define assert_param(expr) ((void)0) 73 | #endif /* USE_FULL_ASSERT */ 74 | 75 | #endif /* __STM32F10x_CONF_H */ 76 | 77 | /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/ 78 | -------------------------------------------------------------------------------- /demos/freertos_multithread/FreeRTOSConfig.h: -------------------------------------------------------------------------------- 1 | /* 2 | FreeRTOS V6.0.5 - Copyright (C) 2010 Real Time Engineers Ltd. 3 | 4 | *************************************************************************** 5 | * * 6 | * If you are: * 7 | * * 8 | * + New to FreeRTOS, * 9 | * + Wanting to learn FreeRTOS or multitasking in general quickly * 10 | * + Looking for basic training, * 11 | * + Wanting to improve your FreeRTOS skills and productivity * 12 | * * 13 | * then take a look at the FreeRTOS eBook * 14 | * * 15 | * "Using the FreeRTOS Real Time Kernel - a Practical Guide" * 16 | * http://www.FreeRTOS.org/Documentation * 17 | * * 18 | * A pdf reference manual is also available. Both are usually delivered * 19 | * to your inbox within 20 minutes to two hours when purchased between 8am * 20 | * and 8pm GMT (although please allow up to 24 hours in case of * 21 | * exceptional circumstances). Thank you for your support! * 22 | * * 23 | *************************************************************************** 24 | 25 | This file is part of the FreeRTOS distribution. 26 | 27 | FreeRTOS is free software; you can redistribute it and/or modify it under 28 | the terms of the GNU General Public License (version 2) as published by the 29 | Free Software Foundation AND MODIFIED BY the FreeRTOS exception. 30 | ***NOTE*** The exception to the GPL is included to allow you to distribute 31 | a combined work that includes FreeRTOS without being obliged to provide the 32 | source code for proprietary components outside of the FreeRTOS kernel. 33 | FreeRTOS is distributed in the hope that it will be useful, but WITHOUT 34 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 35 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 36 | more details. You should have received a copy of the GNU General Public 37 | License and the FreeRTOS license exception along with FreeRTOS; if not it 38 | can be viewed here: http://www.freertos.org/a00114.html and also obtained 39 | by writing to Richard Barry, contact details for whom are available on the 40 | FreeRTOS WEB site. 41 | 42 | 1 tab == 4 spaces! 43 | 44 | http://www.FreeRTOS.org - Documentation, latest information, license and 45 | contact details. 46 | 47 | http://www.SafeRTOS.com - A version that is certified for use in safety 48 | critical systems. 49 | 50 | http://www.OpenRTOS.com - Commercial support, development, porting, 51 | licensing and training services. 52 | */ 53 | 54 | #ifndef FREERTOS_CONFIG_H 55 | #define FREERTOS_CONFIG_H 56 | 57 | #define xPortPendSVHandler PendSV_Handler 58 | #define xPortSysTickHandler SysTick_Handler 59 | #define vPortSVCHandler SVC_Handler 60 | 61 | 62 | 63 | /*----------------------------------------------------------- 64 | * Application specific definitions. 65 | * 66 | * These definitions should be adjusted for your particular hardware and 67 | * application requirements. 68 | * 69 | * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE 70 | * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE. 71 | * 72 | * See http://www.freertos.org/a00110.html. 73 | *----------------------------------------------------------*/ 74 | 75 | #define configUSE_PREEMPTION 1 76 | #define configUSE_IDLE_HOOK 0 77 | #define configUSE_TICK_HOOK 1 78 | #define configCPU_CLOCK_HZ ( ( unsigned long ) 72000000 ) 79 | #define configTICK_RATE_HZ ( ( portTickType ) 100 ) 80 | #define configMAX_PRIORITIES ( 5 ) 81 | #define configMINIMAL_STACK_SIZE ( ( unsigned short ) 128 ) 82 | #define configTOTAL_HEAP_SIZE ( ( size_t ) ( 17 * 1024 ) ) 83 | #define configMAX_TASK_NAME_LEN ( 16 ) 84 | #define configUSE_TRACE_FACILITY 0 85 | #define configUSE_16_BIT_TICKS 0 86 | #define configIDLE_SHOULD_YIELD 1 87 | #define configUSE_MUTEXES 1 88 | 89 | /* Co-routine definitions. */ 90 | #define configUSE_CO_ROUTINES 0 91 | #define configMAX_CO_ROUTINE_PRIORITIES ( 2 ) 92 | 93 | /* Set the following definitions to 1 to include the API function, or zero 94 | to exclude the API function. */ 95 | 96 | #define INCLUDE_vTaskPrioritySet 1 97 | #define INCLUDE_uxTaskPriorityGet 1 98 | #define INCLUDE_vTaskDelete 1 99 | #define INCLUDE_vTaskCleanUpResources 0 100 | #define INCLUDE_vTaskSuspend 1 101 | #define INCLUDE_vTaskDelayUntil 1 102 | #define INCLUDE_vTaskDelay 1 103 | 104 | /* This is the raw value as per the Cortex-M3 NVIC. Values can be 255 105 | (lowest) to 0 (1?) (highest). */ 106 | #define configKERNEL_INTERRUPT_PRIORITY 127 //Needs to be below 240 (0xf0) to work with QEMU, since this is the priority mask used 107 | #define configMAX_SYSCALL_INTERRUPT_PRIORITY 191 /* equivalent to 0xb0, or priority 11. */ 108 | 109 | 110 | /* This is the value being used as per the ST library which permits 16 111 | priority values, 0 to 15. This must correspond to the 112 | configKERNEL_INTERRUPT_PRIORITY setting. Here 15 corresponds to the lowest 113 | NVIC value of 255. */ 114 | #define configLIBRARY_KERNEL_INTERRUPT_PRIORITY 15 115 | 116 | #endif /* FREERTOS_CONFIG_H */ 117 | 118 | -------------------------------------------------------------------------------- /demos/freertos_multithread/stm32f10x_conf.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file GPIO/IOToggle/stm32f10x_conf.h 4 | * @author MCD Application Team 5 | * @version V3.3.0 6 | * @date 04/16/2010 7 | * @brief Library configuration file. 8 | ****************************************************************************** 9 | * @copy 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2010 STMicroelectronics

19 | */ 20 | 21 | /* Define to prevent recursive inclusion -------------------------------------*/ 22 | #ifndef __STM32F10x_CONF_H 23 | #define __STM32F10x_CONF_H 24 | 25 | /* Includes ------------------------------------------------------------------*/ 26 | /* Uncomment the line below to enable peripheral header file inclusion */ 27 | /* #include "stm32f10x_adc.h" */ 28 | /* #include "stm32f10x_bkp.h" */ 29 | /* #include "stm32f10x_can.h" */ 30 | /* #include "stm32f10x_cec.h" */ 31 | /* #include "stm32f10x_crc.h" */ 32 | /* #include "stm32f10x_dac.h" */ 33 | /* #include "stm32f10x_dbgmcu.h" */ 34 | /* #include "stm32f10x_dma.h" */ 35 | /* #include "stm32f10x_exti.h" */ 36 | /* #include "stm32f10x_flash.h" */ 37 | /* #include "stm32f10x_fsmc.h" */ 38 | #include "stm32f10x_gpio.h" 39 | /* #include "stm32f10x_i2c.h" */ 40 | /* #include "stm32f10x_iwdg.h" */ 41 | /* #include "stm32f10x_pwr.h" */ 42 | /* #include "stm32f10x_rcc.h" */ 43 | /* #include "stm32f10x_rtc.h" */ 44 | /* #include "stm32f10x_sdio.h" */ 45 | /* #include "stm32f10x_spi.h" */ 46 | /* #include "stm32f10x_tim.h" */ 47 | #include "stm32f10x_usart.h" 48 | /* #include "stm32f10x_wwdg.h" */ 49 | /* #include "misc.h" */ /* High level functions for NVIC and SysTick (add-on to CMSIS functions) */ 50 | 51 | /* Exported types ------------------------------------------------------------*/ 52 | /* Exported constants --------------------------------------------------------*/ 53 | /* Uncomment the line below to expanse the "assert_param" macro in the 54 | Standard Peripheral Library drivers code */ 55 | /* #define USE_FULL_ASSERT 1 */ 56 | 57 | /* Exported macro ------------------------------------------------------------*/ 58 | #ifdef USE_FULL_ASSERT 59 | 60 | /** 61 | * @brief The assert_param macro is used for function's parameters check. 62 | * @param expr: If expr is false, it calls assert_failed function 63 | * which reports the name of the source file and the source 64 | * line number of the call that failed. 65 | * If expr is true, it returns no value. 66 | * @retval None 67 | */ 68 | #define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__)) 69 | /* Exported functions ------------------------------------------------------- */ 70 | void assert_failed(uint8_t* file, uint32_t line); 71 | #else 72 | #define assert_param(expr) ((void)0) 73 | #endif /* USE_FULL_ASSERT */ 74 | 75 | #endif /* __STM32F10x_CONF_H */ 76 | 77 | /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/ 78 | -------------------------------------------------------------------------------- /demos/freertos_semaphore1/FreeRTOSConfig.h: -------------------------------------------------------------------------------- 1 | /* 2 | FreeRTOS V6.0.5 - Copyright (C) 2010 Real Time Engineers Ltd. 3 | 4 | *************************************************************************** 5 | * * 6 | * If you are: * 7 | * * 8 | * + New to FreeRTOS, * 9 | * + Wanting to learn FreeRTOS or multitasking in general quickly * 10 | * + Looking for basic training, * 11 | * + Wanting to improve your FreeRTOS skills and productivity * 12 | * * 13 | * then take a look at the FreeRTOS eBook * 14 | * * 15 | * "Using the FreeRTOS Real Time Kernel - a Practical Guide" * 16 | * http://www.FreeRTOS.org/Documentation * 17 | * * 18 | * A pdf reference manual is also available. Both are usually delivered * 19 | * to your inbox within 20 minutes to two hours when purchased between 8am * 20 | * and 8pm GMT (although please allow up to 24 hours in case of * 21 | * exceptional circumstances). Thank you for your support! * 22 | * * 23 | *************************************************************************** 24 | 25 | This file is part of the FreeRTOS distribution. 26 | 27 | FreeRTOS is free software; you can redistribute it and/or modify it under 28 | the terms of the GNU General Public License (version 2) as published by the 29 | Free Software Foundation AND MODIFIED BY the FreeRTOS exception. 30 | ***NOTE*** The exception to the GPL is included to allow you to distribute 31 | a combined work that includes FreeRTOS without being obliged to provide the 32 | source code for proprietary components outside of the FreeRTOS kernel. 33 | FreeRTOS is distributed in the hope that it will be useful, but WITHOUT 34 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 35 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 36 | more details. You should have received a copy of the GNU General Public 37 | License and the FreeRTOS license exception along with FreeRTOS; if not it 38 | can be viewed here: http://www.freertos.org/a00114.html and also obtained 39 | by writing to Richard Barry, contact details for whom are available on the 40 | FreeRTOS WEB site. 41 | 42 | 1 tab == 4 spaces! 43 | 44 | http://www.FreeRTOS.org - Documentation, latest information, license and 45 | contact details. 46 | 47 | http://www.SafeRTOS.com - A version that is certified for use in safety 48 | critical systems. 49 | 50 | http://www.OpenRTOS.com - Commercial support, development, porting, 51 | licensing and training services. 52 | */ 53 | 54 | #ifndef FREERTOS_CONFIG_H 55 | #define FREERTOS_CONFIG_H 56 | 57 | #define xPortPendSVHandler PendSV_Handler 58 | #define xPortSysTickHandler SysTick_Handler 59 | #define vPortSVCHandler SVC_Handler 60 | 61 | 62 | #define pdFALSE ( ( BaseType_t ) 0 ) 63 | #define pdTRUE ( ( BaseType_t ) 1 ) 64 | 65 | /*----------------------------------------------------------- 66 | * Application specific definitions. 67 | * 68 | * These definitions should be adjusted for your particular hardware and 69 | * application requirements. 70 | * 71 | * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE 72 | * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE. 73 | * 74 | * See http://www.freertos.org/a00110.html. 75 | *----------------------------------------------------------*/ 76 | 77 | #define configUSE_PREEMPTION 1 78 | #define configUSE_IDLE_HOOK 0 79 | #define configUSE_TICK_HOOK 1 80 | #define configCPU_CLOCK_HZ ( ( unsigned long ) 72000000 ) 81 | #define configTICK_RATE_HZ ( ( portTickType ) 100 ) 82 | #define configMAX_PRIORITIES ( 5 ) 83 | #define configMINIMAL_STACK_SIZE ( ( unsigned short ) 128 ) 84 | #define configTOTAL_HEAP_SIZE ( ( size_t ) ( 17 * 1024 ) ) 85 | #define configMAX_TASK_NAME_LEN ( 16 ) 86 | #define configUSE_TRACE_FACILITY 0 87 | #define configUSE_16_BIT_TICKS 0 88 | #define configIDLE_SHOULD_YIELD 1 89 | #define configUSE_MUTEXES 1 90 | 91 | /* Co-routine definitions. */ 92 | #define configUSE_CO_ROUTINES 0 93 | #define configMAX_CO_ROUTINE_PRIORITIES ( 2 ) 94 | 95 | /* Set the following definitions to 1 to include the API function, or zero 96 | to exclude the API function. */ 97 | 98 | #define INCLUDE_vTaskPrioritySet 1 99 | #define INCLUDE_uxTaskPriorityGet 1 100 | #define INCLUDE_vTaskDelete 1 101 | //#define INCLUDE_vTaskCleanUpResources 0 102 | #define INCLUDE_vTaskSuspend 1 103 | #define INCLUDE_vTaskDelayUntil 1 104 | #define INCLUDE_vTaskDelay 1 105 | 106 | /* This is the raw value as per the Cortex-M3 NVIC. Values can be 255 107 | (lowest) to 0 (1?) (highest). */ 108 | #define configKERNEL_INTERRUPT_PRIORITY 127 //Needs to be below 240 (0xf0) to work with QEMU, since this is the priority mask used 109 | #define configMAX_SYSCALL_INTERRUPT_PRIORITY 191 /* equivalent to 0xb0, or priority 11. */ 110 | 111 | 112 | /* This is the value being used as per the ST library which permits 16 113 | priority values, 0 to 15. This must correspond to the 114 | configKERNEL_INTERRUPT_PRIORITY setting. Here 15 corresponds to the lowest 115 | NVIC value of 255. */ 116 | #define configLIBRARY_KERNEL_INTERRUPT_PRIORITY 15 117 | 118 | #endif /* FREERTOS_CONFIG_H */ 119 | 120 | -------------------------------------------------------------------------------- /demos/freertos_semaphore1/main.c: -------------------------------------------------------------------------------- 1 | #define USE_STDPERIPH_DRIVER 2 | #include "stm32_p103.h" 3 | 4 | /* Scheduler includes. */ 5 | #include "FreeRTOS.h" 6 | #include "task.h" 7 | #include "queue.h" 8 | #include "semphr.h" 9 | #include 10 | #include "myprintk.h" 11 | 12 | 13 | SemaphoreHandle_t bin_sem_1; 14 | 15 | void give_task(void* param) 16 | { 17 | while(1){ 18 | xSemaphoreGive(bin_sem_1); 19 | myprintf("TASK1 give \n"); 20 | vTaskDelay(300); 21 | } 22 | } 23 | 24 | void take_task(void* param) 25 | { 26 | while(1){ 27 | if ( xSemaphoreTake(bin_sem_1,20)){ 28 | myprintf("TASK2 get bin_sem_1 \n"); 29 | } 30 | else{ 31 | myprintf("TASK2 not get bin_sem_1\n"); 32 | } 33 | vTaskDelay(100); 34 | } 35 | } 36 | 37 | int main(void) 38 | { 39 | myprintf_init(); 40 | 41 | bin_sem_1 = xSemaphoreCreateBinary(); 42 | xSemaphoreGive(bin_sem_1); 43 | 44 | xTaskCreate(give_task, ( signed portCHAR * ) "V", 512/* stack size */, NULL, tskIDLE_PRIORITY + 10, NULL ); 45 | xTaskCreate(take_task, ( signed portCHAR * ) "P", 512/* stack size */, NULL, tskIDLE_PRIORITY + 10, NULL ); 46 | 47 | /* Start running the tasks. */ 48 | vTaskStartScheduler(); 49 | 50 | return 0; 51 | } 52 | 53 | void vApplicationTickHook( void ) 54 | { 55 | } 56 | -------------------------------------------------------------------------------- /demos/freertos_semaphore1/stm32f10x_conf.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file GPIO/IOToggle/stm32f10x_conf.h 4 | * @author MCD Application Team 5 | * @version V3.3.0 6 | * @date 04/16/2010 7 | * @brief Library configuration file. 8 | ****************************************************************************** 9 | * @copy 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2010 STMicroelectronics

19 | */ 20 | 21 | /* Define to prevent recursive inclusion -------------------------------------*/ 22 | #ifndef __STM32F10x_CONF_H 23 | #define __STM32F10x_CONF_H 24 | 25 | /* Includes ------------------------------------------------------------------*/ 26 | /* Uncomment the line below to enable peripheral header file inclusion */ 27 | /* #include "stm32f10x_adc.h" */ 28 | /* #include "stm32f10x_bkp.h" */ 29 | /* #include "stm32f10x_can.h" */ 30 | /* #include "stm32f10x_cec.h" */ 31 | /* #include "stm32f10x_crc.h" */ 32 | /* #include "stm32f10x_dac.h" */ 33 | /* #include "stm32f10x_dbgmcu.h" */ 34 | /* #include "stm32f10x_dma.h" */ 35 | /* #include "stm32f10x_exti.h" */ 36 | /* #include "stm32f10x_flash.h" */ 37 | /* #include "stm32f10x_fsmc.h" */ 38 | #include "stm32f10x_gpio.h" 39 | /* #include "stm32f10x_i2c.h" */ 40 | /* #include "stm32f10x_iwdg.h" */ 41 | /* #include "stm32f10x_pwr.h" */ 42 | /* #include "stm32f10x_rcc.h" */ 43 | /* #include "stm32f10x_rtc.h" */ 44 | /* #include "stm32f10x_sdio.h" */ 45 | /* #include "stm32f10x_spi.h" */ 46 | /* #include "stm32f10x_tim.h" */ 47 | #include "stm32f10x_usart.h" 48 | /* #include "stm32f10x_wwdg.h" */ 49 | /* #include "misc.h" */ /* High level functions for NVIC and SysTick (add-on to CMSIS functions) */ 50 | 51 | /* Exported types ------------------------------------------------------------*/ 52 | /* Exported constants --------------------------------------------------------*/ 53 | /* Uncomment the line below to expanse the "assert_param" macro in the 54 | Standard Peripheral Library drivers code */ 55 | /* #define USE_FULL_ASSERT 1 */ 56 | 57 | /* Exported macro ------------------------------------------------------------*/ 58 | #ifdef USE_FULL_ASSERT 59 | 60 | /** 61 | * @brief The assert_param macro is used for function's parameters check. 62 | * @param expr: If expr is false, it calls assert_failed function 63 | * which reports the name of the source file and the source 64 | * line number of the call that failed. 65 | * If expr is true, it returns no value. 66 | * @retval None 67 | */ 68 | #define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__)) 69 | /* Exported functions ------------------------------------------------------- */ 70 | void assert_failed(uint8_t* file, uint32_t line); 71 | #else 72 | #define assert_param(expr) ((void)0) 73 | #endif /* USE_FULL_ASSERT */ 74 | 75 | #endif /* __STM32F10x_CONF_H */ 76 | 77 | /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/ 78 | -------------------------------------------------------------------------------- /demos/freertos_singlethread/FreeRTOSConfig.h: -------------------------------------------------------------------------------- 1 | /* 2 | FreeRTOS V6.0.5 - Copyright (C) 2010 Real Time Engineers Ltd. 3 | 4 | *************************************************************************** 5 | * * 6 | * If you are: * 7 | * * 8 | * + New to FreeRTOS, * 9 | * + Wanting to learn FreeRTOS or multitasking in general quickly * 10 | * + Looking for basic training, * 11 | * + Wanting to improve your FreeRTOS skills and productivity * 12 | * * 13 | * then take a look at the FreeRTOS eBook * 14 | * * 15 | * "Using the FreeRTOS Real Time Kernel - a Practical Guide" * 16 | * http://www.FreeRTOS.org/Documentation * 17 | * * 18 | * A pdf reference manual is also available. Both are usually delivered * 19 | * to your inbox within 20 minutes to two hours when purchased between 8am * 20 | * and 8pm GMT (although please allow up to 24 hours in case of * 21 | * exceptional circumstances). Thank you for your support! * 22 | * * 23 | *************************************************************************** 24 | 25 | This file is part of the FreeRTOS distribution. 26 | 27 | FreeRTOS is free software; you can redistribute it and/or modify it under 28 | the terms of the GNU General Public License (version 2) as published by the 29 | Free Software Foundation AND MODIFIED BY the FreeRTOS exception. 30 | ***NOTE*** The exception to the GPL is included to allow you to distribute 31 | a combined work that includes FreeRTOS without being obliged to provide the 32 | source code for proprietary components outside of the FreeRTOS kernel. 33 | FreeRTOS is distributed in the hope that it will be useful, but WITHOUT 34 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 35 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 36 | more details. You should have received a copy of the GNU General Public 37 | License and the FreeRTOS license exception along with FreeRTOS; if not it 38 | can be viewed here: http://www.freertos.org/a00114.html and also obtained 39 | by writing to Richard Barry, contact details for whom are available on the 40 | FreeRTOS WEB site. 41 | 42 | 1 tab == 4 spaces! 43 | 44 | http://www.FreeRTOS.org - Documentation, latest information, license and 45 | contact details. 46 | 47 | http://www.SafeRTOS.com - A version that is certified for use in safety 48 | critical systems. 49 | 50 | http://www.OpenRTOS.com - Commercial support, development, porting, 51 | licensing and training services. 52 | */ 53 | 54 | #ifndef FREERTOS_CONFIG_H 55 | #define FREERTOS_CONFIG_H 56 | 57 | #define xPortPendSVHandler PendSV_Handler 58 | #define xPortSysTickHandler SysTick_Handler 59 | #define vPortSVCHandler SVC_Handler 60 | 61 | 62 | 63 | /*----------------------------------------------------------- 64 | * Application specific definitions. 65 | * 66 | * These definitions should be adjusted for your particular hardware and 67 | * application requirements. 68 | * 69 | * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE 70 | * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE. 71 | * 72 | * See http://www.freertos.org/a00110.html. 73 | *----------------------------------------------------------*/ 74 | 75 | #define configUSE_PREEMPTION 1 76 | #define configUSE_IDLE_HOOK 0 77 | #define configUSE_TICK_HOOK 1 78 | #define configCPU_CLOCK_HZ ( ( unsigned long ) 72000000 ) 79 | #define configTICK_RATE_HZ ( ( portTickType ) 100 ) 80 | #define configMAX_PRIORITIES ( 5 ) 81 | #define configMINIMAL_STACK_SIZE ( ( unsigned short ) 128 ) 82 | #define configTOTAL_HEAP_SIZE ( ( size_t ) ( 17 * 1024 ) ) 83 | #define configMAX_TASK_NAME_LEN ( 16 ) 84 | #define configUSE_TRACE_FACILITY 0 85 | #define configUSE_16_BIT_TICKS 0 86 | #define configIDLE_SHOULD_YIELD 1 87 | #define configUSE_MUTEXES 1 88 | 89 | /* Co-routine definitions. */ 90 | #define configUSE_CO_ROUTINES 0 91 | #define configMAX_CO_ROUTINE_PRIORITIES ( 2 ) 92 | 93 | /* Set the following definitions to 1 to include the API function, or zero 94 | to exclude the API function. */ 95 | 96 | #define INCLUDE_vTaskPrioritySet 1 97 | #define INCLUDE_uxTaskPriorityGet 1 98 | #define INCLUDE_vTaskDelete 1 99 | #define INCLUDE_vTaskCleanUpResources 0 100 | #define INCLUDE_vTaskSuspend 1 101 | #define INCLUDE_vTaskDelayUntil 1 102 | #define INCLUDE_vTaskDelay 1 103 | 104 | /* This is the raw value as per the Cortex-M3 NVIC. Values can be 255 105 | (lowest) to 0 (1?) (highest). */ 106 | #define configKERNEL_INTERRUPT_PRIORITY 127 //Needs to be below 240 (0xf0) to work with QEMU, since this is the priority mask used 107 | #define configMAX_SYSCALL_INTERRUPT_PRIORITY 191 /* equivalent to 0xb0, or priority 11. */ 108 | 109 | 110 | /* This is the value being used as per the ST library which permits 16 111 | priority values, 0 to 15. This must correspond to the 112 | configKERNEL_INTERRUPT_PRIORITY setting. Here 15 corresponds to the lowest 113 | NVIC value of 255. */ 114 | #define configLIBRARY_KERNEL_INTERRUPT_PRIORITY 15 115 | 116 | #endif /* FREERTOS_CONFIG_H */ 117 | 118 | -------------------------------------------------------------------------------- /demos/freertos_singlethread/main.c: -------------------------------------------------------------------------------- 1 | #define USE_STDPERIPH_DRIVER 2 | #include "stm32_p103.h" 3 | 4 | /* Scheduler includes. */ 5 | #include "FreeRTOS.h" 6 | #include "task.h" 7 | #include "queue.h" 8 | #include "semphr.h" 9 | 10 | static void setup_hardware( void ); 11 | 12 | void led_flash_task( void *pvParameters ) 13 | { 14 | while(1) { 15 | /* Toggle the LED. */ 16 | GPIOC->ODR = GPIOC->ODR ^ 0x00001000; 17 | 18 | /* Wait one second. */ 19 | vTaskDelay(100); 20 | } 21 | } 22 | 23 | 24 | int main(void) 25 | { 26 | init_led(); 27 | 28 | xTaskCreate( led_flash_task, ( signed portCHAR * ) "LED Flash", 512 /* stack size */, NULL, tskIDLE_PRIORITY + 5, NULL ); 29 | 30 | /* Start running the task. */ 31 | vTaskStartScheduler(); 32 | 33 | return 0; 34 | } 35 | 36 | void vApplicationTickHook( void ) 37 | { 38 | } 39 | -------------------------------------------------------------------------------- /demos/freertos_singlethread/stm32f10x_conf.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file GPIO/IOToggle/stm32f10x_conf.h 4 | * @author MCD Application Team 5 | * @version V3.3.0 6 | * @date 04/16/2010 7 | * @brief Library configuration file. 8 | ****************************************************************************** 9 | * @copy 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2010 STMicroelectronics

19 | */ 20 | 21 | /* Define to prevent recursive inclusion -------------------------------------*/ 22 | #ifndef __STM32F10x_CONF_H 23 | #define __STM32F10x_CONF_H 24 | 25 | /* Includes ------------------------------------------------------------------*/ 26 | /* Uncomment the line below to enable peripheral header file inclusion */ 27 | /* #include "stm32f10x_adc.h" */ 28 | /* #include "stm32f10x_bkp.h" */ 29 | /* #include "stm32f10x_can.h" */ 30 | /* #include "stm32f10x_cec.h" */ 31 | /* #include "stm32f10x_crc.h" */ 32 | /* #include "stm32f10x_dac.h" */ 33 | /* #include "stm32f10x_dbgmcu.h" */ 34 | /* #include "stm32f10x_dma.h" */ 35 | /* #include "stm32f10x_exti.h" */ 36 | /* #include "stm32f10x_flash.h" */ 37 | /* #include "stm32f10x_fsmc.h" */ 38 | #include "stm32f10x_gpio.h" 39 | /* #include "stm32f10x_i2c.h" */ 40 | /* #include "stm32f10x_iwdg.h" */ 41 | /* #include "stm32f10x_pwr.h" */ 42 | /* #include "stm32f10x_rcc.h" */ 43 | /* #include "stm32f10x_rtc.h" */ 44 | /* #include "stm32f10x_sdio.h" */ 45 | /* #include "stm32f10x_spi.h" */ 46 | /* #include "stm32f10x_tim.h" */ 47 | /* #include "stm32f10x_usart.h" */ 48 | /* #include "stm32f10x_wwdg.h" */ 49 | /* #include "misc.h" */ /* High level functions for NVIC and SysTick (add-on to CMSIS functions) */ 50 | 51 | /* Exported types ------------------------------------------------------------*/ 52 | /* Exported constants --------------------------------------------------------*/ 53 | /* Uncomment the line below to expanse the "assert_param" macro in the 54 | Standard Peripheral Library drivers code */ 55 | /* #define USE_FULL_ASSERT 1 */ 56 | 57 | /* Exported macro ------------------------------------------------------------*/ 58 | #ifdef USE_FULL_ASSERT 59 | 60 | /** 61 | * @brief The assert_param macro is used for function's parameters check. 62 | * @param expr: If expr is false, it calls assert_failed function 63 | * which reports the name of the source file and the source 64 | * line number of the call that failed. 65 | * If expr is true, it returns no value. 66 | * @retval None 67 | */ 68 | #define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__)) 69 | /* Exported functions ------------------------------------------------------- */ 70 | void assert_failed(uint8_t* file, uint32_t line); 71 | #else 72 | #define assert_param(expr) ((void)0) 73 | #endif /* USE_FULL_ASSERT */ 74 | 75 | #endif /* __STM32F10x_CONF_H */ 76 | 77 | /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/ 78 | -------------------------------------------------------------------------------- /demos/freertos_streambuffer/FreeRTOSConfig.h: -------------------------------------------------------------------------------- 1 | /* 2 | FreeRTOS V6.0.5 - Copyright (C) 2010 Real Time Engineers Ltd. 3 | 4 | *************************************************************************** 5 | * * 6 | * If you are: * 7 | * * 8 | * + New to FreeRTOS, * 9 | * + Wanting to learn FreeRTOS or multitasking in general quickly * 10 | * + Looking for basic training, * 11 | * + Wanting to improve your FreeRTOS skills and productivity * 12 | * * 13 | * then take a look at the FreeRTOS eBook * 14 | * * 15 | * "Using the FreeRTOS Real Time Kernel - a Practical Guide" * 16 | * http://www.FreeRTOS.org/Documentation * 17 | * * 18 | * A pdf reference manual is also available. Both are usually delivered * 19 | * to your inbox within 20 minutes to two hours when purchased between 8am * 20 | * and 8pm GMT (although please allow up to 24 hours in case of * 21 | * exceptional circumstances). Thank you for your support! * 22 | * * 23 | *************************************************************************** 24 | 25 | This file is part of the FreeRTOS distribution. 26 | 27 | FreeRTOS is free software; you can redistribute it and/or modify it under 28 | the terms of the GNU General Public License (version 2) as published by the 29 | Free Software Foundation AND MODIFIED BY the FreeRTOS exception. 30 | ***NOTE*** The exception to the GPL is included to allow you to distribute 31 | a combined work that includes FreeRTOS without being obliged to provide the 32 | source code for proprietary components outside of the FreeRTOS kernel. 33 | FreeRTOS is distributed in the hope that it will be useful, but WITHOUT 34 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 35 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 36 | more details. You should have received a copy of the GNU General Public 37 | License and the FreeRTOS license exception along with FreeRTOS; if not it 38 | can be viewed here: http://www.freertos.org/a00114.html and also obtained 39 | by writing to Richard Barry, contact details for whom are available on the 40 | FreeRTOS WEB site. 41 | 42 | 1 tab == 4 spaces! 43 | 44 | http://www.FreeRTOS.org - Documentation, latest information, license and 45 | contact details. 46 | 47 | http://www.SafeRTOS.com - A version that is certified for use in safety 48 | critical systems. 49 | 50 | http://www.OpenRTOS.com - Commercial support, development, porting, 51 | licensing and training services. 52 | */ 53 | 54 | #ifndef FREERTOS_CONFIG_H 55 | #define FREERTOS_CONFIG_H 56 | 57 | #define xPortPendSVHandler PendSV_Handler 58 | #define xPortSysTickHandler SysTick_Handler 59 | #define vPortSVCHandler SVC_Handler 60 | 61 | 62 | #define pdFALSE ( ( BaseType_t ) 0 ) 63 | #define pdTRUE ( ( BaseType_t ) 1 ) 64 | 65 | /*----------------------------------------------------------- 66 | * Application specific definitions. 67 | * 68 | * These definitions should be adjusted for your particular hardware and 69 | * application requirements. 70 | * 71 | * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE 72 | * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE. 73 | * 74 | * See http://www.freertos.org/a00110.html. 75 | *----------------------------------------------------------*/ 76 | 77 | #define configUSE_PREEMPTION 1 78 | #define configUSE_IDLE_HOOK 0 79 | #define configUSE_TICK_HOOK 1 80 | #define configCPU_CLOCK_HZ ( ( unsigned long ) 72000000 ) 81 | #define configTICK_RATE_HZ ( ( portTickType ) 100 ) 82 | #define configMAX_PRIORITIES ( 5 ) 83 | #define configMINIMAL_STACK_SIZE ( ( unsigned short ) 128 ) 84 | #define configTOTAL_HEAP_SIZE ( ( size_t ) ( 17 * 1024 ) ) 85 | #define configMAX_TASK_NAME_LEN ( 16 ) 86 | #define configUSE_TRACE_FACILITY 0 87 | #define configUSE_16_BIT_TICKS 0 88 | #define configIDLE_SHOULD_YIELD 1 89 | #define configUSE_MUTEXES 1 90 | 91 | /* Co-routine definitions. */ 92 | #define configUSE_CO_ROUTINES 0 93 | #define configMAX_CO_ROUTINE_PRIORITIES ( 2 ) 94 | 95 | /* Set the following definitions to 1 to include the API function, or zero 96 | to exclude the API function. */ 97 | 98 | #define INCLUDE_vTaskPrioritySet 1 99 | #define INCLUDE_uxTaskPriorityGet 1 100 | #define INCLUDE_vTaskDelete 1 101 | //#define INCLUDE_vTaskCleanUpResources 0 102 | #define INCLUDE_vTaskSuspend 1 103 | #define INCLUDE_vTaskDelayUntil 1 104 | #define INCLUDE_vTaskDelay 1 105 | 106 | /* This is the raw value as per the Cortex-M3 NVIC. Values can be 255 107 | (lowest) to 0 (1?) (highest). */ 108 | #define configKERNEL_INTERRUPT_PRIORITY 127 //Needs to be below 240 (0xf0) to work with QEMU, since this is the priority mask used 109 | #define configMAX_SYSCALL_INTERRUPT_PRIORITY 191 /* equivalent to 0xb0, or priority 11. */ 110 | 111 | 112 | /* This is the value being used as per the ST library which permits 16 113 | priority values, 0 to 15. This must correspond to the 114 | configKERNEL_INTERRUPT_PRIORITY setting. Here 15 corresponds to the lowest 115 | NVIC value of 255. */ 116 | #define configLIBRARY_KERNEL_INTERRUPT_PRIORITY 15 117 | 118 | #endif /* FREERTOS_CONFIG_H */ 119 | 120 | -------------------------------------------------------------------------------- /demos/freertos_streambuffer/stm32f10x_conf.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file GPIO/IOToggle/stm32f10x_conf.h 4 | * @author MCD Application Team 5 | * @version V3.3.0 6 | * @date 04/16/2010 7 | * @brief Library configuration file. 8 | ****************************************************************************** 9 | * @copy 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2010 STMicroelectronics

19 | */ 20 | 21 | /* Define to prevent recursive inclusion -------------------------------------*/ 22 | #ifndef __STM32F10x_CONF_H 23 | #define __STM32F10x_CONF_H 24 | 25 | /* Includes ------------------------------------------------------------------*/ 26 | /* Uncomment the line below to enable peripheral header file inclusion */ 27 | /* #include "stm32f10x_adc.h" */ 28 | /* #include "stm32f10x_bkp.h" */ 29 | /* #include "stm32f10x_can.h" */ 30 | /* #include "stm32f10x_cec.h" */ 31 | /* #include "stm32f10x_crc.h" */ 32 | /* #include "stm32f10x_dac.h" */ 33 | /* #include "stm32f10x_dbgmcu.h" */ 34 | /* #include "stm32f10x_dma.h" */ 35 | /* #include "stm32f10x_exti.h" */ 36 | /* #include "stm32f10x_flash.h" */ 37 | /* #include "stm32f10x_fsmc.h" */ 38 | #include "stm32f10x_gpio.h" 39 | /* #include "stm32f10x_i2c.h" */ 40 | /* #include "stm32f10x_iwdg.h" */ 41 | /* #include "stm32f10x_pwr.h" */ 42 | /* #include "stm32f10x_rcc.h" */ 43 | /* #include "stm32f10x_rtc.h" */ 44 | /* #include "stm32f10x_sdio.h" */ 45 | /* #include "stm32f10x_spi.h" */ 46 | /* #include "stm32f10x_tim.h" */ 47 | #include "stm32f10x_usart.h" 48 | /* #include "stm32f10x_wwdg.h" */ 49 | /* #include "misc.h" */ /* High level functions for NVIC and SysTick (add-on to CMSIS functions) */ 50 | 51 | /* Exported types ------------------------------------------------------------*/ 52 | /* Exported constants --------------------------------------------------------*/ 53 | /* Uncomment the line below to expanse the "assert_param" macro in the 54 | Standard Peripheral Library drivers code */ 55 | /* #define USE_FULL_ASSERT 1 */ 56 | 57 | /* Exported macro ------------------------------------------------------------*/ 58 | #ifdef USE_FULL_ASSERT 59 | 60 | /** 61 | * @brief The assert_param macro is used for function's parameters check. 62 | * @param expr: If expr is false, it calls assert_failed function 63 | * which reports the name of the source file and the source 64 | * line number of the call that failed. 65 | * If expr is true, it returns no value. 66 | * @retval None 67 | */ 68 | #define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__)) 69 | /* Exported functions ------------------------------------------------------- */ 70 | void assert_failed(uint8_t* file, uint32_t line); 71 | #else 72 | #define assert_param(expr) ((void)0) 73 | #endif /* USE_FULL_ASSERT */ 74 | 75 | #endif /* __STM32F10x_CONF_H */ 76 | 77 | /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/ 78 | -------------------------------------------------------------------------------- /demos/main.ld: -------------------------------------------------------------------------------- 1 | ENTRY(main) 2 | MEMORY 3 | { 4 | FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 128K 5 | RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 20K 6 | 7 | } 8 | 9 | SECTIONS 10 | { 11 | .text : 12 | { 13 | KEEP(*(.isr_vector)) 14 | *(.text) 15 | *(.text.*) 16 | *(.rodata) 17 | *(.rodata.*) 18 | _sidata = .; 19 | } >FLASH 20 | 21 | /* Initialized data will initially be loaded in FLASH at the end of the .text section. */ 22 | .data : AT (_sidata) 23 | { 24 | _sdata = .; 25 | *(.data) /* Initialized data */ 26 | _edata = .; 27 | } >RAM 28 | 29 | .bss : { 30 | _sbss = .; 31 | *(.bss) /* Zero-filled run time allocate data memory */ 32 | _ebss = .; 33 | } >RAM 34 | 35 | _estack = ORIGIN(RAM) + LENGTH(RAM); 36 | } -------------------------------------------------------------------------------- /demos/printf_demo/main.c: -------------------------------------------------------------------------------- 1 | #define USE_STDPERIPH_DRIVER 2 | #include "stm32_p103.h" 3 | #include "myprintk.h" 4 | 5 | void sleep() 6 | { 7 | int i=1000000; 8 | while(i-->0); 9 | } 10 | 11 | int main(void) 12 | { 13 | uint8_t b; 14 | int32_t num1=0x1234; 15 | char *str1="Strings"; 16 | char ch1='Z'; 17 | 18 | //first init myprintf device(usart2) 19 | myprintf_init(); 20 | while(1) { 21 | myprintf("test num %d=0x%x str %s ch %c\n",num1,num1,str1,ch1); 22 | sleep(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /demos/printf_demo/stm32f10x_conf.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file USART/HalfDuplex/stm32f10x_conf.h 4 | * @author MCD Application Team 5 | * @version V3.3.0 6 | * @date 04/16/2010 7 | * @brief Library configuration file. 8 | ****************************************************************************** 9 | * @copy 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2010 STMicroelectronics

19 | */ 20 | 21 | /* Define to prevent recursive inclusion -------------------------------------*/ 22 | #ifndef __STM32F10x_CONF_H 23 | #define __STM32F10x_CONF_H 24 | 25 | //#define HSI_VALUE ((uint32_t)40000) 26 | //#define HSI_Value ((uint32_t)40000) 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | /* Uncomment the line below to enable peripheral header file inclusion */ 30 | /* #include "stm32f10x_adc.h" */ 31 | /* #include "stm32f10x_bkp.h" */ 32 | /* #include "stm32f10x_can.h" */ 33 | /* #include "stm32f10x_cec.h" */ 34 | /* #include "stm32f10x_crc.h" */ 35 | /* #include "stm32f10x_dac.h" */ 36 | /* #include "stm32f10x_dbgmcu.h" */ 37 | /* #include "stm32f10x_dma.h" */ 38 | /* #include "stm32f10x_exti.h" */ 39 | /* #include "stm32f10x_flash.h" */ 40 | /* #include "stm32f10x_fsmc.h" */ 41 | /* #include "stm32f10x_gpio.h" */ 42 | /* #include "stm32f10x_i2c.h" */ 43 | /* #include "stm32f10x_iwdg.h" */ 44 | /* #include "stm32f10x_pwr.h" */ 45 | /* #include "stm32f10x_rcc.h" */ 46 | /* #include "stm32f10x_rtc.h" */ 47 | /* #include "stm32f10x_sdio.h" */ 48 | /* #include "stm32f10x_spi.h" */ 49 | /* #include "stm32f10x_tim.h" */ 50 | #include "stm32f10x_usart.h" 51 | /* #include "stm32f10x_wwdg.h" */ 52 | /* #include "misc.h" */ /* High level functions for NVIC and SysTick (add-on to CMSIS functions) */ 53 | 54 | /* Exported types ------------------------------------------------------------*/ 55 | /* Exported constants --------------------------------------------------------*/ 56 | /* Uncomment the line below to expanse the "assert_param" macro in the 57 | Standard Peripheral Library drivers code */ 58 | /* #define USE_FULL_ASSERT 1 */ 59 | 60 | /* Exported macro ------------------------------------------------------------*/ 61 | #ifdef USE_FULL_ASSERT 62 | /** 63 | * @brief The assert_param macro is used for function's parameters check. 64 | * @param expr: If expr is false, it calls assert_failed function 65 | * which reports the name of the source file and the source 66 | * line number of the call that failed. 67 | * If expr is true, it returns no value. 68 | * @retval None 69 | */ 70 | #define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__)) 71 | /* Exported functions ------------------------------------------------------- */ 72 | void assert_failed(uint8_t* file, uint32_t line); 73 | #else 74 | #define assert_param(expr) ((void)0) 75 | #endif /* USE_FULL_ASSERT */ 76 | 77 | #endif /* __STM32F10x_CONF_H */ 78 | 79 | /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/ 80 | -------------------------------------------------------------------------------- /demos/qemu_test/main.c: -------------------------------------------------------------------------------- 1 | #define USE_STDPERIPH_DRIVER 2 | #include "stm32_p103.h" 3 | 4 | #define SHPR_BYTE_COUNT 12 5 | 6 | /* Writes words into the specified register. Each byte is filled with a 7 | * different number. 8 | * addr - Start address of the register. 9 | * size - Size of the register in bytes. 10 | * /inrement_seq - 11 | * Define the value sequence to be used. The first byte will be 12 | * set to , the second byte will be 13 | * set to + increment_seq, and so on. 14 | */ 15 | void test_word_write(volatile uint32_t *addr, unsigned size, 16 | uint8_t start_seq, uint8_t increment_seq) 17 | { 18 | int offset; 19 | uint8_t curr_seq; 20 | uint32_t register_value; 21 | 22 | curr_seq = start_seq; 23 | for(offset = 0; offset < (size / 4); offset ++) { 24 | register_value = 25 | curr_seq | 26 | ((curr_seq + increment_seq) << 8) | 27 | ((curr_seq + (increment_seq * 2)) << 16) | 28 | ((curr_seq + (increment_seq * 3)) << 24); 29 | addr[offset] = register_value; 30 | curr_seq += increment_seq * 4; 31 | } 32 | } 33 | 34 | /* Reads words from the specified register. Note that the values are not 35 | * printed out. They must be verified using a debugger. 36 | * addr - Start address of the register. 37 | * size - Size of the register in bytes. 38 | */ 39 | void test_word_read(volatile uint32_t *addr, unsigned size) 40 | { 41 | int offset; 42 | uint32_t register_value; 43 | 44 | for(offset = 0; offset < (size / 4); offset ++) { 45 | register_value = addr[offset]; 46 | } 47 | } 48 | 49 | /* See test_word_write. */ 50 | void test_hword_write(volatile uint16_t *addr, unsigned size, 51 | uint8_t start_seq, uint8_t increment_seq) 52 | { 53 | int offset; 54 | uint8_t curr_seq; 55 | uint16_t register_value; 56 | 57 | curr_seq = start_seq; 58 | for(offset = 0; offset < (size / 2); offset ++) { 59 | register_value = 60 | curr_seq | 61 | ((curr_seq + increment_seq) << 8); 62 | addr[offset] = register_value; 63 | curr_seq += increment_seq * 2; 64 | } 65 | } 66 | 67 | /* See test_word_read. */ 68 | void test_hword_read(volatile uint16_t *addr, unsigned size) 69 | { 70 | int offset; 71 | uint16_t register_value; 72 | 73 | for(offset = 0; offset < (size / 2); offset ++) { 74 | register_value = addr[offset]; 75 | } 76 | } 77 | 78 | /* See test_word_write. */ 79 | void test_byte_write(volatile uint8_t *addr, unsigned size, 80 | uint8_t start_seq, uint8_t increment_seq) 81 | { 82 | int offset; 83 | uint8_t curr_seq; 84 | 85 | curr_seq = start_seq; 86 | for(offset = 0; offset < size; offset ++) { 87 | addr[offset] = curr_seq; 88 | curr_seq += increment_seq; 89 | } 90 | } 91 | 92 | /* See test_word_read. */ 93 | void test_byte_read(volatile uint8_t *addr, unsigned size) 94 | { 95 | int offset; 96 | uint8_t register_value; 97 | 98 | for(offset = 0; offset < size; offset ++) { 99 | register_value = addr[offset]; 100 | } 101 | } 102 | 103 | int main(void) 104 | { 105 | uint32_t *vtor_reg = (uint32_t *)0xE000ED08; 106 | uint32_t vtor = vtor_reg[0]; 107 | 108 | // /* Note that the SHPR (System Handler Priority Registers) only hold a 4 bit 109 | // * priority, which are stored in the upper 4 bits of each byte. The lower 110 | // * 4 bits of each byte are read-only and always hold 0. 111 | // */ 112 | // test_word_write((uint32_t *)SCB->SHP, SHPR_BYTE_COUNT, 0x10, 0x10); 113 | // test_word_read((uint32_t *)SCB->SHP, SHPR_BYTE_COUNT); 114 | 115 | // test_hword_write((uint16_t *)SCB->SHP, SHPR_BYTE_COUNT, 0x20, 0x10); 116 | // test_hword_read((uint16_t *)SCB->SHP, SHPR_BYTE_COUNT); 117 | 118 | // test_byte_write(SCB->SHP, SHPR_BYTE_COUNT, 0x30, 0x10); 119 | // test_byte_read(SCB->SHP, SHPR_BYTE_COUNT); 120 | 121 | // /* Not implemented in QEMU */ 122 | // /*test_word_read((uint32_t *)0xe000efd0, 0x10);*/ 123 | 124 | // test_word_read((uint32_t *)0xe000efe0, 0x10); 125 | // test_word_read((uint32_t *)0xe000eff0, 0x10); 126 | 127 | // test_hword_read((uint16_t *)0xe000efe0, 0x10); 128 | // test_hword_read((uint16_t *)0xe000eff0, 0x10); 129 | 130 | // test_byte_read((uint8_t *)0xe000efe0, 0x10); 131 | // test_byte_read((uint8_t *)0xe000eff0, 0x10); 132 | 133 | /* Freeze */ 134 | while(1); 135 | } 136 | -------------------------------------------------------------------------------- /demos/qemu_test/stm32f10x_conf.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file GPIO/IOToggle/stm32f10x_conf.h 4 | * @author MCD Application Team 5 | * @version V3.3.0 6 | * @date 04/16/2010 7 | * @brief Library configuration file. 8 | ****************************************************************************** 9 | * @copy 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2010 STMicroelectronics

19 | */ 20 | 21 | /* Define to prevent recursive inclusion -------------------------------------*/ 22 | #ifndef __STM32F10x_CONF_H 23 | #define __STM32F10x_CONF_H 24 | 25 | /* Includes ------------------------------------------------------------------*/ 26 | /* Uncomment the line below to enable peripheral header file inclusion */ 27 | /* #include "stm32f10x_adc.h" */ 28 | /* #include "stm32f10x_bkp.h" */ 29 | /* #include "stm32f10x_can.h" */ 30 | /* #include "stm32f10x_cec.h" */ 31 | /* #include "stm32f10x_crc.h" */ 32 | /* #include "stm32f10x_dac.h" */ 33 | /* #include "stm32f10x_dbgmcu.h" */ 34 | /* #include "stm32f10x_dma.h" */ 35 | /* #include "stm32f10x_exti.h" */ 36 | /* #include "stm32f10x_flash.h" */ 37 | /* #include "stm32f10x_fsmc.h" */ 38 | /* #include "stm32f10x_gpio.h" */ 39 | /* #include "stm32f10x_i2c.h" */ 40 | /* #include "stm32f10x_iwdg.h" */ 41 | /* #include "stm32f10x_pwr.h" */ 42 | /* #include "stm32f10x_rcc.h" */ 43 | /* #include "stm32f10x_rtc.h" */ 44 | /* #include "stm32f10x_sdio.h" */ 45 | /* #include "stm32f10x_spi.h" */ 46 | /* #include "stm32f10x_tim.h" */ 47 | /* #include "stm32f10x_usart.h" */ 48 | /* #include "stm32f10x_wwdg.h" */ 49 | #include "misc.h" /* High level functions for NVIC and SysTick (add-on to CMSIS functions) */ 50 | 51 | /* Exported types ------------------------------------------------------------*/ 52 | /* Exported constants --------------------------------------------------------*/ 53 | /* Uncomment the line below to expanse the "assert_param" macro in the 54 | Standard Peripheral Library drivers code */ 55 | /* #define USE_FULL_ASSERT 1 */ 56 | 57 | /* Exported macro ------------------------------------------------------------*/ 58 | #ifdef USE_FULL_ASSERT 59 | 60 | /** 61 | * @brief The assert_param macro is used for function's parameters check. 62 | * @param expr: If expr is false, it calls assert_failed function 63 | * which reports the name of the source file and the source 64 | * line number of the call that failed. 65 | * If expr is true, it returns no value. 66 | * @retval None 67 | */ 68 | #define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__)) 69 | /* Exported functions ------------------------------------------------------- */ 70 | void assert_failed(uint8_t* file, uint32_t line); 71 | #else 72 | #define assert_param(expr) ((void)0) 73 | #endif /* USE_FULL_ASSERT */ 74 | 75 | #endif /* __STM32F10x_CONF_H */ 76 | 77 | /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/ 78 | -------------------------------------------------------------------------------- /demos/rtc/main.c: -------------------------------------------------------------------------------- 1 | // ADC : cf AN3116 2 | // stm32flash /dev/ttyUSB0 -w main.bin 3 | #define USE_STDPERIPH_DRIVER 4 | #include "stm32_p103.h" 5 | 6 | 7 | 8 | void USART1_Init(void) 9 | { 10 | USART_InitTypeDef USART_InitStructure; 11 | GPIO_InitTypeDef GPIO_InitStructure; 12 | 13 | /* Enable peripheral clocks. */ 14 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOC | RCC_APB2Periph_AFIO | RCC_APB2Periph_USART1, ENABLE); 15 | 16 | /* Configure USART1 Rx pin as floating input. */ 17 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; 18 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; 19 | GPIO_Init(GPIOA, &GPIO_InitStructure); 20 | 21 | /* Configure USART1 Tx as alternate function push-pull. */ 22 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9; 23 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 24 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; 25 | GPIO_Init(GPIOA, &GPIO_InitStructure); 26 | 27 | 28 | /* Configure the USART1 */ 29 | USART_InitStructure.USART_BaudRate = 9600; 30 | USART_InitStructure.USART_WordLength = USART_WordLength_8b; 31 | USART_InitStructure.USART_StopBits = USART_StopBits_1; 32 | USART_InitStructure.USART_Parity = USART_Parity_No; 33 | USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; 34 | USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; 35 | USART_Init(USART1, &USART_InitStructure); 36 | } 37 | 38 | void init_led1(void) 39 | { 40 | GPIO_InitTypeDef GPIO_InitStructure; 41 | 42 | /* Enable GPIO C clock. */ 43 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE); 44 | 45 | /* Set the LED pin state such that the LED is off. The LED is connected 46 | * between power and the microcontroller pin, which makes it turn on when 47 | * the pin is low. 48 | */ 49 | GPIO_WriteBit(GPIOC,GPIO_Pin_12,Bit_SET); 50 | 51 | /* Configure the LED pin as push-pull output. */ 52 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12; 53 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; 54 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 55 | GPIO_Init(GPIOC, &GPIO_InitStructure); 56 | } 57 | 58 | /* demos of RTC */ 59 | void time(int *h,int *min,int *sec) 60 | { 61 | *h=(*h +(*min/59)*(*sec/59)); 62 | *min=(*min+*sec/59)%60; 63 | *sec=(*sec+1)%60; 64 | } 65 | 66 | void send_char(char x) 67 | { 68 | while(USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET); 69 | USART_SendData(USART1,x); 70 | } 71 | 72 | void send_str(char* str) 73 | { 74 | int x=0; 75 | while(str[x]) 76 | send_char(str[x++]); 77 | } 78 | 79 | void send_nbr(int nbr) 80 | { 81 | if(nbr/10) 82 | send_nbr(nbr/10); 83 | send_char((nbr%10)+48); 84 | } 85 | 86 | void send_heure(int h,int min,int s) 87 | { 88 | send_nbr(h); 89 | send_char(':'); 90 | send_nbr(min); 91 | send_char(':'); 92 | send_nbr(s); 93 | send_char('\n'); 94 | } 95 | 96 | int main(void) 97 | { 98 | 99 | init_led1(); 100 | USART1_Init(); 101 | int h,min,sec; 102 | h=0; 103 | min=0; 104 | sec=0; 105 | //USART_Cmd(USART2, ENABLE); 106 | USART_Cmd(USART1, ENABLE); 107 | /* enable LSE SRC CLOCK */ 108 | RCC->BDCR |=RCC_BDCR_LSEON; 109 | /*select LSE as CLOCK of RTC*/ 110 | RCC->BDCR |=RCC_BDCR_RTCSEL_LSE; // Enable 111 | /* enable RTC CLK */ 112 | RCC->BDCR |= RCC_BDCR_RTCEN; 113 | /*wait for syncro*/ 114 | RTC_WaitForSynchro(); 115 | /*Enable Sec Interrupt*/ 116 | RTC_ITConfig(RTC_IT_SEC, ENABLE); 117 | /*Enable ALR Interrupt*/ 118 | RTC_ITConfig(RTC_IT_ALR, ENABLE); 119 | /*set prescaler for 1 seconde*/ 120 | RTC_SetPrescaler(0x7FFF); 121 | /*wait until last write 122 | operation has finished*/ 123 | RTC_WaitForLastTask(); 124 | /*set ALARM 10 seconde */ 125 | RTC_SetAlarm(0xA); 126 | RTC_WaitForLastTask(); 127 | /*clear counter*/ 128 | RTC_SetCounter(0x0); 129 | 130 | /*clear SEC and ALR flag*/ 131 | RTC_ClearFlag(RTC_FLAG_SEC); 132 | RTC_ClearFlag(RTC_FLAG_ALR); 133 | 134 | /*declench alarm each 10 sec*/ 135 | 136 | while (1) 137 | { 138 | 139 | while(RTC_GetFlagStatus(RTC_FLAG_SEC)==0); 140 | time(&h,&min,&sec); 141 | send_heure(h,min,sec); 142 | 143 | RTC_ClearFlag(RTC_FLAG_SEC); /*clear sec flag*/ 144 | 145 | if(RTC_GetFlagStatus(RTC_FLAG_ALR)){ 146 | 147 | send_str("ALARME\n"); 148 | RTC_ClearFlag(RTC_FLAG_ALR); /*clear alarm flag*/ 149 | /*clear count for declench 150 | alarm each 10 sec*/ 151 | RTC_SetCounter(0x0); 152 | 153 | GPIO_ResetBits(GPIOC, GPIO_Pin_12); 154 | GPIO_SetBits(GPIOC, GPIO_Pin_12); // Turn on led connected to PC.4 pin 155 | 156 | } 157 | } 158 | } 159 | 160 | 161 | -------------------------------------------------------------------------------- /demos/rtc/stm32f10x_conf.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file USART/HalfDuplex/stm32f10x_conf.h 4 | * @author MCD Application Team 5 | * @version V3.3.0 6 | * @date 04/16/2010 7 | * @brief Library configuration file. 8 | ****************************************************************************** 9 | * @copy 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2010 STMicroelectronics

19 | */ 20 | 21 | /* Define to prevent recursive inclusion -------------------------------------*/ 22 | #ifndef __STM32F10x_CONF_H 23 | #define __STM32F10x_CONF_H 24 | 25 | /* Includes ------------------------------------------------------------------*/ 26 | /* Uncomment the line below to enable peripheral header file inclusion */ 27 | #include "stm32f10x_adc.h" 28 | /* #include "stm32f10x_bkp.h" */ 29 | /* #include "stm32f10x_can.h" */ 30 | /* #include "stm32f10x_cec.h" */ 31 | /* #include "stm32f10x_crc.h" */ 32 | /* #include "stm32f10x_dac.h" */ 33 | /* #include "stm32f10x_dbgmcu.h" */ 34 | /* #include "stm32f10x_dma.h" */ 35 | /* #include "stm32f10x_exti.h" */ 36 | /* #include "stm32f10x_flash.h" */ 37 | /* #include "stm32f10x_fsmc.h" */ 38 | #include "stm32f10x_gpio.h" 39 | #include "stm32f10x_i2c.h" 40 | /* #include "stm32f10x_iwdg.h" */ 41 | /* #include "stm32f10x_pwr.h" */ 42 | #include "stm32f10x_rcc.h" 43 | #include "stm32f10x_rtc.h" 44 | /* #include "stm32f10x_sdio.h" */ 45 | /* #include "stm32f10x_spi.h" */ 46 | /* #include "stm32f10x_tim.h" */ 47 | #include "stm32f10x_usart.h" 48 | /* #include "stm32f10x_wwdg.h" */ 49 | #include "misc.h" /* High level functions for NVIC and SysTick (add-on to CMSIS functions) */ 50 | 51 | /* Exported types ------------------------------------------------------------*/ 52 | /* Exported constants --------------------------------------------------------*/ 53 | /* Uncomment the line below to expanse the "assert_param" macro in the 54 | Standard Peripheral Library drivers code */ 55 | /* #define USE_FULL_ASSERT 1 */ 56 | 57 | /* Exported macro ------------------------------------------------------------*/ 58 | #ifdef USE_FULL_ASSERT 59 | /** 60 | * @brief The assert_param macro is used for function's parameters check. 61 | * @param expr: If expr is false, it calls assert_failed function 62 | * which reports the name of the source file and the source 63 | * line number of the call that failed. 64 | * If expr is true, it returns no value. 65 | * @retval None 66 | */ 67 | #define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__)) 68 | /* Exported functions ------------------------------------------------------- */ 69 | void assert_failed(uint8_t* file, uint32_t line); 70 | #else 71 | #define assert_param(expr) ((void)0) 72 | #endif /* USE_FULL_ASSERT */ 73 | 74 | #endif /* __STM32F10x_CONF_H */ 75 | 76 | /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/ 77 | -------------------------------------------------------------------------------- /demos/software_int/main.c: -------------------------------------------------------------------------------- 1 | #define USE_STDPERIPH_DRIVER 2 | #include "stm32_p103.h" 3 | 4 | void myDelay(unsigned long delay ) 5 | { 6 | while(delay) delay--; 7 | } 8 | 9 | void EXTI0_IRQHandler(void) 10 | { 11 | /* Make sure the line has a pending interrupt 12 | * (should this always be true if we are inside this interrupt handle? */ 13 | 14 | if(EXTI_GetITStatus(EXTI_Line0) != RESET) { 15 | /* Toggle LED */ 16 | GPIOC->ODR = GPIOC->ODR ^ 0x00001000; 17 | 18 | /* Clear the pending interrupt flag that triggered this interrupt. */ 19 | EXTI_ClearITPendingBit(EXTI_Line0); 20 | } 21 | } 22 | 23 | int main(void) 24 | { 25 | init_led(); 26 | 27 | init_button(); 28 | enable_button_interrupts(); 29 | 30 | while(1) { 31 | /* Generate a software interrupt on EXTI line 0 */ 32 | EXTI_GenerateSWInterrupt(EXTI_Line0); 33 | 34 | myDelay(500000); 35 | } 36 | } 37 | 38 | 39 | -------------------------------------------------------------------------------- /demos/software_int/stm32f10x_conf.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file GPIO/IOToggle/stm32f10x_conf.h 4 | * @author MCD Application Team 5 | * @version V3.3.0 6 | * @date 04/16/2010 7 | * @brief Library configuration file. 8 | ****************************************************************************** 9 | * @copy 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2010 STMicroelectronics

19 | */ 20 | 21 | /* Define to prevent recursive inclusion -------------------------------------*/ 22 | #ifndef __STM32F10x_CONF_H 23 | #define __STM32F10x_CONF_H 24 | 25 | /* Includes ------------------------------------------------------------------*/ 26 | /* Uncomment the line below to enable peripheral header file inclusion */ 27 | /* #include "stm32f10x_adc.h" */ 28 | /* #include "stm32f10x_bkp.h" */ 29 | /* #include "stm32f10x_can.h" */ 30 | /* #include "stm32f10x_cec.h" */ 31 | /* #include "stm32f10x_crc.h" */ 32 | /* #include "stm32f10x_dac.h" */ 33 | /* #include "stm32f10x_dbgmcu.h" */ 34 | /* #include "stm32f10x_dma.h" */ 35 | #include "stm32f10x_exti.h" 36 | /* #include "stm32f10x_flash.h" */ 37 | /* #include "stm32f10x_fsmc.h" */ 38 | #include "stm32f10x_gpio.h" 39 | /* #include "stm32f10x_i2c.h" */ 40 | /* #include "stm32f10x_iwdg.h" */ 41 | /* #include "stm32f10x_pwr.h" */ 42 | /* #include "stm32f10x_rcc.h" */ 43 | /* #include "stm32f10x_rtc.h" */ 44 | /* #include "stm32f10x_sdio.h" */ 45 | /* #include "stm32f10x_spi.h" */ 46 | /* #include "stm32f10x_tim.h" */ 47 | /* #include "stm32f10x_usart.h" */ 48 | /* #include "stm32f10x_wwdg.h" */ 49 | /* #include "misc.h" */ /* High level functions for NVIC and SysTick (add-on to CMSIS functions) */ 50 | 51 | /* Exported types ------------------------------------------------------------*/ 52 | /* Exported constants --------------------------------------------------------*/ 53 | /* Uncomment the line below to expanse the "assert_param" macro in the 54 | Standard Peripheral Library drivers code */ 55 | /* #define USE_FULL_ASSERT 1 */ 56 | 57 | /* Exported macro ------------------------------------------------------------*/ 58 | #ifdef USE_FULL_ASSERT 59 | 60 | /** 61 | * @brief The assert_param macro is used for function's parameters check. 62 | * @param expr: If expr is false, it calls assert_failed function 63 | * which reports the name of the source file and the source 64 | * line number of the call that failed. 65 | * If expr is true, it returns no value. 66 | * @retval None 67 | */ 68 | #define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__)) 69 | /* Exported functions ------------------------------------------------------- */ 70 | void assert_failed(uint8_t* file, uint32_t line); 71 | #else 72 | #define assert_param(expr) ((void)0) 73 | #endif /* USE_FULL_ASSERT */ 74 | 75 | #endif /* __STM32F10x_CONF_H */ 76 | 77 | /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/ 78 | -------------------------------------------------------------------------------- /demos/stkalign/main.c: -------------------------------------------------------------------------------- 1 | #define USE_STDPERIPH_DRIVER 2 | #include "stm32_p103.h" 3 | 4 | #define NVIC_CCR ((volatile unsigned long *)(0xE000ED14)) 5 | 6 | void EXTI0_IRQHandler(void) 7 | { 8 | /* Make sure the line has a pending interrupt 9 | * (should this alwaysbe true if we are inside this interrupt handle? */ 10 | 11 | if(EXTI_GetITStatus(EXTI_Line0) != RESET) { 12 | /* Toggle LED */ 13 | GPIOC->ODR = GPIOC->ODR ^ 0x00001000; 14 | 15 | /* Clear the pending interrupt flag that triggered this interrupt. */ 16 | EXTI_ClearITPendingBit(EXTI_Line0); 17 | } 18 | } 19 | 20 | int main(void) 21 | { 22 | unsigned long var; 23 | 24 | init_led(); 25 | 26 | init_button(); 27 | enable_button_interrupts(); 28 | 29 | *NVIC_CCR = *NVIC_CCR | 0x200; 30 | 31 | __asm volatile ( 32 | "mov r0, sp \n" 33 | "and r0, r0, #4 \n" 34 | "cmp r0, #0 \n" 35 | "bne fourbytealigned1 \n" 36 | "sub sp, #4 \n" 37 | "fourbytealigned1: \n" 38 | "mov r0, sp \n" 39 | : 40 | : 41 | : "r0"); 42 | 43 | EXTI->SWIER |= EXTI_Line0; //Address should end in 0 or 8 inside interrupt 44 | 45 | __asm volatile ( 46 | "mov r0, sp \n" 47 | "and r0, r0, #4 \n" 48 | "cmp r0, #0 \n" 49 | "beq eightbytealigned1 \n" 50 | "sub sp, #4 \n" 51 | "eightbytealigned1: \n" 52 | "mov r0, sp \n" 53 | : 54 | : 55 | : "r0"); 56 | 57 | EXTI->SWIER |= EXTI_Line0; //Address should end in 0 or 8 inside interrupt 58 | 59 | 60 | 61 | 62 | 63 | 64 | *NVIC_CCR = *NVIC_CCR & 0xfffffdff; 65 | 66 | __asm volatile ( 67 | "mov r0, sp \n" 68 | "and r0, r0, #4 \n" 69 | "cmp r0, #0 \n" 70 | "bne fourbytealigned2 \n" 71 | "sub sp, #4 \n" 72 | "fourbytealigned2: \n" 73 | "mov r0, sp \n" 74 | : 75 | : 76 | : "r0"); 77 | 78 | EXTI->SWIER |= EXTI_Line0; //Address should end in 4 or c inside interrupt 79 | 80 | __asm volatile ( 81 | "mov r0, sp \n" 82 | "and r0, r0, #4 \n" 83 | "cmp r0, #0 \n" 84 | "beq eightbytealigned2 \n" 85 | "sub sp, #4 \n" 86 | "eightbytealigned2: \n" 87 | "mov r0, sp \n" 88 | : 89 | : 90 | : "r0"); 91 | 92 | EXTI->SWIER |= EXTI_Line0; //Address should end in 0 or 8 inside interrupt 93 | 94 | 95 | while(1); 96 | } 97 | -------------------------------------------------------------------------------- /demos/stkalign/stm32f10x_conf.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file GPIO/IOToggle/stm32f10x_conf.h 4 | * @author MCD Application Team 5 | * @version V3.3.0 6 | * @date 04/16/2010 7 | * @brief Library configuration file. 8 | ****************************************************************************** 9 | * @copy 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2010 STMicroelectronics

19 | */ 20 | 21 | /* Define to prevent recursive inclusion -------------------------------------*/ 22 | #ifndef __STM32F10x_CONF_H 23 | #define __STM32F10x_CONF_H 24 | 25 | /* Includes ------------------------------------------------------------------*/ 26 | /* Uncomment the line below to enable peripheral header file inclusion */ 27 | /* #include "stm32f10x_adc.h" */ 28 | /* #include "stm32f10x_bkp.h" */ 29 | /* #include "stm32f10x_can.h" */ 30 | /* #include "stm32f10x_cec.h" */ 31 | /* #include "stm32f10x_crc.h" */ 32 | /* #include "stm32f10x_dac.h" */ 33 | /* #include "stm32f10x_dbgmcu.h" */ 34 | /* #include "stm32f10x_dma.h" */ 35 | #include "stm32f10x_exti.h" 36 | /* #include "stm32f10x_flash.h" */ 37 | /* #include "stm32f10x_fsmc.h" */ 38 | #include "stm32f10x_gpio.h" 39 | /* #include "stm32f10x_i2c.h" */ 40 | /* #include "stm32f10x_iwdg.h" */ 41 | /* #include "stm32f10x_pwr.h" */ 42 | /* #include "stm32f10x_rcc.h" */ 43 | /* #include "stm32f10x_rtc.h" */ 44 | /* #include "stm32f10x_sdio.h" */ 45 | /* #include "stm32f10x_spi.h" */ 46 | /* #include "stm32f10x_tim.h" */ 47 | /* #include "stm32f10x_usart.h" */ 48 | /* #include "stm32f10x_wwdg.h" */ 49 | #include "misc.h" /* High level functions for NVIC and SysTick (add-on to CMSIS functions) */ 50 | 51 | /* Exported types ------------------------------------------------------------*/ 52 | /* Exported constants --------------------------------------------------------*/ 53 | /* Uncomment the line below to expanse the "assert_param" macro in the 54 | Standard Peripheral Library drivers code */ 55 | /* #define USE_FULL_ASSERT 1 */ 56 | 57 | /* Exported macro ------------------------------------------------------------*/ 58 | #ifdef USE_FULL_ASSERT 59 | 60 | /** 61 | * @brief The assert_param macro is used for function's parameters check. 62 | * @param expr: If expr is false, it calls assert_failed function 63 | * which reports the name of the source file and the source 64 | * line number of the call that failed. 65 | * If expr is true, it returns no value. 66 | * @retval None 67 | */ 68 | #define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__)) 69 | /* Exported functions ------------------------------------------------------- */ 70 | void assert_failed(uint8_t* file, uint32_t line); 71 | #else 72 | #define assert_param(expr) ((void)0) 73 | #endif /* USE_FULL_ASSERT */ 74 | 75 | #endif /* __STM32F10x_CONF_H */ 76 | 77 | /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/ 78 | -------------------------------------------------------------------------------- /demos/systick/main.c: -------------------------------------------------------------------------------- 1 | #define USE_STDPERIPH_DRIVER 2 | #include "stm32_p103.h" 3 | #include "stm32_p103.h" 4 | 5 | void SysTick_Handler(void) 6 | { 7 | GPIOC->ODR ^= 0x00001000; 8 | } 9 | 10 | int main(void) 11 | { 12 | int last_button_state, new_button_state; 13 | uint32_t hclk_ticks_per_sec, ext_clock_ticks_per_sec; 14 | 15 | init_led(); 16 | init_button(); 17 | 18 | /* The Cortex System Timer (SysTick) clock can be driven by the Cortex 19 | * clock (HCLK), which is the output of the AHB prescaler, or from the 20 | * external clock, which is HLCK divided by 8. 21 | * Call SysTick_Config with the number of ticks between Systick interrupts. 22 | * We will choose this value such that there is one second 23 | * between interrupts when the external clock (HCLK / 8) is selected. 24 | * Initially, the Cortex clock (HCLK) will be selected, which means an 25 | * interrupt every 1/8th of a second. 26 | */ 27 | hclk_ticks_per_sec = SystemCoreClock; 28 | ext_clock_ticks_per_sec = hclk_ticks_per_sec / 8; 29 | if (SysTick_Config(ext_clock_ticks_per_sec)) 30 | { 31 | /* If SysTick_Config returns 1, that means the number ticks exceeds the 32 | * limit. */ 33 | while (1); 34 | } 35 | 36 | /* Infinite loop - when the button changes state, toggle the SysTick clock 37 | * source. 38 | */ 39 | last_button_state = GPIOA->IDR & 0x00000001; 40 | while(1) { 41 | new_button_state = GPIOA->IDR & 0x00000001; 42 | if(new_button_state ^ last_button_state) { 43 | if(new_button_state) { 44 | SysTick->CTRL ^= SysTick_CTRL_CLKSOURCE_Msk; 45 | } 46 | } 47 | last_button_state = new_button_state; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /demos/systick/stm32f10x_conf.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file GPIO/IOToggle/stm32f10x_conf.h 4 | * @author MCD Application Team 5 | * @version V3.3.0 6 | * @date 04/16/2010 7 | * @brief Library configuration file. 8 | ****************************************************************************** 9 | * @copy 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2010 STMicroelectronics

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

© COPYRIGHT 2010 STMicroelectronics

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

© COPYRIGHT 2010 STMicroelectronics

19 | */ 20 | 21 | /* Define to prevent recursive inclusion -------------------------------------*/ 22 | #ifndef __STM32F10x_CONF_H 23 | #define __STM32F10x_CONF_H 24 | 25 | //#define HSI_VALUE ((uint32_t)40000) 26 | //#define HSI_Value ((uint32_t)40000) 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | /* Uncomment the line below to enable peripheral header file inclusion */ 30 | /* #include "stm32f10x_adc.h" */ 31 | /* #include "stm32f10x_bkp.h" */ 32 | /* #include "stm32f10x_can.h" */ 33 | /* #include "stm32f10x_cec.h" */ 34 | /* #include "stm32f10x_crc.h" */ 35 | /* #include "stm32f10x_dac.h" */ 36 | /* #include "stm32f10x_dbgmcu.h" */ 37 | /* #include "stm32f10x_dma.h" */ 38 | /* #include "stm32f10x_exti.h" */ 39 | /* #include "stm32f10x_flash.h" */ 40 | /* #include "stm32f10x_fsmc.h" */ 41 | /* #include "stm32f10x_gpio.h" */ 42 | /* #include "stm32f10x_i2c.h" */ 43 | /* #include "stm32f10x_iwdg.h" */ 44 | /* #include "stm32f10x_pwr.h" */ 45 | /* #include "stm32f10x_rcc.h" */ 46 | /* #include "stm32f10x_rtc.h" */ 47 | /* #include "stm32f10x_sdio.h" */ 48 | /* #include "stm32f10x_spi.h" */ 49 | /* #include "stm32f10x_tim.h" */ 50 | #include "stm32f10x_usart.h" 51 | /* #include "stm32f10x_wwdg.h" */ 52 | /* #include "misc.h" */ /* High level functions for NVIC and SysTick (add-on to CMSIS functions) */ 53 | 54 | /* Exported types ------------------------------------------------------------*/ 55 | /* Exported constants --------------------------------------------------------*/ 56 | /* Uncomment the line below to expanse the "assert_param" macro in the 57 | Standard Peripheral Library drivers code */ 58 | /* #define USE_FULL_ASSERT 1 */ 59 | 60 | /* Exported macro ------------------------------------------------------------*/ 61 | #ifdef USE_FULL_ASSERT 62 | /** 63 | * @brief The assert_param macro is used for function's parameters check. 64 | * @param expr: If expr is false, it calls assert_failed function 65 | * which reports the name of the source file and the source 66 | * line number of the call that failed. 67 | * If expr is true, it returns no value. 68 | * @retval None 69 | */ 70 | #define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__)) 71 | /* Exported functions ------------------------------------------------------- */ 72 | void assert_failed(uint8_t* file, uint32_t line); 73 | #else 74 | #define assert_param(expr) ((void)0) 75 | #endif /* USE_FULL_ASSERT */ 76 | 77 | #endif /* __STM32F10x_CONF_H */ 78 | 79 | /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/ 80 | -------------------------------------------------------------------------------- /demos/uart_echo_int/main.c: -------------------------------------------------------------------------------- 1 | #define USE_STDPERIPH_DRIVER 2 | #include "stm32_p103.h" 3 | 4 | 5 | volatile char in_char; 6 | volatile char *out_str = "Got:_\n"; 7 | volatile int curr_char; 8 | 9 | /* Handler predefined by STM32 library to handle USART2 interrupts. */ 10 | void USART2_IRQHandler(void) 11 | { 12 | if(USART_GetITStatus(USART2, USART_IT_RXNE) != RESET) { 13 | GPIOC->ODR = GPIOC->ODR ^ 0x00001000; 14 | if(curr_char == -1) { 15 | in_char = USART_ReceiveData(USART2); 16 | 17 | USART_ITConfig(USART2, USART_IT_TXE, ENABLE); 18 | 19 | curr_char = 1; 20 | USART_SendData(USART2, out_str[0]); 21 | } else { 22 | /* Discard byte if we are still processing the last one. */ 23 | USART_ReceiveData(USART2); 24 | } 25 | } 26 | 27 | if(USART_GetITStatus(USART2, USART_IT_TXE) != RESET) { 28 | GPIOC->ODR = GPIOC->ODR ^ 0x00001000; 29 | 30 | if(curr_char == -1) { 31 | USART_SendData(USART2, '!'); //This should never happen 32 | } else if(out_str[curr_char] == '_') { 33 | curr_char++; 34 | USART_SendData(USART2, in_char); 35 | } else if(out_str[curr_char] == '\0') { 36 | curr_char = -1; 37 | USART_ITConfig(USART2, USART_IT_TXE, DISABLE); 38 | } else { 39 | USART_SendData(USART2, out_str[curr_char++]); 40 | } 41 | } 42 | } 43 | 44 | 45 | 46 | 47 | int main(void) 48 | { 49 | init_led(); 50 | 51 | init_button(); 52 | 53 | init_rs232(); 54 | enable_rs232_interrupts(); 55 | curr_char = -1; 56 | enable_rs232(); 57 | 58 | while(1); 59 | } 60 | -------------------------------------------------------------------------------- /demos/uart_echo_int/stm32f10x_conf.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file USART/HalfDuplex/stm32f10x_conf.h 4 | * @author MCD Application Team 5 | * @version V3.3.0 6 | * @date 04/16/2010 7 | * @brief Library configuration file. 8 | ****************************************************************************** 9 | * @copy 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2010 STMicroelectronics

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

© COPYRIGHT 2010 STMicroelectronics

19 | */ 20 | 21 | /* Define to prevent recursive inclusion -------------------------------------*/ 22 | #ifndef __STM32F10x_CONF_H 23 | #define __STM32F10x_CONF_H 24 | 25 | /* Includes ------------------------------------------------------------------*/ 26 | /* Uncomment the line below to enable peripheral header file inclusion */ 27 | /* #include "stm32f10x_adc.h" */ 28 | /* #include "stm32f10x_bkp.h" */ 29 | /* #include "stm32f10x_can.h" */ 30 | /* #include "stm32f10x_cec.h" */ 31 | /* #include "stm32f10x_crc.h" */ 32 | /* #include "stm32f10x_dac.h" */ 33 | /* #include "stm32f10x_dbgmcu.h" */ 34 | /* #include "stm32f10x_dma.h" */ 35 | /* #include "stm32f10x_exti.h" */ 36 | /* #include "stm32f10x_flash.h" */ 37 | /* #include "stm32f10x_fsmc.h" */ 38 | #include "stm32f10x_gpio.h" 39 | /* #include "stm32f10x_i2c.h" */ 40 | /* #include "stm32f10x_iwdg.h" */ 41 | /* #include "stm32f10x_pwr.h" */ 42 | /* #include "stm32f10x_rcc.h" */ 43 | /* #include "stm32f10x_rtc.h" */ 44 | /* #include "stm32f10x_sdio.h" */ 45 | /* #include "stm32f10x_spi.h" */ 46 | /* #include "stm32f10x_tim.h" */ 47 | #include "stm32f10x_usart.h" 48 | /* #include "stm32f10x_wwdg.h" */ 49 | /* #include "misc.h" */ /* High level functions for NVIC and SysTick (add-on to CMSIS functions) */ 50 | 51 | /* Exported types ------------------------------------------------------------*/ 52 | /* Exported constants --------------------------------------------------------*/ 53 | /* Uncomment the line below to expanse the "assert_param" macro in the 54 | Standard Peripheral Library drivers code */ 55 | /* #define USE_FULL_ASSERT 1 */ 56 | 57 | /* Exported macro ------------------------------------------------------------*/ 58 | #ifdef USE_FULL_ASSERT 59 | /** 60 | * @brief The assert_param macro is used for function's parameters check. 61 | * @param expr: If expr is false, it calls assert_failed function 62 | * which reports the name of the source file and the source 63 | * line number of the call that failed. 64 | * If expr is true, it returns no value. 65 | * @retval None 66 | */ 67 | #define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__)) 68 | /* Exported functions ------------------------------------------------------- */ 69 | void assert_failed(uint8_t* file, uint32_t line); 70 | #else 71 | #define assert_param(expr) ((void)0) 72 | #endif /* USE_FULL_ASSERT */ 73 | 74 | #endif /* __STM32F10x_CONF_H */ 75 | 76 | /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/ 77 | -------------------------------------------------------------------------------- /demos/uart_repeat_write_int/main.c: -------------------------------------------------------------------------------- 1 | #define USE_STDPERIPH_DRIVER 2 | #include "stm32_p103.h" 3 | 4 | void USART2_IRQHandler(void) 5 | { 6 | /* Make sure the interrupt was triggered by a transmit. This should 7 | * always be true. 8 | */ 9 | if(USART_GetITStatus(USART2, USART_IT_TXE) != RESET) { 10 | /* Toggle the LED just to show that progress is being made. */ 11 | GPIOC->ODR = GPIOC->ODR ^ 0x00001000; 12 | 13 | /* Send the next byte */ 14 | USART_SendData(USART2, 'X'); 15 | } 16 | } 17 | 18 | int main(void) 19 | { 20 | init_led(); 21 | 22 | init_button(); 23 | 24 | init_rs232(); 25 | enable_rs232_interrupts(); 26 | enable_rs232(); 27 | 28 | /* Send the first byte and enable the interrupt. */ 29 | USART_SendData(USART2, 'x'); 30 | USART_ITConfig(USART2, USART_IT_TXE, ENABLE); 31 | 32 | /* Infinite loop - when the previous finishes, the interrupt will trigger. 33 | * The interrupt will send the next byte. 34 | */ 35 | while(1); 36 | } 37 | -------------------------------------------------------------------------------- /demos/uart_repeat_write_int/stm32f10x_conf.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file USART/HalfDuplex/stm32f10x_conf.h 4 | * @author MCD Application Team 5 | * @version V3.3.0 6 | * @date 04/16/2010 7 | * @brief Library configuration file. 8 | ****************************************************************************** 9 | * @copy 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2010 STMicroelectronics

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

© COPYRIGHT 2011 STMicroelectronics

19 | ****************************************************************************** 20 | */ 21 | 22 | /** @addtogroup CMSIS 23 | * @{ 24 | */ 25 | 26 | /** @addtogroup stm32f10x_system 27 | * @{ 28 | */ 29 | 30 | /** 31 | * @brief Define to prevent recursive inclusion 32 | */ 33 | #ifndef __SYSTEM_STM32F10X_H 34 | #define __SYSTEM_STM32F10X_H 35 | 36 | #ifdef __cplusplus 37 | extern "C" { 38 | #endif 39 | 40 | /** @addtogroup STM32F10x_System_Includes 41 | * @{ 42 | */ 43 | 44 | /** 45 | * @} 46 | */ 47 | 48 | 49 | /** @addtogroup STM32F10x_System_Exported_types 50 | * @{ 51 | */ 52 | 53 | extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ 54 | 55 | /** 56 | * @} 57 | */ 58 | 59 | /** @addtogroup STM32F10x_System_Exported_Constants 60 | * @{ 61 | */ 62 | 63 | /** 64 | * @} 65 | */ 66 | 67 | /** @addtogroup STM32F10x_System_Exported_Macros 68 | * @{ 69 | */ 70 | 71 | /** 72 | * @} 73 | */ 74 | 75 | /** @addtogroup STM32F10x_System_Exported_Functions 76 | * @{ 77 | */ 78 | 79 | extern void SystemInit(void); 80 | extern void SystemCoreClockUpdate(void); 81 | /** 82 | * @} 83 | */ 84 | 85 | #ifdef __cplusplus 86 | } 87 | #endif 88 | 89 | #endif /*__SYSTEM_STM32F10X_H */ 90 | 91 | /** 92 | * @} 93 | */ 94 | 95 | /** 96 | * @} 97 | */ 98 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 99 | -------------------------------------------------------------------------------- /libraries/CMSIS/CMSIS debug support.htm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beckus/stm32_p103_demos/4a369e92a57d2e539aa6160f0c0a50de17cad895/libraries/CMSIS/CMSIS debug support.htm -------------------------------------------------------------------------------- /libraries/CMSIS/Documentation/CMSIS_Core.htm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beckus/stm32_p103_demos/4a369e92a57d2e539aa6160f0c0a50de17cad895/libraries/CMSIS/Documentation/CMSIS_Core.htm -------------------------------------------------------------------------------- /libraries/CMSIS/License.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beckus/stm32_p103_demos/4a369e92a57d2e539aa6160f0c0a50de17cad895/libraries/CMSIS/License.doc -------------------------------------------------------------------------------- /libraries/FreeRTOS/include/projdefs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * FreeRTOS Kernel V10.0.0 3 | * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | * this software and associated documentation files (the "Software"), to deal in 7 | * the Software without restriction, including without limitation the rights to 8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | * the Software, and to permit persons to whom the Software is furnished to do so, 10 | * subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. If you wish to use our Amazon 14 | * FreeRTOS name, please do so in a fair use way that does not cause confusion. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 18 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 19 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 20 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | * 23 | * http://www.FreeRTOS.org 24 | * http://aws.amazon.com/freertos 25 | * 26 | * 1 tab == 4 spaces! 27 | */ 28 | 29 | #ifndef PROJDEFS_H 30 | #define PROJDEFS_H 31 | 32 | /* 33 | * Defines the prototype to which task functions must conform. Defined in this 34 | * file to ensure the type is known before portable.h is included. 35 | */ 36 | typedef void (*TaskFunction_t)( void * ); 37 | 38 | /* Converts a time in milliseconds to a time in ticks. This macro can be 39 | overridden by a macro of the same name defined in FreeRTOSConfig.h in case the 40 | definition here is not suitable for your application. */ 41 | #ifndef pdMS_TO_TICKS 42 | #define pdMS_TO_TICKS( xTimeInMs ) ( ( TickType_t ) ( ( ( TickType_t ) ( xTimeInMs ) * ( TickType_t ) configTICK_RATE_HZ ) / ( TickType_t ) 1000 ) ) 43 | #endif 44 | 45 | #define pdFALSE ( ( BaseType_t ) 0 ) 46 | #define pdTRUE ( ( BaseType_t ) 1 ) 47 | 48 | #define pdPASS ( pdTRUE ) 49 | #define pdFAIL ( pdFALSE ) 50 | #define errQUEUE_EMPTY ( ( BaseType_t ) 0 ) 51 | #define errQUEUE_FULL ( ( BaseType_t ) 0 ) 52 | 53 | /* FreeRTOS error definitions. */ 54 | #define errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY ( -1 ) 55 | #define errQUEUE_BLOCKED ( -4 ) 56 | #define errQUEUE_YIELD ( -5 ) 57 | 58 | /* Macros used for basic data corruption checks. */ 59 | #ifndef configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES 60 | #define configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES 0 61 | #endif 62 | 63 | #if( configUSE_16_BIT_TICKS == 1 ) 64 | #define pdINTEGRITY_CHECK_VALUE 0x5a5a 65 | #else 66 | #define pdINTEGRITY_CHECK_VALUE 0x5a5a5a5aUL 67 | #endif 68 | 69 | /* The following errno values are used by FreeRTOS+ components, not FreeRTOS 70 | itself. */ 71 | #define pdFREERTOS_ERRNO_NONE 0 /* No errors */ 72 | #define pdFREERTOS_ERRNO_ENOENT 2 /* No such file or directory */ 73 | #define pdFREERTOS_ERRNO_EINTR 4 /* Interrupted system call */ 74 | #define pdFREERTOS_ERRNO_EIO 5 /* I/O error */ 75 | #define pdFREERTOS_ERRNO_ENXIO 6 /* No such device or address */ 76 | #define pdFREERTOS_ERRNO_EBADF 9 /* Bad file number */ 77 | #define pdFREERTOS_ERRNO_EAGAIN 11 /* No more processes */ 78 | #define pdFREERTOS_ERRNO_EWOULDBLOCK 11 /* Operation would block */ 79 | #define pdFREERTOS_ERRNO_ENOMEM 12 /* Not enough memory */ 80 | #define pdFREERTOS_ERRNO_EACCES 13 /* Permission denied */ 81 | #define pdFREERTOS_ERRNO_EFAULT 14 /* Bad address */ 82 | #define pdFREERTOS_ERRNO_EBUSY 16 /* Mount device busy */ 83 | #define pdFREERTOS_ERRNO_EEXIST 17 /* File exists */ 84 | #define pdFREERTOS_ERRNO_EXDEV 18 /* Cross-device link */ 85 | #define pdFREERTOS_ERRNO_ENODEV 19 /* No such device */ 86 | #define pdFREERTOS_ERRNO_ENOTDIR 20 /* Not a directory */ 87 | #define pdFREERTOS_ERRNO_EISDIR 21 /* Is a directory */ 88 | #define pdFREERTOS_ERRNO_EINVAL 22 /* Invalid argument */ 89 | #define pdFREERTOS_ERRNO_ENOSPC 28 /* No space left on device */ 90 | #define pdFREERTOS_ERRNO_ESPIPE 29 /* Illegal seek */ 91 | #define pdFREERTOS_ERRNO_EROFS 30 /* Read only file system */ 92 | #define pdFREERTOS_ERRNO_EUNATCH 42 /* Protocol driver not attached */ 93 | #define pdFREERTOS_ERRNO_EBADE 50 /* Invalid exchange */ 94 | #define pdFREERTOS_ERRNO_EFTYPE 79 /* Inappropriate file type or format */ 95 | #define pdFREERTOS_ERRNO_ENMFILE 89 /* No more files */ 96 | #define pdFREERTOS_ERRNO_ENOTEMPTY 90 /* Directory not empty */ 97 | #define pdFREERTOS_ERRNO_ENAMETOOLONG 91 /* File or path name too long */ 98 | #define pdFREERTOS_ERRNO_EOPNOTSUPP 95 /* Operation not supported on transport endpoint */ 99 | #define pdFREERTOS_ERRNO_ENOBUFS 105 /* No buffer space available */ 100 | #define pdFREERTOS_ERRNO_ENOPROTOOPT 109 /* Protocol not available */ 101 | #define pdFREERTOS_ERRNO_EADDRINUSE 112 /* Address already in use */ 102 | #define pdFREERTOS_ERRNO_ETIMEDOUT 116 /* Connection timed out */ 103 | #define pdFREERTOS_ERRNO_EINPROGRESS 119 /* Connection already in progress */ 104 | #define pdFREERTOS_ERRNO_EALREADY 120 /* Socket already connected */ 105 | #define pdFREERTOS_ERRNO_EADDRNOTAVAIL 125 /* Address not available */ 106 | #define pdFREERTOS_ERRNO_EISCONN 127 /* Socket is already connected */ 107 | #define pdFREERTOS_ERRNO_ENOTCONN 128 /* Socket is not connected */ 108 | #define pdFREERTOS_ERRNO_ENOMEDIUM 135 /* No medium inserted */ 109 | #define pdFREERTOS_ERRNO_EILSEQ 138 /* An invalid UTF-16 sequence was encountered. */ 110 | #define pdFREERTOS_ERRNO_ECANCELED 140 /* Operation canceled. */ 111 | 112 | /* The following endian values are used by FreeRTOS+ components, not FreeRTOS 113 | itself. */ 114 | #define pdFREERTOS_LITTLE_ENDIAN 0 115 | #define pdFREERTOS_BIG_ENDIAN 1 116 | 117 | /* Re-defining endian values for generic naming. */ 118 | #define pdLITTLE_ENDIAN pdFREERTOS_LITTLE_ENDIAN 119 | #define pdBIG_ENDIAN pdFREERTOS_BIG_ENDIAN 120 | 121 | 122 | #endif /* PROJDEFS_H */ 123 | 124 | 125 | 126 | -------------------------------------------------------------------------------- /libraries/FreeRTOS/include/stdint.readme: -------------------------------------------------------------------------------- 1 | 2 | #ifndef FREERTOS_STDINT 3 | #define FREERTOS_STDINT 4 | 5 | /******************************************************************************* 6 | * THIS IS NOT A FULL stdint.h IMPLEMENTATION - It only contains the definitions 7 | * necessary to build the FreeRTOS code. It is provided to allow FreeRTOS to be 8 | * built using compilers that do not provide their own stdint.h definition. 9 | * 10 | * To use this file: 11 | * 12 | * 1) Copy this file into the directory that contains your FreeRTOSConfig.h 13 | * header file, as that directory will already be in the compilers include 14 | * path. 15 | * 16 | * 2) Rename the copied file stdint.h. 17 | * 18 | */ 19 | 20 | typedef signed char int8_t; 21 | typedef unsigned char uint8_t; 22 | typedef short int16_t; 23 | typedef unsigned short uint16_t; 24 | typedef long int32_t; 25 | typedef unsigned long uint32_t; 26 | 27 | #endif /* FREERTOS_STDINT */ 28 | -------------------------------------------------------------------------------- /libraries/FreeRTOS/portable/MemMang/ReadMe.url: -------------------------------------------------------------------------------- 1 | [{000214A0-0000-0000-C000-000000000046}] 2 | Prop3=19,2 3 | [InternetShortcut] 4 | URL=http://www.freertos.org/a00111.html 5 | IDList= 6 | -------------------------------------------------------------------------------- /libraries/FreeRTOS/portable/MemMang/heap_1.c: -------------------------------------------------------------------------------- 1 | /* 2 | * FreeRTOS Kernel V10.0.0 3 | * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | * this software and associated documentation files (the "Software"), to deal in 7 | * the Software without restriction, including without limitation the rights to 8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | * the Software, and to permit persons to whom the Software is furnished to do so, 10 | * subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. If you wish to use our Amazon 14 | * FreeRTOS name, please do so in a fair use way that does not cause confusion. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 18 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 19 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 20 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | * 23 | * http://www.FreeRTOS.org 24 | * http://aws.amazon.com/freertos 25 | * 26 | * 1 tab == 4 spaces! 27 | */ 28 | 29 | 30 | /* 31 | * The simplest possible implementation of pvPortMalloc(). Note that this 32 | * implementation does NOT allow allocated memory to be freed again. 33 | * 34 | * See heap_2.c, heap_3.c and heap_4.c for alternative implementations, and the 35 | * memory management pages of http://www.FreeRTOS.org for more information. 36 | */ 37 | #include 38 | 39 | /* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining 40 | all the API functions to use the MPU wrappers. That should only be done when 41 | task.h is included from an application file. */ 42 | #define MPU_WRAPPERS_INCLUDED_FROM_API_FILE 43 | 44 | #include "FreeRTOS.h" 45 | #include "task.h" 46 | 47 | #undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE 48 | 49 | #if( configSUPPORT_DYNAMIC_ALLOCATION == 0 ) 50 | #error This file must not be used if configSUPPORT_DYNAMIC_ALLOCATION is 0 51 | #endif 52 | 53 | /* A few bytes might be lost to byte aligning the heap start address. */ 54 | #define configADJUSTED_HEAP_SIZE ( configTOTAL_HEAP_SIZE - portBYTE_ALIGNMENT ) 55 | 56 | /* Allocate the memory for the heap. */ 57 | /* Allocate the memory for the heap. */ 58 | #if( configAPPLICATION_ALLOCATED_HEAP == 1 ) 59 | /* The application writer has already defined the array used for the RTOS 60 | heap - probably so it can be placed in a special segment or address. */ 61 | extern uint8_t ucHeap[ configTOTAL_HEAP_SIZE ]; 62 | #else 63 | static uint8_t ucHeap[ configTOTAL_HEAP_SIZE ]; 64 | #endif /* configAPPLICATION_ALLOCATED_HEAP */ 65 | 66 | /* Index into the ucHeap array. */ 67 | static size_t xNextFreeByte = ( size_t ) 0; 68 | 69 | /*-----------------------------------------------------------*/ 70 | 71 | void *pvPortMalloc( size_t xWantedSize ) 72 | { 73 | void *pvReturn = NULL; 74 | static uint8_t *pucAlignedHeap = NULL; 75 | 76 | /* Ensure that blocks are always aligned to the required number of bytes. */ 77 | #if( portBYTE_ALIGNMENT != 1 ) 78 | { 79 | if( xWantedSize & portBYTE_ALIGNMENT_MASK ) 80 | { 81 | /* Byte alignment required. */ 82 | xWantedSize += ( portBYTE_ALIGNMENT - ( xWantedSize & portBYTE_ALIGNMENT_MASK ) ); 83 | } 84 | } 85 | #endif 86 | 87 | vTaskSuspendAll(); 88 | { 89 | if( pucAlignedHeap == NULL ) 90 | { 91 | /* Ensure the heap starts on a correctly aligned boundary. */ 92 | pucAlignedHeap = ( uint8_t * ) ( ( ( portPOINTER_SIZE_TYPE ) &ucHeap[ portBYTE_ALIGNMENT ] ) & ( ~( ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK ) ) ); 93 | } 94 | 95 | /* Check there is enough room left for the allocation. */ 96 | if( ( ( xNextFreeByte + xWantedSize ) < configADJUSTED_HEAP_SIZE ) && 97 | ( ( xNextFreeByte + xWantedSize ) > xNextFreeByte ) )/* Check for overflow. */ 98 | { 99 | /* Return the next free byte then increment the index past this 100 | block. */ 101 | pvReturn = pucAlignedHeap + xNextFreeByte; 102 | xNextFreeByte += xWantedSize; 103 | } 104 | 105 | traceMALLOC( pvReturn, xWantedSize ); 106 | } 107 | ( void ) xTaskResumeAll(); 108 | 109 | #if( configUSE_MALLOC_FAILED_HOOK == 1 ) 110 | { 111 | if( pvReturn == NULL ) 112 | { 113 | extern void vApplicationMallocFailedHook( void ); 114 | vApplicationMallocFailedHook(); 115 | } 116 | } 117 | #endif 118 | 119 | return pvReturn; 120 | } 121 | /*-----------------------------------------------------------*/ 122 | 123 | void vPortFree( void *pv ) 124 | { 125 | /* Memory cannot be freed using this scheme. See heap_2.c, heap_3.c and 126 | heap_4.c for alternative implementations, and the memory management pages of 127 | http://www.FreeRTOS.org for more information. */ 128 | ( void ) pv; 129 | 130 | /* Force an assert as it is invalid to call this function. */ 131 | configASSERT( pv == NULL ); 132 | } 133 | /*-----------------------------------------------------------*/ 134 | 135 | void vPortInitialiseBlocks( void ) 136 | { 137 | /* Only required when static memory is not cleared. */ 138 | xNextFreeByte = ( size_t ) 0; 139 | } 140 | /*-----------------------------------------------------------*/ 141 | 142 | size_t xPortGetFreeHeapSize( void ) 143 | { 144 | return ( configADJUSTED_HEAP_SIZE - xNextFreeByte ); 145 | } 146 | 147 | 148 | 149 | -------------------------------------------------------------------------------- /libraries/FreeRTOS/portable/MemMang/heap_3.c: -------------------------------------------------------------------------------- 1 | /* 2 | * FreeRTOS Kernel V10.0.0 3 | * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | * this software and associated documentation files (the "Software"), to deal in 7 | * the Software without restriction, including without limitation the rights to 8 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | * the Software, and to permit persons to whom the Software is furnished to do so, 10 | * subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all 13 | * copies or substantial portions of the Software. If you wish to use our Amazon 14 | * FreeRTOS name, please do so in a fair use way that does not cause confusion. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 18 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 19 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 20 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | * 23 | * http://www.FreeRTOS.org 24 | * http://aws.amazon.com/freertos 25 | * 26 | * 1 tab == 4 spaces! 27 | */ 28 | 29 | 30 | /* 31 | * Implementation of pvPortMalloc() and vPortFree() that relies on the 32 | * compilers own malloc() and free() implementations. 33 | * 34 | * This file can only be used if the linker is configured to to generate 35 | * a heap memory area. 36 | * 37 | * See heap_1.c, heap_2.c and heap_4.c for alternative implementations, and the 38 | * memory management pages of http://www.FreeRTOS.org for more information. 39 | */ 40 | 41 | #include 42 | 43 | /* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining 44 | all the API functions to use the MPU wrappers. That should only be done when 45 | task.h is included from an application file. */ 46 | #define MPU_WRAPPERS_INCLUDED_FROM_API_FILE 47 | 48 | #include "FreeRTOS.h" 49 | #include "task.h" 50 | 51 | #undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE 52 | 53 | #if( configSUPPORT_DYNAMIC_ALLOCATION == 0 ) 54 | #error This file must not be used if configSUPPORT_DYNAMIC_ALLOCATION is 0 55 | #endif 56 | 57 | /*-----------------------------------------------------------*/ 58 | 59 | void *pvPortMalloc( size_t xWantedSize ) 60 | { 61 | void *pvReturn; 62 | 63 | vTaskSuspendAll(); 64 | { 65 | pvReturn = malloc( xWantedSize ); 66 | traceMALLOC( pvReturn, xWantedSize ); 67 | } 68 | ( void ) xTaskResumeAll(); 69 | 70 | #if( configUSE_MALLOC_FAILED_HOOK == 1 ) 71 | { 72 | if( pvReturn == NULL ) 73 | { 74 | extern void vApplicationMallocFailedHook( void ); 75 | vApplicationMallocFailedHook(); 76 | } 77 | } 78 | #endif 79 | 80 | return pvReturn; 81 | } 82 | /*-----------------------------------------------------------*/ 83 | 84 | void vPortFree( void *pv ) 85 | { 86 | if( pv ) 87 | { 88 | vTaskSuspendAll(); 89 | { 90 | free( pv ); 91 | traceFREE( pv, 0 ); 92 | } 93 | ( void ) xTaskResumeAll(); 94 | } 95 | } 96 | 97 | 98 | 99 | -------------------------------------------------------------------------------- /libraries/FreeRTOS/portable/readme.txt: -------------------------------------------------------------------------------- 1 | Each real time kernel port consists of three files that contain the core kernel 2 | components and are common to every port, and one or more files that are 3 | specific to a particular microcontroller and/or compiler. 4 | 5 | 6 | + The FreeRTOS/Source/Portable/MemMang directory contains the five sample 7 | memory allocators as described on the http://www.FreeRTOS.org WEB site. 8 | 9 | + The other directories each contain files specific to a particular 10 | microcontroller or compiler, where the directory name denotes the compiler 11 | specific files the directory contains. 12 | 13 | 14 | 15 | For example, if you are interested in the [compiler] port for the [architecture] 16 | microcontroller, then the port specific files are contained in 17 | FreeRTOS/Source/Portable/[compiler]/[architecture] directory. If this is the 18 | only port you are interested in then all the other directories can be 19 | ignored. 20 | 21 | -------------------------------------------------------------------------------- /libraries/FreeRTOS/readme.txt: -------------------------------------------------------------------------------- 1 | Each real time kernel port consists of three files that contain the core kernel 2 | components and are common to every port, and one or more files that are 3 | specific to a particular microcontroller and or compiler. 4 | 5 | + The FreeRTOS/Source directory contains the three files that are common to 6 | every port - list.c, queue.c and tasks.c. The kernel is contained within these 7 | three files. croutine.c implements the optional co-routine functionality - which 8 | is normally only used on very memory limited systems. 9 | 10 | + The FreeRTOS/Source/Portable directory contains the files that are specific to 11 | a particular microcontroller and or compiler. 12 | 13 | + The FreeRTOS/Source/include directory contains the real time kernel header 14 | files. 15 | 16 | See the readme file in the FreeRTOS/Source/Portable directory for more 17 | information. -------------------------------------------------------------------------------- /libraries/STM32F10x_StdPeriph_Driver/inc/stm32f10x_crc.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f10x_crc.h 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 11-March-2011 7 | * @brief This file contains all the functions prototypes for the CRC firmware 8 | * library. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 13 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 14 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 15 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 16 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 17 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 18 | * 19 | *

© COPYRIGHT 2011 STMicroelectronics

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

© COPYRIGHT 2011 STMicroelectronics

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

© COPYRIGHT 2011 STMicroelectronics

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

© COPYRIGHT 2011 STMicroelectronics

20 | ****************************************************************************** 21 | */ 22 | 23 | /* Define to prevent recursive inclusion -------------------------------------*/ 24 | #ifndef __STM32F10x_PWR_H 25 | #define __STM32F10x_PWR_H 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | /* Includes ------------------------------------------------------------------*/ 32 | #include "stm32f10x.h" 33 | 34 | /** @addtogroup STM32F10x_StdPeriph_Driver 35 | * @{ 36 | */ 37 | 38 | /** @addtogroup PWR 39 | * @{ 40 | */ 41 | 42 | /** @defgroup PWR_Exported_Types 43 | * @{ 44 | */ 45 | 46 | /** 47 | * @} 48 | */ 49 | 50 | /** @defgroup PWR_Exported_Constants 51 | * @{ 52 | */ 53 | 54 | /** @defgroup PVD_detection_level 55 | * @{ 56 | */ 57 | 58 | #define PWR_PVDLevel_2V2 ((uint32_t)0x00000000) 59 | #define PWR_PVDLevel_2V3 ((uint32_t)0x00000020) 60 | #define PWR_PVDLevel_2V4 ((uint32_t)0x00000040) 61 | #define PWR_PVDLevel_2V5 ((uint32_t)0x00000060) 62 | #define PWR_PVDLevel_2V6 ((uint32_t)0x00000080) 63 | #define PWR_PVDLevel_2V7 ((uint32_t)0x000000A0) 64 | #define PWR_PVDLevel_2V8 ((uint32_t)0x000000C0) 65 | #define PWR_PVDLevel_2V9 ((uint32_t)0x000000E0) 66 | #define IS_PWR_PVD_LEVEL(LEVEL) (((LEVEL) == PWR_PVDLevel_2V2) || ((LEVEL) == PWR_PVDLevel_2V3)|| \ 67 | ((LEVEL) == PWR_PVDLevel_2V4) || ((LEVEL) == PWR_PVDLevel_2V5)|| \ 68 | ((LEVEL) == PWR_PVDLevel_2V6) || ((LEVEL) == PWR_PVDLevel_2V7)|| \ 69 | ((LEVEL) == PWR_PVDLevel_2V8) || ((LEVEL) == PWR_PVDLevel_2V9)) 70 | /** 71 | * @} 72 | */ 73 | 74 | /** @defgroup Regulator_state_is_STOP_mode 75 | * @{ 76 | */ 77 | 78 | #define PWR_Regulator_ON ((uint32_t)0x00000000) 79 | #define PWR_Regulator_LowPower ((uint32_t)0x00000001) 80 | #define IS_PWR_REGULATOR(REGULATOR) (((REGULATOR) == PWR_Regulator_ON) || \ 81 | ((REGULATOR) == PWR_Regulator_LowPower)) 82 | /** 83 | * @} 84 | */ 85 | 86 | /** @defgroup STOP_mode_entry 87 | * @{ 88 | */ 89 | 90 | #define PWR_STOPEntry_WFI ((uint8_t)0x01) 91 | #define PWR_STOPEntry_WFE ((uint8_t)0x02) 92 | #define IS_PWR_STOP_ENTRY(ENTRY) (((ENTRY) == PWR_STOPEntry_WFI) || ((ENTRY) == PWR_STOPEntry_WFE)) 93 | 94 | /** 95 | * @} 96 | */ 97 | 98 | /** @defgroup PWR_Flag 99 | * @{ 100 | */ 101 | 102 | #define PWR_FLAG_WU ((uint32_t)0x00000001) 103 | #define PWR_FLAG_SB ((uint32_t)0x00000002) 104 | #define PWR_FLAG_PVDO ((uint32_t)0x00000004) 105 | #define IS_PWR_GET_FLAG(FLAG) (((FLAG) == PWR_FLAG_WU) || ((FLAG) == PWR_FLAG_SB) || \ 106 | ((FLAG) == PWR_FLAG_PVDO)) 107 | 108 | #define IS_PWR_CLEAR_FLAG(FLAG) (((FLAG) == PWR_FLAG_WU) || ((FLAG) == PWR_FLAG_SB)) 109 | /** 110 | * @} 111 | */ 112 | 113 | /** 114 | * @} 115 | */ 116 | 117 | /** @defgroup PWR_Exported_Macros 118 | * @{ 119 | */ 120 | 121 | /** 122 | * @} 123 | */ 124 | 125 | /** @defgroup PWR_Exported_Functions 126 | * @{ 127 | */ 128 | 129 | void PWR_DeInit(void); 130 | void PWR_BackupAccessCmd(FunctionalState NewState); 131 | void PWR_PVDCmd(FunctionalState NewState); 132 | void PWR_PVDLevelConfig(uint32_t PWR_PVDLevel); 133 | void PWR_WakeUpPinCmd(FunctionalState NewState); 134 | void PWR_EnterSTOPMode(uint32_t PWR_Regulator, uint8_t PWR_STOPEntry); 135 | void PWR_EnterSTANDBYMode(void); 136 | FlagStatus PWR_GetFlagStatus(uint32_t PWR_FLAG); 137 | void PWR_ClearFlag(uint32_t PWR_FLAG); 138 | 139 | #ifdef __cplusplus 140 | } 141 | #endif 142 | 143 | #endif /* __STM32F10x_PWR_H */ 144 | /** 145 | * @} 146 | */ 147 | 148 | /** 149 | * @} 150 | */ 151 | 152 | /** 153 | * @} 154 | */ 155 | 156 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 157 | -------------------------------------------------------------------------------- /libraries/STM32F10x_StdPeriph_Driver/inc/stm32f10x_rtc.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f10x_rtc.h 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 11-March-2011 7 | * @brief This file contains all the functions prototypes for the RTC firmware 8 | * library. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 13 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 14 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 15 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 16 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 17 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 18 | * 19 | *

© COPYRIGHT 2011 STMicroelectronics

20 | ****************************************************************************** 21 | */ 22 | 23 | /* Define to prevent recursive inclusion -------------------------------------*/ 24 | #ifndef __STM32F10x_RTC_H 25 | #define __STM32F10x_RTC_H 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | /* Includes ------------------------------------------------------------------*/ 32 | #include "stm32f10x.h" 33 | 34 | /** @addtogroup STM32F10x_StdPeriph_Driver 35 | * @{ 36 | */ 37 | 38 | /** @addtogroup RTC 39 | * @{ 40 | */ 41 | 42 | /** @defgroup RTC_Exported_Types 43 | * @{ 44 | */ 45 | 46 | /** 47 | * @} 48 | */ 49 | 50 | /** @defgroup RTC_Exported_Constants 51 | * @{ 52 | */ 53 | 54 | /** @defgroup RTC_interrupts_define 55 | * @{ 56 | */ 57 | 58 | #define RTC_IT_OW ((uint16_t)0x0004) /*!< Overflow interrupt */ 59 | #define RTC_IT_ALR ((uint16_t)0x0002) /*!< Alarm interrupt */ 60 | #define RTC_IT_SEC ((uint16_t)0x0001) /*!< Second interrupt */ 61 | #define IS_RTC_IT(IT) ((((IT) & (uint16_t)0xFFF8) == 0x00) && ((IT) != 0x00)) 62 | #define IS_RTC_GET_IT(IT) (((IT) == RTC_IT_OW) || ((IT) == RTC_IT_ALR) || \ 63 | ((IT) == RTC_IT_SEC)) 64 | /** 65 | * @} 66 | */ 67 | 68 | /** @defgroup RTC_interrupts_flags 69 | * @{ 70 | */ 71 | 72 | #define RTC_FLAG_RTOFF ((uint16_t)0x0020) /*!< RTC Operation OFF flag */ 73 | #define RTC_FLAG_RSF ((uint16_t)0x0008) /*!< Registers Synchronized flag */ 74 | #define RTC_FLAG_OW ((uint16_t)0x0004) /*!< Overflow flag */ 75 | #define RTC_FLAG_ALR ((uint16_t)0x0002) /*!< Alarm flag */ 76 | #define RTC_FLAG_SEC ((uint16_t)0x0001) /*!< Second flag */ 77 | #define IS_RTC_CLEAR_FLAG(FLAG) ((((FLAG) & (uint16_t)0xFFF0) == 0x00) && ((FLAG) != 0x00)) 78 | #define IS_RTC_GET_FLAG(FLAG) (((FLAG) == RTC_FLAG_RTOFF) || ((FLAG) == RTC_FLAG_RSF) || \ 79 | ((FLAG) == RTC_FLAG_OW) || ((FLAG) == RTC_FLAG_ALR) || \ 80 | ((FLAG) == RTC_FLAG_SEC)) 81 | #define IS_RTC_PRESCALER(PRESCALER) ((PRESCALER) <= 0xFFFFF) 82 | 83 | /** 84 | * @} 85 | */ 86 | 87 | /** 88 | * @} 89 | */ 90 | 91 | /** @defgroup RTC_Exported_Macros 92 | * @{ 93 | */ 94 | 95 | /** 96 | * @} 97 | */ 98 | 99 | /** @defgroup RTC_Exported_Functions 100 | * @{ 101 | */ 102 | 103 | void RTC_ITConfig(uint16_t RTC_IT, FunctionalState NewState); 104 | void RTC_EnterConfigMode(void); 105 | void RTC_ExitConfigMode(void); 106 | uint32_t RTC_GetCounter(void); 107 | void RTC_SetCounter(uint32_t CounterValue); 108 | void RTC_SetPrescaler(uint32_t PrescalerValue); 109 | void RTC_SetAlarm(uint32_t AlarmValue); 110 | uint32_t RTC_GetDivider(void); 111 | void RTC_WaitForLastTask(void); 112 | void RTC_WaitForSynchro(void); 113 | FlagStatus RTC_GetFlagStatus(uint16_t RTC_FLAG); 114 | void RTC_ClearFlag(uint16_t RTC_FLAG); 115 | ITStatus RTC_GetITStatus(uint16_t RTC_IT); 116 | void RTC_ClearITPendingBit(uint16_t RTC_IT); 117 | 118 | #ifdef __cplusplus 119 | } 120 | #endif 121 | 122 | #endif /* __STM32F10x_RTC_H */ 123 | /** 124 | * @} 125 | */ 126 | 127 | /** 128 | * @} 129 | */ 130 | 131 | /** 132 | * @} 133 | */ 134 | 135 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 136 | -------------------------------------------------------------------------------- /libraries/STM32F10x_StdPeriph_Driver/inc/stm32f10x_wwdg.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f10x_wwdg.h 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 11-March-2011 7 | * @brief This file contains all the functions prototypes for the WWDG firmware 8 | * library. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 13 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 14 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 15 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 16 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 17 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 18 | * 19 | *

© COPYRIGHT 2011 STMicroelectronics

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

© COPYRIGHT 2011 STMicroelectronics

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

© COPYRIGHT 2011 STMicroelectronics

19 | ****************************************************************************** 20 | */ 21 | 22 | /* Includes ------------------------------------------------------------------*/ 23 | #include "stm32f10x_dbgmcu.h" 24 | 25 | /** @addtogroup STM32F10x_StdPeriph_Driver 26 | * @{ 27 | */ 28 | 29 | /** @defgroup DBGMCU 30 | * @brief DBGMCU driver modules 31 | * @{ 32 | */ 33 | 34 | /** @defgroup DBGMCU_Private_TypesDefinitions 35 | * @{ 36 | */ 37 | 38 | /** 39 | * @} 40 | */ 41 | 42 | /** @defgroup DBGMCU_Private_Defines 43 | * @{ 44 | */ 45 | 46 | #define IDCODE_DEVID_MASK ((uint32_t)0x00000FFF) 47 | /** 48 | * @} 49 | */ 50 | 51 | /** @defgroup DBGMCU_Private_Macros 52 | * @{ 53 | */ 54 | 55 | /** 56 | * @} 57 | */ 58 | 59 | /** @defgroup DBGMCU_Private_Variables 60 | * @{ 61 | */ 62 | 63 | /** 64 | * @} 65 | */ 66 | 67 | /** @defgroup DBGMCU_Private_FunctionPrototypes 68 | * @{ 69 | */ 70 | 71 | /** 72 | * @} 73 | */ 74 | 75 | /** @defgroup DBGMCU_Private_Functions 76 | * @{ 77 | */ 78 | 79 | /** 80 | * @brief Returns the device revision identifier. 81 | * @param None 82 | * @retval Device revision identifier 83 | */ 84 | uint32_t DBGMCU_GetREVID(void) 85 | { 86 | return(DBGMCU->IDCODE >> 16); 87 | } 88 | 89 | /** 90 | * @brief Returns the device identifier. 91 | * @param None 92 | * @retval Device identifier 93 | */ 94 | uint32_t DBGMCU_GetDEVID(void) 95 | { 96 | return(DBGMCU->IDCODE & IDCODE_DEVID_MASK); 97 | } 98 | 99 | /** 100 | * @brief Configures the specified peripheral and low power mode behavior 101 | * when the MCU under Debug mode. 102 | * @param DBGMCU_Periph: specifies the peripheral and low power mode. 103 | * This parameter can be any combination of the following values: 104 | * @arg DBGMCU_SLEEP: Keep debugger connection during SLEEP mode 105 | * @arg DBGMCU_STOP: Keep debugger connection during STOP mode 106 | * @arg DBGMCU_STANDBY: Keep debugger connection during STANDBY mode 107 | * @arg DBGMCU_IWDG_STOP: Debug IWDG stopped when Core is halted 108 | * @arg DBGMCU_WWDG_STOP: Debug WWDG stopped when Core is halted 109 | * @arg DBGMCU_TIM1_STOP: TIM1 counter stopped when Core is halted 110 | * @arg DBGMCU_TIM2_STOP: TIM2 counter stopped when Core is halted 111 | * @arg DBGMCU_TIM3_STOP: TIM3 counter stopped when Core is halted 112 | * @arg DBGMCU_TIM4_STOP: TIM4 counter stopped when Core is halted 113 | * @arg DBGMCU_CAN1_STOP: Debug CAN2 stopped when Core is halted 114 | * @arg DBGMCU_I2C1_SMBUS_TIMEOUT: I2C1 SMBUS timeout mode stopped when Core is halted 115 | * @arg DBGMCU_I2C2_SMBUS_TIMEOUT: I2C2 SMBUS timeout mode stopped when Core is halted 116 | * @arg DBGMCU_TIM5_STOP: TIM5 counter stopped when Core is halted 117 | * @arg DBGMCU_TIM6_STOP: TIM6 counter stopped when Core is halted 118 | * @arg DBGMCU_TIM7_STOP: TIM7 counter stopped when Core is halted 119 | * @arg DBGMCU_TIM8_STOP: TIM8 counter stopped when Core is halted 120 | * @arg DBGMCU_CAN2_STOP: Debug CAN2 stopped when Core is halted 121 | * @arg DBGMCU_TIM15_STOP: TIM15 counter stopped when Core is halted 122 | * @arg DBGMCU_TIM16_STOP: TIM16 counter stopped when Core is halted 123 | * @arg DBGMCU_TIM17_STOP: TIM17 counter stopped when Core is halted 124 | * @arg DBGMCU_TIM9_STOP: TIM9 counter stopped when Core is halted 125 | * @arg DBGMCU_TIM10_STOP: TIM10 counter stopped when Core is halted 126 | * @arg DBGMCU_TIM11_STOP: TIM11 counter stopped when Core is halted 127 | * @arg DBGMCU_TIM12_STOP: TIM12 counter stopped when Core is halted 128 | * @arg DBGMCU_TIM13_STOP: TIM13 counter stopped when Core is halted 129 | * @arg DBGMCU_TIM14_STOP: TIM14 counter stopped when Core is halted 130 | * @param NewState: new state of the specified peripheral in Debug mode. 131 | * This parameter can be: ENABLE or DISABLE. 132 | * @retval None 133 | */ 134 | void DBGMCU_Config(uint32_t DBGMCU_Periph, FunctionalState NewState) 135 | { 136 | /* Check the parameters */ 137 | assert_param(IS_DBGMCU_PERIPH(DBGMCU_Periph)); 138 | assert_param(IS_FUNCTIONAL_STATE(NewState)); 139 | 140 | if (NewState != DISABLE) 141 | { 142 | DBGMCU->CR |= DBGMCU_Periph; 143 | } 144 | else 145 | { 146 | DBGMCU->CR &= ~DBGMCU_Periph; 147 | } 148 | } 149 | 150 | /** 151 | * @} 152 | */ 153 | 154 | /** 155 | * @} 156 | */ 157 | 158 | /** 159 | * @} 160 | */ 161 | 162 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 163 | -------------------------------------------------------------------------------- /libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_flash.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beckus/stm32_p103_demos/4a369e92a57d2e539aa6160f0c0a50de17cad895/libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_flash.c -------------------------------------------------------------------------------- /libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_i2c.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beckus/stm32_p103_demos/4a369e92a57d2e539aa6160f0c0a50de17cad895/libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_i2c.c -------------------------------------------------------------------------------- /libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_iwdg.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f10x_iwdg.c 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 11-March-2011 7 | * @brief This file provides all the IWDG firmware functions. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2011 STMicroelectronics

19 | ****************************************************************************** 20 | */ 21 | 22 | /* Includes ------------------------------------------------------------------*/ 23 | #include "stm32f10x_iwdg.h" 24 | 25 | /** @addtogroup STM32F10x_StdPeriph_Driver 26 | * @{ 27 | */ 28 | 29 | /** @defgroup IWDG 30 | * @brief IWDG driver modules 31 | * @{ 32 | */ 33 | 34 | /** @defgroup IWDG_Private_TypesDefinitions 35 | * @{ 36 | */ 37 | 38 | /** 39 | * @} 40 | */ 41 | 42 | /** @defgroup IWDG_Private_Defines 43 | * @{ 44 | */ 45 | 46 | /* ---------------------- IWDG registers bit mask ----------------------------*/ 47 | 48 | /* KR register bit mask */ 49 | #define KR_KEY_Reload ((uint16_t)0xAAAA) 50 | #define KR_KEY_Enable ((uint16_t)0xCCCC) 51 | 52 | /** 53 | * @} 54 | */ 55 | 56 | /** @defgroup IWDG_Private_Macros 57 | * @{ 58 | */ 59 | 60 | /** 61 | * @} 62 | */ 63 | 64 | /** @defgroup IWDG_Private_Variables 65 | * @{ 66 | */ 67 | 68 | /** 69 | * @} 70 | */ 71 | 72 | /** @defgroup IWDG_Private_FunctionPrototypes 73 | * @{ 74 | */ 75 | 76 | /** 77 | * @} 78 | */ 79 | 80 | /** @defgroup IWDG_Private_Functions 81 | * @{ 82 | */ 83 | 84 | /** 85 | * @brief Enables or disables write access to IWDG_PR and IWDG_RLR registers. 86 | * @param IWDG_WriteAccess: new state of write access to IWDG_PR and IWDG_RLR registers. 87 | * This parameter can be one of the following values: 88 | * @arg IWDG_WriteAccess_Enable: Enable write access to IWDG_PR and IWDG_RLR registers 89 | * @arg IWDG_WriteAccess_Disable: Disable write access to IWDG_PR and IWDG_RLR registers 90 | * @retval None 91 | */ 92 | void IWDG_WriteAccessCmd(uint16_t IWDG_WriteAccess) 93 | { 94 | /* Check the parameters */ 95 | assert_param(IS_IWDG_WRITE_ACCESS(IWDG_WriteAccess)); 96 | IWDG->KR = IWDG_WriteAccess; 97 | } 98 | 99 | /** 100 | * @brief Sets IWDG Prescaler value. 101 | * @param IWDG_Prescaler: specifies the IWDG Prescaler value. 102 | * This parameter can be one of the following values: 103 | * @arg IWDG_Prescaler_4: IWDG prescaler set to 4 104 | * @arg IWDG_Prescaler_8: IWDG prescaler set to 8 105 | * @arg IWDG_Prescaler_16: IWDG prescaler set to 16 106 | * @arg IWDG_Prescaler_32: IWDG prescaler set to 32 107 | * @arg IWDG_Prescaler_64: IWDG prescaler set to 64 108 | * @arg IWDG_Prescaler_128: IWDG prescaler set to 128 109 | * @arg IWDG_Prescaler_256: IWDG prescaler set to 256 110 | * @retval None 111 | */ 112 | void IWDG_SetPrescaler(uint8_t IWDG_Prescaler) 113 | { 114 | /* Check the parameters */ 115 | assert_param(IS_IWDG_PRESCALER(IWDG_Prescaler)); 116 | IWDG->PR = IWDG_Prescaler; 117 | } 118 | 119 | /** 120 | * @brief Sets IWDG Reload value. 121 | * @param Reload: specifies the IWDG Reload value. 122 | * This parameter must be a number between 0 and 0x0FFF. 123 | * @retval None 124 | */ 125 | void IWDG_SetReload(uint16_t Reload) 126 | { 127 | /* Check the parameters */ 128 | assert_param(IS_IWDG_RELOAD(Reload)); 129 | IWDG->RLR = Reload; 130 | } 131 | 132 | /** 133 | * @brief Reloads IWDG counter with value defined in the reload register 134 | * (write access to IWDG_PR and IWDG_RLR registers disabled). 135 | * @param None 136 | * @retval None 137 | */ 138 | void IWDG_ReloadCounter(void) 139 | { 140 | IWDG->KR = KR_KEY_Reload; 141 | } 142 | 143 | /** 144 | * @brief Enables IWDG (write access to IWDG_PR and IWDG_RLR registers disabled). 145 | * @param None 146 | * @retval None 147 | */ 148 | void IWDG_Enable(void) 149 | { 150 | IWDG->KR = KR_KEY_Enable; 151 | } 152 | 153 | /** 154 | * @brief Checks whether the specified IWDG flag is set or not. 155 | * @param IWDG_FLAG: specifies the flag to check. 156 | * This parameter can be one of the following values: 157 | * @arg IWDG_FLAG_PVU: Prescaler Value Update on going 158 | * @arg IWDG_FLAG_RVU: Reload Value Update on going 159 | * @retval The new state of IWDG_FLAG (SET or RESET). 160 | */ 161 | FlagStatus IWDG_GetFlagStatus(uint16_t IWDG_FLAG) 162 | { 163 | FlagStatus bitstatus = RESET; 164 | /* Check the parameters */ 165 | assert_param(IS_IWDG_FLAG(IWDG_FLAG)); 166 | if ((IWDG->SR & IWDG_FLAG) != (uint32_t)RESET) 167 | { 168 | bitstatus = SET; 169 | } 170 | else 171 | { 172 | bitstatus = RESET; 173 | } 174 | /* Return the flag status */ 175 | return bitstatus; 176 | } 177 | 178 | /** 179 | * @} 180 | */ 181 | 182 | /** 183 | * @} 184 | */ 185 | 186 | /** 187 | * @} 188 | */ 189 | 190 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 191 | -------------------------------------------------------------------------------- /libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_usart.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beckus/stm32_p103_demos/4a369e92a57d2e539aa6160f0c0a50de17cad895/libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_usart.c -------------------------------------------------------------------------------- /openocd/README: -------------------------------------------------------------------------------- 1 | SETTING UP OPENOCD AND THE JTAG PROGRAMMER 2 | This depends heavily on what operating system you are using. If you do an 3 | Internet search, you should be able to find many examples. 4 | 5 | 6 | CONNECTING TO BOARD: 7 | Notes: 8 | - If you want to view the OpenOCD configuration scripts, they are installed in 9 | /usr/local/share/openocd/scripts 10 | - When I first tried programming the board, I had problems. I got it working 11 | through some trial-and-error, but I am not sure exactly what was wrong. I 12 | think it was mostly issues with write protectiong and locking. 13 | - When debugging, it is normal to get this error from OpenOCD: 14 | Error: address + size wrapped(0xffffffff, 0x00000004) 15 | 16 | To connect to the device (assumes the JTAG programmer is plugged connected to 17 | your PC and board, and that the board is powered up). You will need to choose 18 | the appropriate interface cfg script for your programmer: 19 | openocd -f interface/olimex-arm-usb-tiny-h.cfg -f target/stm32f1x.cfg 20 | 21 | Then in another command prompt, connect to the OpenOCD daemon: 22 | telnet localhost 4444 23 | 24 | As a general rule, you must halt before running commands: 25 | reset halt 26 | 27 | To view the flash banks (the STM32-P103 microcontroller should only have a 28 | bank #0): 29 | flash banks 30 | 31 | To view the bank info: 32 | flash probe 0 33 | 34 | To view the sectors in the bank (particular usefuly to check write protect 35 | status): 36 | flash info 0 37 | 38 | To check the option bytes: 39 | stm32f1x options_read 0 40 | 41 | To unlock: 42 | stm32f1x unlock 0 43 | 44 | To disable write protect (afterwards, "flash info 0" still shows the memory as 45 | protected - you need to do a "reset halt" before it shows the new status): 46 | flash protect 0 0 last off 47 | 48 | To check erase state of the sectors: 49 | flash erase_check 0 50 | 51 | To program: 52 | flash erase_sector 0 0 last 53 | flash write_bank 0 main.bin 0 54 | reset run 55 | 56 | 57 | 58 | debug: 59 | Start daemon: 60 | openocd -f openocd_stm32_p103_dbg.cfg 61 | 62 | arm-none-eabi-gdb 63 | file stm32_p103_blink_flash_asm.elf 64 | target remote localhost:3333 65 | monitor reset halt 66 | break main.c:46 67 | -------------------------------------------------------------------------------- /openocd/openocd_stm32_p103.cfg: -------------------------------------------------------------------------------- 1 | # Set WORKAREASIZE based on RAM size of 20kb 2 | set WORKAREASIZE 0x4fff 3 | source [find target/stm32f1x.cfg] 4 | 5 | proc init_stm32 {} { 6 | init 7 | reset halt 8 | adapter_khz 1500 9 | } 10 | 11 | proc program_flash {bin_file} { 12 | init_stm32 13 | wait_halt 14 | flash erase_sector 0 0 last 15 | flash write_bank 0 $bin_file 0 16 | reset run 17 | shutdown 18 | } 19 | 20 | --------------------------------------------------------------------------------