2020-11-23 21:48:35 -05:00
|
|
|
/* blink.c -- user LED blink
|
2021-03-03 02:17:56 -05:00
|
|
|
** Copyright (c) 2020-2021 Renaud Fivet
|
2020-11-23 21:48:35 -05:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* Memory locations defined by linker script */
|
2021-03-03 02:17:56 -05:00
|
|
|
void __StackTop( void) ; /* __StackTop points after end of stack */
|
2020-11-23 21:48:35 -05:00
|
|
|
void Reset_Handler( void) ; /* Entry point for execution */
|
|
|
|
|
|
|
|
/* Interrupt vector table:
|
|
|
|
* 1 Stack Pointer reset value
|
|
|
|
* 15 System Exceptions
|
|
|
|
* NN Device specific Interrupts
|
|
|
|
*/
|
|
|
|
typedef void (*isr_p)( void) ;
|
|
|
|
isr_p const isr_vector[ 2] __attribute__((section(".isr_vector"))) = {
|
2021-03-03 02:17:56 -05:00
|
|
|
__StackTop,
|
2020-11-23 21:48:35 -05:00
|
|
|
/* System Exceptions */
|
|
|
|
Reset_Handler
|
|
|
|
} ;
|
|
|
|
|
|
|
|
#define RCC ((volatile long *) 0x40021000)
|
|
|
|
#define RCC_AHBENR RCC[ 5]
|
|
|
|
#define RCC_AHBENR_IOPBEN 0x00040000 /* 18: I/O port B clock enable */
|
|
|
|
|
|
|
|
#define GPIOB ((volatile long *) 0x48000400)
|
|
|
|
#define GPIOB_MODER GPIOB[ 0]
|
|
|
|
#define GPIOB_ODR GPIOB[ 5]
|
|
|
|
|
|
|
|
void Reset_Handler( void) {
|
|
|
|
int delay ;
|
|
|
|
|
|
|
|
/* User LED ON */
|
|
|
|
RCC_AHBENR |= RCC_AHBENR_IOPBEN ; /* Enable IOPB periph */
|
|
|
|
GPIOB_MODER |= 1 << (1 * 2) ; /* PB1 Output [01], over default 00 */
|
|
|
|
/* OTYPER Push-Pull by default */
|
|
|
|
/* PB1 output default LOW at reset */
|
|
|
|
|
|
|
|
/* User LED blink */
|
|
|
|
for( ;;) {
|
|
|
|
for( delay = 1000000 ; delay ; delay--) ; /* delay between toggling */
|
|
|
|
GPIOB_ODR ^= 1 << 1 ; /* toggle PB1 (User LED) */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* end of blink.c */
|