Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdint.h>
- #include <stddef.h>
- #include "register_def.h"
- #include "inc\hw_memmap.h"
- #include "inc\hw_gpio.h"
- #include "inc\hw_apps_rcm.h"
- #include "inc\hw_ocp_shared.h"
- void delay_1sec(void)
- {
- __asm(" PUSH {r4-r12,lr}");
- __asm(" LDR r4, [pc, #12]");
- __asm(" MOV r5, pc");
- __asm(" NOP");
- __asm(" SUBS r4, #1"); /* 1 instruction cycle */
- __asm(" ITE NEQ"); /* 1 instruction cycle */
- __asm(" MOV pc, r5"); /* 1 + P instructions (where P is between 1 and 3 depending on pipeline refill) */
- __asm(" POP {r4-r12,pc}");
- __asm(" .word 5000000");
- }
- int main(void)
- {
- HWREG(ARCM_BASE + APPS_RCM_O_GPIO_A_CLK_GATING) = 0x01;
- HWREG(OCP_SHARED_BASE + OCP_SHARED_O_GPIO_PAD_CONFIG_9) = 0x60;
- HWREG(OCP_SHARED_BASE + OCP_SHARED_O_GPIO_PAD_CONFIG_10) = 0x60;
- HWREG(OCP_SHARED_BASE + OCP_SHARED_O_GPIO_PAD_CONFIG_11) = 0x60;
- HWREG(GPIOA1_BASE + GPIO_O_GPIO_DIR) = 0x0E;
- HWREG(GPIOA1_BASE + GPIO_O_GPIO_DATA + (0x0E << 2)) = 0x00;
- int index = 0;
- while(1)
- {
- HWREG(GPIOA1_BASE + GPIO_O_GPIO_DATA + (0x0E << 2)) = (index << 1);
- index = (index + 1) % 16;
- delay_1sec();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement