Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: STM32F3-Discovery
main.c@1:5d95bdb46dfd, 2018-04-19 (annotated)
- Committer:
- MartinJohnson
- Date:
- Thu Apr 19 00:03:02 2018 +0000
- Revision:
- 1:5d95bdb46dfd
- Parent:
- 0:699994a61048
- Child:
- 2:366bad33b2bd
Make it run forever and remove commented out line
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
MartinJohnson | 0:699994a61048 | 1 | |
MartinJohnson | 0:699994a61048 | 2 | #include <stm32f3_discovery.h> |
MartinJohnson | 0:699994a61048 | 3 | |
MartinJohnson | 0:699994a61048 | 4 | volatile unsigned sysTiming; |
MartinJohnson | 0:699994a61048 | 5 | volatile unsigned sysTicks = 0; |
MartinJohnson | 0:699994a61048 | 6 | |
MartinJohnson | 0:699994a61048 | 7 | void SysTick_Handler(void) { |
MartinJohnson | 0:699994a61048 | 8 | sysTicks++; |
MartinJohnson | 0:699994a61048 | 9 | if (sysTiming > 0) --sysTiming; |
MartinJohnson | 0:699994a61048 | 10 | } |
MartinJohnson | 0:699994a61048 | 11 | |
MartinJohnson | 0:699994a61048 | 12 | void sysDelayMs(unsigned dly) { |
MartinJohnson | 0:699994a61048 | 13 | sysTiming = dly; |
MartinJohnson | 0:699994a61048 | 14 | while (sysTiming > 0) __wfi(); |
MartinJohnson | 0:699994a61048 | 15 | |
MartinJohnson | 0:699994a61048 | 16 | } |
MartinJohnson | 0:699994a61048 | 17 | |
MartinJohnson | 0:699994a61048 | 18 | int main(void) { |
MartinJohnson | 0:699994a61048 | 19 | |
MartinJohnson | 0:699994a61048 | 20 | SysTick_Config((SystemCoreClock / 1000)); |
MartinJohnson | 0:699994a61048 | 21 | RCC->AHBENR |= RCC_AHBPeriph_GPIOE | RCC_AHBPeriph_GPIOA; |
MartinJohnson | 0:699994a61048 | 22 | GPIOE->MODER = (GPIOE->MODER&0xffff) | 0x55550000; // output mode for PE8-15 |
MartinJohnson | 0:699994a61048 | 23 | GPIOA->MODER = (GPIOA->MODER&0xfffffffc) ; // input mode for PA0 |
MartinJohnson | 0:699994a61048 | 24 | |
MartinJohnson | 0:699994a61048 | 25 | GPIOE->BSRR=0xff00; |
MartinJohnson | 0:699994a61048 | 26 | sysDelayMs(500); |
MartinJohnson | 0:699994a61048 | 27 | int b=0; |
MartinJohnson | 1:5d95bdb46dfd | 28 | while(1) { |
MartinJohnson | 0:699994a61048 | 29 | GPIOE->BSRR=1<<(b+8); |
MartinJohnson | 0:699994a61048 | 30 | while(GPIOA->IDR&1); |
MartinJohnson | 0:699994a61048 | 31 | sysDelayMs(100); |
MartinJohnson | 0:699994a61048 | 32 | GPIOE->BSRR=1<<(b+8+16); |
MartinJohnson | 0:699994a61048 | 33 | b=(b+1)%8; |
MartinJohnson | 0:699994a61048 | 34 | } |
MartinJohnson | 0:699994a61048 | 35 | } |
MartinJohnson | 0:699994a61048 | 36 | |
MartinJohnson | 0:699994a61048 | 37 |