Initial commit

This commit is contained in:
Andreas Mieke 2018-03-15 14:34:23 +01:00
commit 1f0e2aad64
64 changed files with 2531 additions and 0 deletions

View file

@ -0,0 +1,49 @@
AREA BLINKEN, CODE, READONLY
INCLUDE STM32_F103RB_MEM_MAP.INC
EXPORT __main
__main PROC
BL init_port
LDR R1, =GPIOB_ODR
_main_again LDR R0, [R1]
EOR R0, R0, #0x100
STR R0, [R1]
BL wait_500ms
B _main_again
ENDP
init_port PROC
PUSH {R0-R2, LR}
MOV R2, #0x8
LDR R1, =RCC_APB2ENR
LDR R0, [R1]
ORR R0, R0, R2
STR R0, [R1]
LDR R1, =GPIOB_CRH
LDR R0, [R1]
LDR R2, =0xFFFFFFF0
AND R0, R0, R2
MOV R2, #0x03
ORR R0, R0, R2
STR R0, [R1]
POP {R0-R2, PC}
ENDP
wait_500ms PROC
PUSH {R0-R2, LR}
MOV R0, #0x1F4
MOV R1, #0
_wait_ms_loop MOV R2, #0x63B
_wait_ms_loop1 SUB R2, R2, #1
CMP R2, R1
BNE _wait_ms_loop1
SUB R0, R0, #1
CMP R0, R1
BNE _wait_ms_loop
POP {R0-R2, PC}
ENDP
END

View file

@ -0,0 +1,77 @@
#include <stm32f10x.h>
void wait(void);
void init_leds_switches(void);
void set_leds(char value);
char get_switches(void);
void wait_ms(int ms);
void init_leds_switches() {
int temp;
RCC->APB2ENR |= RCC_APB2ENR_IOPAEN;
RCC->APB2ENR |= RCC_APB2ENR_IOPBEN;
temp = GPIOA->CRL;
temp &= 0x00000000;
temp |= 0x88888888;
GPIOA->CRL = temp;
GPIOA->BSRR = 0x00FF;
temp = GPIOB->CRH;
temp &= 0x00000000;
temp |= 0x33333333;
GPIOB->CRH = temp;
}
void set_leds(char value) {
GPIOB->ODR = (GPIOB->ODR & 0xFFFF00FF) |
((value & 0x000000FF) <<8);
}
char get_switches() {
return (GPIOA->IDR & 0x000000FF);
}
void wait_ms(int ms) {
int i,j;
for (i = 0; i < ms; i++) {
for (j = 0; j < 1595; j++);
}
}
void wait() {
unsigned char speed;
unsigned char i;
speed = get_switches();
speed = ~speed;
speed = speed & 0x7f;
for (i = 0; i <= speed; i++) {
wait_ms(100);
}
}
int main () {
char i;
char hs;
char lauflicht;
init_leds_switches();
hs = get_switches() & 0x80;
while (hs) {
lauflicht = 0x01;
i = 0;
while (i < 8) {
set_leds(lauflicht);
lauflicht = lauflicht << 1;
i++;
wait();
}
hs = get_switches() & 0x80;
}
while (1);
}

View file

@ -0,0 +1,20 @@
#include "stm32f10x.h"
void init_leds_switches(void) {
RCC->APB2ENR |= RCC_APB2ENR_IOPBEN;
GPIOB->CRH &= 0x00000000;
GPIOB->CRH |= 0x00000003;
}
int main()
{
int i;
init_leds_switches();
for (;;) {
GPIOB->ODR = 0x01FF & ~(GPIOB->ODR & 0x01FF);
for (i=0; i < 65535; i++);
for (i=0; i < 65535; i++);
for (i=0; i < 65535; i++);
}
}