finish blink tests

This commit is contained in:
Mariano Alvira 2010-02-24 13:35:37 -05:00
parent f79c71153a
commit 289a839161
5 changed files with 40 additions and 31 deletions

View file

@ -4,12 +4,20 @@
#define GPIO_PAD_DIR0 ((volatile uint32_t *) 0x80000000) #define GPIO_PAD_DIR0 ((volatile uint32_t *) 0x80000000)
#define GPIO_PAD_DIR0 ((volatile uint32_t *) 0x80000000) #define GPIO_PAD_DIR0 ((volatile uint32_t *) 0x80000000)
#define GPIO_PAD_DIR1 ((volatile uint32_t *) 0x80000004)
#define GPIO_DATA0 ((volatile uint32_t *) 0x80000008) #define GPIO_DATA0 ((volatile uint32_t *) 0x80000008)
#define GPIO_FUNC_SEL0 ((volatile uint32_t *) 0x80000018) /* GPIO 15 - 0; 2 bit blocks */ #define GPIO_DATA1 ((volatile uint32_t *) 0x8000000c)
#define GPIO_PAD_PU_SEL0 ((volatile uint32_t *) 0x80000030)
#define GPIO_PAD_PU_SEL1 ((volatile uint32_t *) 0x80000034)
#define GPIO_PAD_PU_EN0 ((volatile uint32_t *) 0x80000010) #define GPIO_PAD_PU_EN0 ((volatile uint32_t *) 0x80000010)
#define GPIO_PAD_PU_EN1 ((volatile uint32_t *) 0x80000014) #define GPIO_PAD_PU_EN1 ((volatile uint32_t *) 0x80000014)
#define GPIO_FUNC_SEL0 ((volatile uint32_t *) 0x80000018) /* GPIO 15 - 0; 2 bit blocks */
#define GPIO_FUNC_SEL1 ((volatile uint32_t *) 0x8000001c) /* GPIO 16 - 31; 2 bit blocks */
#define GPIO_FUNC_SEL2 ((volatile uint32_t *) 0x80000020) /* GPIO 32 - 47; 2 bit blocks */
#define GPIO_FUNC_SEL3 ((volatile uint32_t *) 0x80000024) /* GPIO 48 - 63; 2 bit blocks */
#define GPIO_DATA_SEL0 ((volatile uint32_t *) 0x80000028)
#define GPIO_DATA_SEL1 ((volatile uint32_t *) 0x8000002c)
#define GPIO_PAD_PU_SEL0 ((volatile uint32_t *) 0x80000030)
#define GPIO_PAD_PU_SEL1 ((volatile uint32_t *) 0x80000034)
/* select pullup or pulldown for GPIO 0-31 (b=0-31) */ /* select pullup or pulldown for GPIO 0-31 (b=0-31) */
#define gpio_sel0_pullup(b) (set_bit(reg32(GPIO_PAD_PU_SEL0),b)) #define gpio_sel0_pullup(b) (set_bit(reg32(GPIO_PAD_PU_SEL0),b))

View file

@ -0,0 +1,13 @@
#ifndef UTILS_H
#define UTILS_H
#include <stdint.h>
#define CAT2(x, y, z) x##y##z
#define bit(bit) (1 << bit)
#define bit_is_set(val, bit) (((val & (1 << bit)) >> bit) == 1)
#define clear_bit(val, bit) (val = (val & ~(1 << bit)))
#define set_bit(val, bit) (val = (val | (1 << bit)))
#endif /* UTILS_H */

View file

@ -1,6 +1,6 @@
MC1322X := .. MC1322X := ..
TARGETS := blink-red blink-green blink-blue TARGETS := blink-red blink-green blink-blue blink-white blink-allio
include $(MC1322X)/Makefile.include include $(MC1322X)/Makefile.include

View file

@ -1,43 +1,29 @@
#define MBAR_GPIO 0x80000000 #include <mc1322x.h>
#define GPIO_FUNC_SEL0 0x80000018 /* GPIO 15 - 0; 2 bit blocks */ #include <board.h>
#define GPIO_FUNC_SEL1 0x8000001c
#define GPIO_FUNC_SEL2 0x80000020
#define GPIO_FUNC_SEL3 0x80000024
#define GPIO_PAD_DIR0 0x80000000
#define GPIO_DATA0 0x80000008
#define GPIO_PAD_DIR1 0x80000004
#define GPIO_DATA1 0x8000000c
#define UART1_DATA 0x80005008
#define DELAY 400000 #define DELAY 400000
#include "embedded_types.h"
#include "isr.h"
#include "led.h"
#define LED_BITS LED_WHITE
__attribute__ ((section ("startup")))
void main(void) { void main(void) {
*(volatile uint32_t *)GPIO_FUNC_SEL0 = 0xffffffff; *GPIO_FUNC_SEL0 = 0xffffffff;
*(volatile uint32_t *)GPIO_FUNC_SEL1 = 0xffffffff; *GPIO_FUNC_SEL1 = 0xffffffff;
*(volatile uint32_t *)GPIO_FUNC_SEL2 = 0xffffffff; *GPIO_FUNC_SEL2 = 0xffffffff;
*(volatile uint32_t *)GPIO_FUNC_SEL3 = 0xffffffff; *GPIO_FUNC_SEL3 = 0xffffffff;
*(volatile uint32_t *)GPIO_PAD_DIR0 = 0xffffffff; *GPIO_PAD_DIR0 = 0xffffffff;
*(volatile uint32_t *)GPIO_PAD_DIR1 = 0xffffffff; *GPIO_PAD_DIR1 = 0xffffffff;
volatile uint32_t i; volatile uint32_t i;
while(1) { while(1) {
*(volatile uint32_t *)GPIO_DATA0 = 0xffffffff; *GPIO_DATA0 = 0xffffffff;
*(volatile uint32_t *)GPIO_DATA1 = 0xffffffff; *GPIO_DATA1 = 0xffffffff;
for(i=0; i<DELAY; i++) { continue; } for(i=0; i<DELAY; i++) { continue; }
*(volatile uint32_t *)GPIO_DATA0 = 0x00000000; *GPIO_DATA0 = 0x00000000;
*(volatile uint32_t *)GPIO_DATA1 = 0x00000000; *GPIO_DATA1 = 0x00000000;
for(i=0; i<DELAY; i++) { continue; } for(i=0; i<DELAY; i++) { continue; }

View file

@ -1,6 +1,8 @@
#include <mc1322x.h> #include <mc1322x.h>
#include <board.h> #include <board.h>
#include "led.h"
#define DELAY 400000 #define DELAY 400000
#define LED_BITS LED_WHITE #define LED_BITS LED_WHITE