From 627e5732a8d596dafce7cd1e2c5cdc7d62152459 Mon Sep 17 00:00:00 2001 From: T-moe Date: Sun, 31 Jan 2016 17:42:37 +0100 Subject: [PATCH] Started with implementation of pin_create --- src/io.s | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/io.s b/src/io.s index af8d622..fae5132 100644 --- a/src/io.s +++ b/src/io.s @@ -6,6 +6,39 @@ //R0: address to pin struct, R1: address to GPIO, R2: pinnr (1 byte). No return value pin_create: + .set OFFSET_MODR, 0 + .set OFFSET_OTYPER, 0x4 + .set OFFSET_PUPDR, 0xC + .set GPIO_MODE_IN, 0 + + MOV r5, #3 //r5 = 3 + LSL r4, r2, #1 //r4 = pinnr*2 + LSL r5, r5, r4 //r5 = 3 << (pinnr*2) + + //GPIO->MODER &=~ ( 3 << (pinnr*2)); //Clear the 2 bits (mode) + LDR r3, [r1, #OFFSET_MODR] //r3 = GPIO->MODR + BIC r3, r3, r5 //r3 &= ~r5 + + //GPIO->MODER |= GPIO_Mode_IN << (pinnr*2); //Set the correct bits for mode + MOV r5, #GPIO_MODE_IN + LSL r5, r5, r4 //r5 = GPIO_MODE_IN << (pinnr*2) + ORR r3, r3, r5 //r3 |= r5 + STR r3, [r1, #OFFSET_MODR] //GPIO->MODR = r3 + + //GPIO->OTYPER &=~ (1 << (pinnr*2)); //Clear the bit (otype) + + + //GPIO->OTYPER |= GPIO_OType_OD <<(pinnr*2); //set the correct bit for otype +/* + GPIO->PUPDR &=~ (3 <<(pinnr*2)); //clear the 2 bits (pp/od) + GPIO->PUPDR |= GPIO_PuPd_UP <<(pinnr*2); //set the correct bits for pp/od + + pin->GPIO=GPIO; // Set the gpiopin in the pin structure + pin->pinmask=0x01<