PWM
#file: gpio_d.s .include "macros.inc" .include "src/gpio_regs.inc" SET_TARGET .text FUNCTION gpio_d_init, global // initialize all 16 bits of Port D to outputs push {lr} mov r0,#3 // send 1 as argument to rcc_gpio_enable function bl rcc_gpio_enable // call rcc_gpio_enable ldr r3,=#GPIOD_BASE // load r3 with base address of GPIO PORT D ldr r2,=#0x00000000 // load 0 into r2 str r2,[r3, #GPIO_PUPDR] // write 0 to GPIO Port D PUPD register str r2,[r3, #GPIO_OTYPER] // write 0 to GPIO Port D TYPE register str r2,[r3, #GPIO_ODR] // write 0 to GPIO Port D output data register ldr r2,=#0x55555555 // set all 16 bits of Port D to outputs str r2,[r3, #GPIO_MODER] ldr r2,=#0xffffffff // write 0xffffffff to Port D SPEED register str r2,[r3, #GPIO_OSPEEDR] pop {lr} bx lr ENDFUNC gpio_d_init FUNCTION gpio_d_put, global push {lr} ldr r3,=#GPIOD_BASE str r0,[r3, #GPIO_ODR] pop {lr} bx lr ENDFUNC gpio_d_put FUNCTION gpio_d_get_current, global // get the current state of the 16 Port D outputs push {lr} ldr r3,=#GPIOD_BASE // load r3 with base address of GPIO Port D ldr r0,[r3, #GPIO_ODR] // load r0 (rtn arg) with GPIO Port D output data register pop {lr} bx lr ENDFUNC gpio_d_get_current .end