1
0
mirror of git://projects.qi-hardware.com/f32xbase.git synced 2024-11-23 23:15:55 +02:00

Support different targets. (Openmoko GTA01/02 with Dbgv3, soon c2ben.)

- f32x/Makefile: added support for building for different targets (for now,
  just TARGET=om)
- f32x/c2-drv.h: interface for C2 drivers
- f32x/c2-om.c: updated title
- f32x/c2-om.c: renamed all c2_* to om_* and made them "static"
- f32x/c2-om.c (c2_om): driver operations
- f32x/c2.c: call driver operations
- f32x/c2.h: moved protocol constants to c2-drv.h
This commit is contained in:
Werner Almesberger 2010-10-21 10:03:42 -03:00
parent ab35c6b518
commit de75051afa
5 changed files with 146 additions and 26 deletions

View File

@ -1,8 +1,8 @@
#
# f32x/Makefile - Build the C8051F326/7 Flash programmer
#
# Written 2008 by Werner Almesberger
# Copyright 2008 Werner Almesberger
# Written 2008, 2010 by Werner Almesberger
# Copyright 2008, 2010 Werner Almesberger
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -11,15 +11,26 @@
#
CC=arm-angstrom-linux-gnueabi-gcc
CFLAGS=-Wall -Wshadow -g -O
LDFLAGS=
PREFIX=/usr
NAME=f32x
OBJS=f32x.o flash.o c2-om.o gpio.o rt.o boundary.o
ifeq ($(TARGET),)
TARGET = om
endif
CC_om = arm-angstrom-linux-gnueabi-gcc
CFLAGS_om = -O -DDRIVER=c2_om
LDFLAGS_om =
OBJS_om = c2-om.o gpio.o rt.o
NAME = f32x
CC = $(CC_$(TARGET))
CFLAGS = -Wall -Wshadow -g $(CFLAGS_$(TARGET))
LDFLAGS = $(LDFLAGS_$(TARGET))
OBJS = f32x.o flash.o c2.o boundary.o $(OBJS_$(TARGET))
.PHONY: all install uninstall clean depend spotless
@ -45,7 +56,7 @@ include .depend
endif
clean:
rm -f $(OBJS) .depend
rm -f $(OBJS) $(OBJS_om) .depend
spotless: clean
rm -f $(NAME)

36
f32x/c2-drv.h Normal file
View File

@ -0,0 +1,36 @@
/*
* f32x/c2-drv.h - C2 driver interface
*
* Written 2010 by Werner Almesberger
* Copyright 2010 Werner Almesberger
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*/
#ifndef C2_DRV_H
#define C2_DRV_H
#include <stdint.h>
#define C2_DATA_READ 0
#define C2_DATA_WRITE 1
#define C2_ADDR_READ 2
#define C2_ADDR_WRITE 3
struct c2_ops {
void (*init)(void);
void (*reset)(void);
void (*addr_write)(uint8_t addr);
uint8_t (*addr_read)(void);
void (*data_write)(uint32_t data, int bytes);
uint32_t (*data_read)(int bytes) ;
};
#endif /* !C2_DRV_H */

View File

@ -1,8 +1,8 @@
/*
* f32x/c2.c - Basic C2 messages
* f32x/c2-om.c - Basic C2 messages, driver for Openmoko GTA01/GTA02+DebugV3
*
* Written 2008 by Werner Almesberger
* Copyright 2008 Werner Almesberger
* Written 2008, 2010 by Werner Almesberger
* Copyright 2008, 2010 Werner Almesberger
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -15,7 +15,7 @@
#include <unistd.h>
#include "gpio.h"
#include "c2.h"
#include "c2-drv.h"
/*
@ -64,7 +64,7 @@ static uint32_t c2_recv(int bits)
/* ----- C2 Register read/write -------------------------------------------- */
void c2_addr_write(uint8_t addr)
static void om_addr_write(uint8_t addr)
{
c2_pulse();
gpio_output(C2D);
@ -75,7 +75,7 @@ void c2_addr_write(uint8_t addr)
}
uint8_t c2_addr_read(void)
static uint8_t om_addr_read(void)
{
c2_pulse();
gpio_output(C2D);
@ -86,7 +86,7 @@ uint8_t c2_addr_read(void)
}
void c2_data_write(uint32_t data, int bytes)
static void om_data_write(uint32_t data, int bytes)
{
c2_pulse();
gpio_output(C2D);
@ -99,7 +99,7 @@ void c2_data_write(uint32_t data, int bytes)
}
uint32_t c2_data_read(int bytes)
static uint32_t om_data_read(int bytes)
{
c2_pulse();
gpio_output(C2D);
@ -115,7 +115,7 @@ uint32_t c2_data_read(int bytes)
/* ----- C2 initialization ------------------------------------------------- */
void c2_init(void)
static void om_init(void)
{
gpio_init();
gpio_input(C2D);
@ -127,7 +127,7 @@ void c2_init(void)
}
void c2_reset(void)
static void om_reset(void)
{
gpio_input(C2D);
gpio_low(C2CK);
@ -136,3 +136,16 @@ void c2_reset(void)
gpio_output(C2CK);
gpio_high(C2CK);
}
/* ----- Operations -------------------------------------------------------- */
struct c2_ops c2_om = {
.init = om_init,
.reset = om_reset,
.addr_write = om_addr_write,
.addr_read = om_addr_read,
.data_write = om_data_write,
.data_read = om_data_read,
};

66
f32x/c2.c Normal file
View File

@ -0,0 +1,66 @@
/*
* f32x/c2.c - Basic C2 messages
*
* Written 2010 by Werner Almesberger
* Copyright 2010 Werner Almesberger
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*/
#include <stdint.h>
#include "c2.h"
#include "c2-drv.h"
static struct c2_ops *c2_ops;
/* ----- C2 Register read/write -------------------------------------------- */
void c2_addr_write(uint8_t addr)
{
c2_ops->addr_write(addr);
}
uint8_t c2_addr_read(void)
{
return c2_ops->addr_read();
}
void c2_data_write(uint32_t data, int bytes)
{
c2_ops->data_write(data, bytes);
}
uint32_t c2_data_read(int bytes)
{
return c2_ops->data_read(bytes);
}
/* ----- C2 initialization ------------------------------------------------- */
void c2_init(void)
{
extern struct c2_ops DRIVER;
c2_ops = &DRIVER;
if (c2_ops->init)
c2_ops->init();
}
void c2_reset(void)
{
c2_ops->reset();
}

View File

@ -18,12 +18,6 @@
#include <stdint.h>
#define C2_DATA_READ 0
#define C2_DATA_WRITE 1
#define C2_ADDR_READ 2
#define C2_ADDR_WRITE 3
void c2_addr_write(uint8_t addr);
uint8_t c2_addr_read(void);
void c2_data_write(uint32_t data, int bytes);