Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
jitomesky
authored and
jitomesky
committed
Mar 14, 2014
1 parent
00d8d50
commit 735c492
Showing
292 changed files
with
508,169 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
CROSS= arm-unknown-eabi- | ||
|
||
CC= $(CROSS)gcc | ||
LD= $(CROSS)ld | ||
OBJCOPY= $(CROSS)objcopy | ||
OBJDUMP= $(CROSS)objdump | ||
SIZE= $(CROSS)size | ||
READELF= $(CROSS)readelf | ||
|
||
# libgcc.a | ||
LIBS = -L/home/jitomesky/cross/rpi/arm-unknown-eabi/lib/gcc/arm-unknown-eabi/4.8.1/ | ||
# newlib | ||
LIBS += -L/home/jitomesky/cross/rpi/arm-unknown-eabi/arm-unknown-eabi/lib/ | ||
STARTUP= startup.o | ||
OBJS= main.o | ||
|
||
# systemcall | ||
OBJS += syscalls.o | ||
|
||
# RaspberryPi library | ||
OBJS+= rpi_lib/rpi_init.o rpi_lib/gpio/gpio.o rpi_lib/timer/timer.o rpi_lib/delay/delay.o | ||
OBJS+= rpi_lib/serial/serial.o | ||
OBJS+= rpi_lib/bss/clearbss.o | ||
|
||
CFLAGS= -mfloat-abi=soft -mlittle-endian | ||
CFLAGS+= -nostartfiles | ||
CFLAGS+= -ffreestanding | ||
CFLAGS+= -O0 -g3 | ||
|
||
######################## | ||
all: rpi-micon.img | ||
|
||
rpi-micon.elf: $(STARTUP) $(OBJS) | ||
$(LD) -static -nostartfiles -T rpiMicon.lds $^ -o $@ $(LIBS) -lc -lgcc | ||
$(OBJDUMP) -D rpi-micon.elf > rpi-micon.disas | ||
$(SIZE) rpi-micon.elf > rpi-micon.size | ||
$(READELF) -a rpi-micon.elf > rpi-micon.readelf | ||
|
||
.SUFFIXES: .elf .img | ||
|
||
.elf.img: | ||
$(OBJCOPY) -O binary $< $@ | ||
.c.o: | ||
$(CC) $(CFLAGS) -c $< -o $@ | ||
.S.o: | ||
$(CC) $(CFLAGS) -c $< -o $@ | ||
|
||
clean:: | ||
$(RM) -f *.o *.img *.elf */*.o */*/*.o | ||
$(RM) -f tags *~ | ||
|
||
tags:: | ||
ctags *.[chS] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
#include "rpi_lib/rpi.h" | ||
#include <stdio.h> | ||
#include <stdint.h> | ||
|
||
|
||
#define BSC1_BASE (0x00804000) | ||
#define BSC1_C ((vu32_t *)PHY_PERI_ADDR(BSC1_BASE + 0x00)) | ||
#define BSC1_S ((vu32_t *)PHY_PERI_ADDR(BSC1_BASE + 0x04)) | ||
#define BSC1_DLEN ((vu32_t *)PHY_PERI_ADDR(BSC1_BASE + 0x08)) | ||
#define BSC1_A ((vu32_t *)PHY_PERI_ADDR(BSC1_BASE + 0x0C)) | ||
#define BSC1_FIFO ((vu32_t *)PHY_PERI_ADDR(BSC1_BASE + 0x10)) | ||
#define BSC1_DIV ((vu32_t *)PHY_PERI_ADDR(BSC1_BASE + 0x14)) | ||
#define BSC1_DEL ((vu32_t *)PHY_PERI_ADDR(BSC1_BASE + 0x18)) | ||
#define BSC1_CLKT ((vu32_t *)PHY_PERI_ADDR(BSC1_BASE + 0x1C)) | ||
|
||
// I2C(BSC) Concrol MASK(use OR MASK) | ||
#define BSC_C_I2CEN_EN ((vu32_t)0x01 << 15) | ||
#define BSC_C_ST_EN ((vu32_t)0x01 << 7) | ||
#define BSC_C_CLEAR_ALL ((vu32_t)0x03 << 4) | ||
#define BSC_C_READ_READ ((vu32_t)0x01) | ||
|
||
// I2C(BSC) Status MASK | ||
#define BSC_S_CLKT ((vu32_t)0x01 << 9) | ||
#define BSC_S_ERR ((vu32_t)0x01 << 8) | ||
#define BSC_S_RXF ((vu32_t)0x01 << 7) | ||
#define BSC_S_TXE ((vu32_t)0x01 << 6) | ||
#define BSC_S_RXD ((vu32_t)0x01 << 5) | ||
#define BSC_S_TXD ((vu32_t)0x01 << 4) | ||
#define BSC_S_RXR ((vu32_t)0x01 << 3) | ||
#define BSC_S_TXW ((vu32_t)0x01 << 2) | ||
#define BSC_S_DONE ((vu32_t)0x01 << 1) | ||
#define BSC_S_TA ((vu32_t)0x01 << 0) | ||
|
||
// LCD | ||
#define AQM0802_ADDR (0x7C) | ||
|
||
|
||
int main(void){ | ||
rpi_init(); | ||
|
||
// I2C init | ||
// port setting | ||
pinMode(2, ALT0); // SDA | ||
pinMode(3, ALT0); // SCL | ||
// set I2C clock divider | ||
// SCL = 150[MHz] / 32768 = 4.58[kHz] | ||
*BSC1_DIV = 0; | ||
|
||
// LCD init start | ||
// 送信準備 | ||
// Clear Status | ||
*BSC1_S = BSC_S_CLKT | BSC_S_ERR | BSC_S_DONE; | ||
// slave address | ||
*BSC1_A = AQM0802_ADDR >> 1; | ||
// Write mode | ||
*BSC1_C &= ~BSC_C_READ_READ; | ||
// Buffer clear | ||
*BSC1_C |= BSC_C_CLEAR_ALL; | ||
// 送信データ長設定 | ||
*BSC1_DLEN = 2*9; | ||
|
||
// set data | ||
*BSC1_FIFO = 0x80; // Co=1,RS=0 | ||
*BSC1_FIFO = 0x38; // Function Set | ||
*BSC1_FIFO = 0x80; // Co=1,RS=0 | ||
*BSC1_FIFO = 0x39; // Function Set | ||
*BSC1_FIFO = 0x80; // Co=1,RS=0 | ||
*BSC1_FIFO = 0x14; // Internal OSC frequency | ||
*BSC1_FIFO = 0x80; // Co=1,RS=0 | ||
*BSC1_FIFO = 0x70; // Contrast Set | ||
*BSC1_FIFO = 0x80; // Co=1,RS=0 | ||
*BSC1_FIFO = 0x56; // Power/ICON/Contrast | ||
*BSC1_FIFO = 0x80; // Co=1,RS=0 | ||
*BSC1_FIFO = 0x6C; // Follower control | ||
|
||
// transfer start | ||
*BSC1_C |= BSC_C_I2CEN_EN | BSC_C_ST_EN; | ||
|
||
delay(250); | ||
|
||
// 送信バッファが空いているか確認 | ||
while(!(*BSC1_S & BSC_S_TXW)); | ||
*BSC1_FIFO = 0x80; // Co=1,RS=0 | ||
*BSC1_FIFO = 0x38; // Function Set | ||
// 送信バッファが空いているか確認 | ||
while(!(*BSC1_S & BSC_S_TXW)); | ||
*BSC1_FIFO = 0x80; // Co=1,RS=0 | ||
*BSC1_FIFO = 0x0C; // Display ON/OFF | ||
// 送信バッファが空いているか確認 | ||
while(!(*BSC1_S & BSC_S_TXW)); | ||
*BSC1_FIFO = 0x80; // Co=1,RS=0 | ||
*BSC1_FIFO = 0x01; // Display Clear | ||
|
||
// 転送終了待ち | ||
// 1 = Transfer complete | ||
while(!(*BSC1_S & BSC_S_DONE)); | ||
// transfer end | ||
// LCD init end | ||
|
||
delay(200); | ||
|
||
// print "Hello" | ||
// 送信準備 | ||
// Clear Status | ||
*BSC1_S = BSC_S_CLKT | BSC_S_ERR | BSC_S_DONE; | ||
// slave address | ||
*BSC1_A = AQM0802_ADDR >> 1; | ||
// Write mode | ||
*BSC1_C |= BSC_C_READ_WRITE; | ||
// Buffer clear | ||
*BSC1_C |= BSC_C_CLEAR_ALL; | ||
// 送信データ長設定 | ||
*BSC1_DLEN = 8; | ||
|
||
// send data | ||
*BSC1_FIFO = 0x80; // Co=1,RS=0 | ||
*BSC1_FIFO = 0x80 | 0x00; //set DDRAM address | ||
*BSC1_FIFO = 0x40; // Co=0,RS=1 | ||
*BSC1_FIFO = 'H'; | ||
*BSC1_FIFO = 'e'; | ||
*BSC1_FIFO = 'l'; | ||
*BSC1_FIFO = 'l'; | ||
*BSC1_FIFO = 'o'; | ||
|
||
// transfer start | ||
*BSC1_C |= BSC_C_I2CEN_EN | BSC_C_ST_EN; | ||
|
||
// 転送終了待ち | ||
// 1 = Transfer complete | ||
while(!(*BSC1_S & BSC_S_DONE)); | ||
// transfer end | ||
|
||
// I2C通信終了 | ||
*BSC1_C &= ~BSC_C_I2CEN_EN; | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
|
||
# Broadcom 2835 on Raspberry Pi | ||
|
||
telnet_port 4444 | ||
#gdb_port 0 | ||
#tcl_port 0 | ||
|
||
#jtag_khz 1000 | ||
adapter_khz 1000 | ||
|
||
#jtag_nsrst_delay 400 | ||
#jtag_ntrst_delay 400 | ||
|
||
if { [info exists CHIPNAME] } { | ||
set _CHIPNAME $CHIPNAME | ||
} else { | ||
set _CHIPNAME raspi | ||
} | ||
|
||
reset_config none | ||
|
||
if { [info exists CPU_TAPID ] } { | ||
set _CPU_TAPID $CPU_TAPID | ||
} else { | ||
set _CPU_TAPID 0x07b7617F | ||
} | ||
jtag newtap $_CHIPNAME arm -irlen 5 -expected-id $_CPU_TAPID | ||
|
||
set _TARGETNAME $_CHIPNAME.arm | ||
target create $_TARGETNAME arm11 -chain-position $_TARGETNAME | ||
|
Oops, something went wrong.