Dream Team / Mbed 2 deprecated Lab1_BasicIO

Dependencies:   DebounceIn mbed PinDetect

Committer:
Jesse Baker
Date:
Sun Jan 24 16:45:15 2016 -0500
Revision:
53:1c8235c49b70
Parent:
47:0efd125c7f2d
JB is about to test expansion

Who changed what in which revision?

UserRevisionLine numberNew contents of line
gtzintzarov3 47:0efd125c7f2d 1 AREA asm_func, CODE, READONLY
gtzintzarov3 47:0efd125c7f2d 2 ; Export my_asm function location so that C compiler can find it and link
gtzintzarov3 47:0efd125c7f2d 3 EXPORT my_asm
gtzintzarov3 47:0efd125c7f2d 4 my_asm
gtzintzarov3 47:0efd125c7f2d 5 ;
gtzintzarov3 47:0efd125c7f2d 6 ; ARM Assembly language function to set LED1 bit to a value passed from C
gtzintzarov3 47:0efd125c7f2d 7 ; LED1 gets value (passed from C compiler in R0)
gtzintzarov3 47:0efd125c7f2d 8 ; LED1 is on GPIO port 1 bit 18
gtzintzarov3 47:0efd125c7f2d 9 ; See Chapter 9 in the LPC1768 User Manual
gtzintzarov3 47:0efd125c7f2d 10 ; for all of the GPIO register info and addresses
gtzintzarov3 47:0efd125c7f2d 11 ; Pinnames.h has the mbed modules pin port and bit connections
gtzintzarov3 47:0efd125c7f2d 12 ;
gtzintzarov3 47:0efd125c7f2d 13 ; Load GPIO Port 1 base address in register R1
gtzintzarov3 47:0efd125c7f2d 14 LDR R1, =0x2009C000 ; 0x2009C020 = GPIO port 1 base address
gtzintzarov3 47:0efd125c7f2d 15 ; Move bit mask in register R2 for bit 18 only
gtzintzarov3 47:0efd125c7f2d 16 MOV.W R2, #0x00000010 ; 0x040000 = 1<<18 all "0"s with a "1" in bit 18
gtzintzarov3 47:0efd125c7f2d 17 ; value passed from C compiler code is in R0 - compare to a "0"
gtzintzarov3 47:0efd125c7f2d 18 CMP R0, #0 ; value == 0 ?
gtzintzarov3 47:0efd125c7f2d 19 ; (If-Then-Else) on next two instructions using equal cond from the zero flag
gtzintzarov3 47:0efd125c7f2d 20 ITE EQ
gtzintzarov3 47:0efd125c7f2d 21 ; STORE if EQ - clear led 1 port bit using GPIO FIOCLR register and mask
gtzintzarov3 47:0efd125c7f2d 22 STREQ R2, [R1,#0x1C] ; if==0, clear LED1 bit
gtzintzarov3 47:0efd125c7f2d 23 ; STORE if NE - set led 1 port bit using GPIO FIOSET register and mask
gtzintzarov3 47:0efd125c7f2d 24 STRNE R2, [R1,#0x18] ; if==1, set LED1 bit
gtzintzarov3 47:0efd125c7f2d 25 ; Return to C using link register (Branch indirect using LR - a return)
gtzintzarov3 47:0efd125c7f2d 26 BX LR
gtzintzarov3 47:0efd125c7f2d 27 END
gtzintzarov3 47:0efd125c7f2d 28