2017-04-05 12:04:25 +08:00
|
|
|
// stm32flash -e 255 -w blink.hex -v /dev/ttyUSB0
|
|
|
|
|
2017-03-26 18:16:39 +08:00
|
|
|
|
2017-04-04 02:51:08 +08:00
|
|
|
#include "stm32l031xx.h"
|
|
|
|
|
2017-04-05 12:04:25 +08:00
|
|
|
volatile unsigned long SysTickCount = 0;
|
|
|
|
|
|
|
|
void __attribute__ ((interrupt, used)) SysTick_Handler(void)
|
|
|
|
{
|
|
|
|
SysTickCount++;
|
|
|
|
|
|
|
|
if ( SysTickCount & 1 )
|
|
|
|
GPIOA->BSRR = GPIO_BSRR_BS_13; /* atomic set PA13 */
|
|
|
|
else
|
|
|
|
GPIOA->BSRR = GPIO_BSRR_BR_13; /* atomic clr PA13 */
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-03-26 18:16:39 +08:00
|
|
|
int main()
|
|
|
|
{
|
2017-04-05 12:04:25 +08:00
|
|
|
|
2017-04-04 02:51:08 +08:00
|
|
|
//RCC->CFGR &=
|
|
|
|
RCC->IOPENR |= RCC_IOPENR_IOPAEN; /* Enable clock for GPIO Port A */
|
|
|
|
__NOP();
|
|
|
|
__NOP();
|
2017-04-05 12:04:25 +08:00
|
|
|
|
|
|
|
|
2017-04-04 02:51:08 +08:00
|
|
|
|
|
|
|
GPIOA->MODER &= ~GPIO_MODER_MODE13; /* clear mode for PA13 */
|
2017-04-05 12:04:25 +08:00
|
|
|
GPIOA->MODER |= GPIO_MODER_MODE13_0; /* Output mode for PA13 */
|
2017-04-04 02:51:08 +08:00
|
|
|
GPIOA->OTYPER &= ~GPIO_OTYPER_OT_13; /* no Push/Pull for PA13 */
|
|
|
|
GPIOA->OSPEEDR &= ~GPIO_OSPEEDER_OSPEED13; /* low speed for PA13 */
|
|
|
|
GPIOA->PUPDR &= ~GPIO_PUPDR_PUPD13; /* no pullup/pulldown for PA13 */
|
|
|
|
//GPIOA->BSRR = GPIO_BSRR_BS_13; /* atomic set PA13 */
|
|
|
|
GPIOA->BSRR = GPIO_BSRR_BR_13; /* atomic clr PA13 */
|
2017-04-05 12:04:25 +08:00
|
|
|
|
|
|
|
//SysTick->LOAD = (SystemCoreClock/1000UL*(unsigned long)SYS_TICK_PERIOD_IN_MS) - 1;
|
|
|
|
SysTick->LOAD = 2000*500 - 1;
|
|
|
|
SysTick->VAL = 0;
|
|
|
|
SysTick->CTRL = 7; /* enable, generate interrupt (SysTick_Handler), do not divide by 2 */
|
|
|
|
|
2017-04-04 02:51:08 +08:00
|
|
|
|
|
|
|
for(;;)
|
|
|
|
;
|
2017-03-26 18:16:39 +08:00
|
|
|
}
|