Started with implementation of pin_create
This commit is contained in:
33
src/io.s
33
src/io.s
@@ -6,6 +6,39 @@
|
|||||||
//R0: address to pin struct, R1: address to GPIO, R2: pinnr (1 byte). No return value
|
//R0: address to pin struct, R1: address to GPIO, R2: pinnr (1 byte). No return value
|
||||||
pin_create:
|
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<<pinnr; // Insert the pinmask
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//TODO: Implement
|
//TODO: Implement
|
||||||
|
|
||||||
end_pin_create:
|
end_pin_create:
|
||||||
|
|||||||
Reference in New Issue
Block a user