forked from Imagelibrary/rtems
bfin libcpu and libbsp: Fix warnings
This commit is contained in:
@@ -1,14 +1,12 @@
|
|||||||
/**
|
|
||||||
* @file
|
|
||||||
* @ingroup bfin_tll6527m
|
|
||||||
* @brief Global BSP definitions.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file bsp.h
|
* @file bsp.h
|
||||||
|
* @ingroup bfin_tll6527m
|
||||||
|
* @brief Global BSP definitions.
|
||||||
*
|
*
|
||||||
* This include file contains all board IO definitions for TLL6527M.
|
* This include file contains all board IO definitions for TLL6527M.
|
||||||
*
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
* COPYRIGHT (c) 2010 by ECE Northeastern University.
|
* COPYRIGHT (c) 2010 by ECE Northeastern University.
|
||||||
*
|
*
|
||||||
* The license and distribution terms for this file may be
|
* The license and distribution terms for this file may be
|
||||||
@@ -16,10 +14,10 @@
|
|||||||
* http://www.rtems.org/license
|
* http://www.rtems.org/license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef _BSP_H
|
#ifndef _BSP_H
|
||||||
#define _BSP_H
|
#define _BSP_H
|
||||||
|
|
||||||
|
#ifndef ASM
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@@ -95,16 +93,39 @@ extern "C" {
|
|||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
rtems_isr_entry set_vector( ///< @brief returns old vector */
|
/**
|
||||||
rtems_isr_entry handler, ///< @brief isr routine */
|
* @brief Install an interrupt handler
|
||||||
rtems_vector_number vector, ///< @brief vector number */
|
*
|
||||||
int type ///< @brief RTEMS or RAW intr */
|
* This method installs an interrupt handle.
|
||||||
|
*
|
||||||
|
* @param[in] handler is the isr routine
|
||||||
|
* @param[in] vector is the vector number
|
||||||
|
* @param[in] type indicates whether RTEMS or RAW intr
|
||||||
|
*
|
||||||
|
* @return returns old vector
|
||||||
|
*/
|
||||||
|
rtems_isr_entry set_vector(
|
||||||
|
rtems_isr_entry handler,
|
||||||
|
rtems_vector_number vector,
|
||||||
|
int type
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Internal BSP methods that are used across file boundaries
|
||||||
|
*/
|
||||||
|
void Init_RTC(void);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Prototype for methods in .S files that are referenced from C.
|
||||||
|
*/
|
||||||
|
void bfin_null_isr(void);
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif /* !ASM */
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/* bspstart.c for TLL6527M
|
/* bspstart.c for TLL6527M
|
||||||
*
|
*
|
||||||
* This routine does the bulk of the system initialisation.
|
* This routine does the bulk of the system initialization.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -11,7 +11,6 @@
|
|||||||
* http://www.rtems.org/license
|
* http://www.rtems.org/license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <bsp.h>
|
#include <bsp.h>
|
||||||
#include <bsp/bootcard.h>
|
#include <bsp/bootcard.h>
|
||||||
#include <cplb.h>
|
#include <cplb.h>
|
||||||
@@ -61,62 +60,12 @@ const unsigned int _icplbs_table[16][2] = {
|
|||||||
{ 0xffffffff, 0xffffffff }/* end of section - termination */
|
{ 0xffffffff, 0xffffffff }/* end of section - termination */
|
||||||
};
|
};
|
||||||
|
|
||||||
void Init_PLL (void);
|
|
||||||
void Init_EBIU (void);
|
|
||||||
void Init_Flags(void);
|
|
||||||
void Init_RTC (void);
|
|
||||||
void initCPLB(void);
|
|
||||||
|
|
||||||
|
|
||||||
void null_isr(void);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Function: bsp_pretasking_hook
|
|
||||||
* Created: 95/03/10
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* BSP pretasking hook. Called just before drivers are initialized.
|
|
||||||
* Used to setup libc and install any BSP extensions.
|
|
||||||
*
|
|
||||||
* NOTES:
|
|
||||||
* Must not use libc (to do io) from here, since drivers are
|
|
||||||
* not yet initialized.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
void bsp_pretasking_hook(void)
|
|
||||||
{
|
|
||||||
bfin_interrupt_init();
|
|
||||||
}
|
|
||||||
|
|
||||||
void bsp_start( void )
|
|
||||||
{
|
|
||||||
/* BSP Hardware Initialization*/
|
|
||||||
Init_RTC(); /* Blackfin Real Time Clock initialization */
|
|
||||||
Init_PLL(); /* PLL initialization */
|
|
||||||
Init_EBIU(); /* EBIU initialization */
|
|
||||||
Init_Flags(); /* GPIO initialization */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Allocate the memory for the RTEMS Work Space. This can come from
|
|
||||||
* a variety of places: hard coded address, malloc'ed from outside
|
|
||||||
* RTEMS world (e.g. simulator or primitive memory manager), or (as
|
|
||||||
* typically done by stock BSPs) by subtracting the required amount
|
|
||||||
* of work space from the last physical address on the CPU board.
|
|
||||||
*/
|
|
||||||
int i=0;
|
|
||||||
for (i=5;i<16;i++) {
|
|
||||||
set_vector((rtems_isr_entry)null_isr, i, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Init_PLL
|
* Init_PLL
|
||||||
*
|
*
|
||||||
* Routine to initialize the PLL. The TLL6527M uses a 25 Mhz XTAL.
|
* Routine to initialize the PLL. The TLL6527M uses a 25 Mhz XTAL.
|
||||||
*/
|
*/
|
||||||
void Init_PLL (void)
|
static void Init_PLL (void)
|
||||||
{
|
{
|
||||||
unsigned short msel = 0;
|
unsigned short msel = 0;
|
||||||
unsigned short ssel = 0;
|
unsigned short ssel = 0;
|
||||||
@@ -143,8 +92,7 @@ void Init_PLL (void)
|
|||||||
*
|
*
|
||||||
* Configure extern memory
|
* Configure extern memory
|
||||||
*/
|
*/
|
||||||
|
static void Init_EBIU (void)
|
||||||
void Init_EBIU (void)
|
|
||||||
{
|
{
|
||||||
/* Check if SDRAM is already enabled */
|
/* Check if SDRAM is already enabled */
|
||||||
if ( 0 != (*(uint16_t *)EBIU_SDSTAT & EBIU_SDSTAT_SDRS) ){
|
if ( 0 != (*(uint16_t *)EBIU_SDSTAT & EBIU_SDSTAT_SDRS) ){
|
||||||
@@ -165,7 +113,7 @@ void Init_EBIU (void)
|
|||||||
*
|
*
|
||||||
* Enable LEDs port
|
* Enable LEDs port
|
||||||
*/
|
*/
|
||||||
void Init_Flags(void)
|
static void Init_Flags(void)
|
||||||
{
|
{
|
||||||
*((uint16_t*)PORTH_FER) = 0x0;
|
*((uint16_t*)PORTH_FER) = 0x0;
|
||||||
*((uint16_t*)PORTH_MUX) = 0x0;
|
*((uint16_t*)PORTH_MUX) = 0x0;
|
||||||
@@ -173,22 +121,33 @@ void Init_Flags(void)
|
|||||||
*((uint16_t*)PORTHIO_SET) = 0x1<<15;
|
*((uint16_t*)PORTHIO_SET) = 0x1<<15;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* bsp_pretasking_hook
|
||||||
void initCPLB(void) {
|
*/
|
||||||
|
void bsp_pretasking_hook(void)
|
||||||
int i = 0;
|
{
|
||||||
unsigned int *addr;
|
bfin_interrupt_init();
|
||||||
unsigned int *data;
|
|
||||||
|
|
||||||
addr = (unsigned int *)0xffe00100;
|
|
||||||
data = (unsigned int *)0xffe00200;
|
|
||||||
|
|
||||||
while ( dcplbs_table[i][0] != 0xffffffff ) {
|
|
||||||
*addr = dcplbs_table[i][0];
|
|
||||||
*data = dcplbs_table[i][1];
|
|
||||||
|
|
||||||
addr++;
|
|
||||||
data++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void bsp_start( void )
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
/* BSP Hardware Initialization*/
|
||||||
|
Init_RTC(); /* Blackfin Real Time Clock initialization */
|
||||||
|
Init_PLL(); /* PLL initialization */
|
||||||
|
Init_EBIU(); /* EBIU initialization */
|
||||||
|
Init_Flags(); /* GPIO initialization */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Allocate the memory for the RTEMS Work Space. This can come from
|
||||||
|
* a variety of places: hard coded address, malloc'ed from outside
|
||||||
|
* RTEMS world (e.g. simulator or primitive memory manager), or (as
|
||||||
|
* typically done by stock BSPs) by subtracting the required amount
|
||||||
|
* of work space from the last physical address on the CPU board.
|
||||||
|
*/
|
||||||
|
for (i=5;i<16;i++) {
|
||||||
|
set_vector((rtems_isr_entry)bfin_null_isr, i, 1);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
/* Console driver for bf537Stamp
|
/* Console driver for bf537Stamp
|
||||||
*
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
* Copyright (c) 2008 Kallisti Labs, Los Gatos, CA, USA
|
* Copyright (c) 2008 Kallisti Labs, Los Gatos, CA, USA
|
||||||
* written by Allan Hessenflow <allanh@kallisti.com>
|
* written by Allan Hessenflow <allanh@kallisti.com>
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -15,6 +15,8 @@
|
|||||||
#ifndef _BSP_H
|
#ifndef _BSP_H
|
||||||
#define _BSP_H
|
#define _BSP_H
|
||||||
|
|
||||||
|
#ifndef ASM
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
@@ -89,7 +91,9 @@ void setLED(uint8_t value);
|
|||||||
/*
|
/*
|
||||||
* Helper Function to use the EzKits LEDS
|
* Helper Function to use the EzKits LEDS
|
||||||
*/
|
*/
|
||||||
uint8_t getLED(void);
|
uint8_t getLEDs(void);
|
||||||
|
void setLEDs(uint8_t value);
|
||||||
|
uint8_t getButtons(void);
|
||||||
|
|
||||||
rtems_isr_entry set_vector( /* returns old vector */
|
rtems_isr_entry set_vector( /* returns old vector */
|
||||||
rtems_isr_entry handler, /* isr routine */
|
rtems_isr_entry handler, /* isr routine */
|
||||||
@@ -97,6 +101,11 @@ rtems_isr_entry set_vector( /* returns old vector */
|
|||||||
int type /* RTEMS or RAW intr */
|
int type /* RTEMS or RAW intr */
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Internal BSP methods that are used across file boundaries
|
||||||
|
*/
|
||||||
|
void Init_RTC(void);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Network driver configuration
|
* Network driver configuration
|
||||||
*/
|
*/
|
||||||
@@ -110,4 +119,6 @@ extern int bf537Stamp_network_driver_attach(struct rtems_bsdnet_ifconfig *, int)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif /* !ASM */
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -65,8 +65,6 @@ static bfin_mmu_config_t mmuRegions = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
void Init_RTC(void);
|
|
||||||
|
|
||||||
static void initPLL(void);
|
static void initPLL(void);
|
||||||
static void initEBIU(void);
|
static void initEBIU(void);
|
||||||
static void initGPIO(void);
|
static void initGPIO(void);
|
||||||
|
|||||||
@@ -21,6 +21,8 @@
|
|||||||
#ifndef _BSP_H
|
#ifndef _BSP_H
|
||||||
#define _BSP_H
|
#define _BSP_H
|
||||||
|
|
||||||
|
#ifndef ASM
|
||||||
|
|
||||||
#include <libcpu/bf533.h>
|
#include <libcpu/bf533.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
@@ -126,12 +128,33 @@ void setLED (uint8_t value);
|
|||||||
*/
|
*/
|
||||||
uint8_t getLED (void);
|
uint8_t getLED (void);
|
||||||
|
|
||||||
rtems_isr_entry set_vector( ///< @brief returns old vector */
|
/**
|
||||||
rtems_isr_entry handler, ///< @brief isr routine */
|
* @brief Install an interrupt handler
|
||||||
rtems_vector_number vector, ///< @brief vector number */
|
*
|
||||||
int type ///< @brief RTEMS or RAW intr */
|
* This method installs an interrupt handle.
|
||||||
|
*
|
||||||
|
* @param[in] handler is the isr routine
|
||||||
|
* @param[in] vector is the vector number
|
||||||
|
* @param[in] type indicates whether RTEMS or RAW intr
|
||||||
|
*
|
||||||
|
* @return returns old vector
|
||||||
|
*/
|
||||||
|
rtems_isr_entry set_vector(
|
||||||
|
rtems_isr_entry handler,
|
||||||
|
rtems_vector_number vector,
|
||||||
|
int type
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Internal BSP methods that are used across file boundaries
|
||||||
|
*/
|
||||||
|
void Init_RTC(void);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Prototype for methods in .S files that are referenced from C.
|
||||||
|
*/
|
||||||
|
void bfin_null_isr(void);
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
@@ -140,4 +163,6 @@ rtems_isr_entry set_vector( ///< @brief returns old vector *
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif /* !ASM */
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -58,48 +58,13 @@ const unsigned int _icplbs_table[16][2] = {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
|
||||||
* Use the shared implementations of the following routines
|
|
||||||
*/
|
|
||||||
|
|
||||||
void Init_PLL (void);
|
|
||||||
void Init_EBIU (void);
|
|
||||||
void Init_Flags(void);
|
|
||||||
void Init_RTC (void);
|
|
||||||
|
|
||||||
void null_isr(void);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* BSP pretasking hook. Called just before drivers are initialized.
|
|
||||||
* Used to setup libc and install any BSP extensions.
|
|
||||||
*/
|
|
||||||
|
|
||||||
void bsp_pretasking_hook(void)
|
|
||||||
{
|
|
||||||
bfin_interrupt_init();
|
|
||||||
}
|
|
||||||
|
|
||||||
void bsp_start( void )
|
|
||||||
{
|
|
||||||
/* BSP Hardware Initialization*/
|
|
||||||
Init_RTC(); /* Blackfin Real Time Clock initialization */
|
|
||||||
Init_PLL(); /* PLL initialization */
|
|
||||||
Init_EBIU(); /* EBIU initialization */
|
|
||||||
Init_Flags(); /* GPIO initialization */
|
|
||||||
|
|
||||||
int i=0;
|
|
||||||
for (i=5;i<16;i++) {
|
|
||||||
set_vector((rtems_isr_entry)null_isr, i, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Init_PLL
|
* Init_PLL
|
||||||
*
|
*
|
||||||
* Routine to initialize the PLL. The Ezkit uses a 27 Mhz XTAL.
|
* Routine to initialize the PLL. The Ezkit uses a 27 Mhz XTAL.
|
||||||
* See "../eZKit533/include/bsp.h" for more information.
|
* See "../eZKit533/include/bsp.h" for more information.
|
||||||
*/
|
*/
|
||||||
void Init_PLL (void)
|
static void Init_PLL (void)
|
||||||
{
|
{
|
||||||
unsigned int n;
|
unsigned int n;
|
||||||
|
|
||||||
@@ -122,8 +87,7 @@ void Init_PLL (void)
|
|||||||
*
|
*
|
||||||
* Configure extern memory
|
* Configure extern memory
|
||||||
*/
|
*/
|
||||||
|
static void Init_EBIU (void)
|
||||||
void Init_EBIU (void)
|
|
||||||
{
|
{
|
||||||
/* Configure FLASH */
|
/* Configure FLASH */
|
||||||
*((uint32_t*)EBIU_AMBCTL0) = 0x7bb07bb0L;
|
*((uint32_t*)EBIU_AMBCTL0) = 0x7bb07bb0L;
|
||||||
@@ -142,7 +106,7 @@ void Init_EBIU (void)
|
|||||||
*
|
*
|
||||||
* Enable LEDs port
|
* Enable LEDs port
|
||||||
*/
|
*/
|
||||||
void Init_Flags(void)
|
static void Init_Flags(void)
|
||||||
{
|
{
|
||||||
*((uint16_t*)FIO_INEN) = 0x0100;
|
*((uint16_t*)FIO_INEN) = 0x0100;
|
||||||
*((uint16_t*)FIO_DIR) = 0x0000;
|
*((uint16_t*)FIO_DIR) = 0x0000;
|
||||||
@@ -153,6 +117,29 @@ void Init_Flags(void)
|
|||||||
*((uint8_t*)FlashA_PortB_Data) = 0x00;
|
*((uint8_t*)FlashA_PortB_Data) = 0x00;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* BSP pretasking hook. Called just before drivers are initialized.
|
||||||
|
* Used to setup libc and install any BSP extensions.
|
||||||
|
*/
|
||||||
|
void bsp_pretasking_hook(void)
|
||||||
|
{
|
||||||
|
bfin_interrupt_init();
|
||||||
|
}
|
||||||
|
|
||||||
|
void bsp_start( void )
|
||||||
|
{
|
||||||
|
/* BSP Hardware Initialization*/
|
||||||
|
Init_RTC(); /* Blackfin Real Time Clock initialization */
|
||||||
|
Init_PLL(); /* PLL initialization */
|
||||||
|
Init_EBIU(); /* EBIU initialization */
|
||||||
|
Init_Flags(); /* GPIO initialization */
|
||||||
|
|
||||||
|
int i=0;
|
||||||
|
for (i=5;i<16;i++) {
|
||||||
|
set_vector((rtems_isr_entry)bfin_null_isr, i, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Helper Function to use the EzKits LEDS.
|
* Helper Function to use the EzKits LEDS.
|
||||||
* Can be used by the Application.
|
* Can be used by the Application.
|
||||||
@@ -169,20 +156,3 @@ uint8_t getLED (void)
|
|||||||
{
|
{
|
||||||
return *((uint8_t*)FlashA_PortB_Data);
|
return *((uint8_t*)FlashA_PortB_Data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void initCPLB(void)
|
|
||||||
{
|
|
||||||
int i = 0;
|
|
||||||
unsigned int *addr;
|
|
||||||
unsigned int *data;
|
|
||||||
|
|
||||||
addr = (unsigned int *)0xffe00100;
|
|
||||||
data = (unsigned int *)0xffe00200;
|
|
||||||
|
|
||||||
while ( dcplbs_table[i][0] != 0xffffffff ) {
|
|
||||||
*addr = dcplbs_table[i][0];
|
|
||||||
*data = dcplbs_table[i][1];
|
|
||||||
addr++;
|
|
||||||
data++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
|
|
||||||
#include <rtems/bfin/bfin.h>
|
#include <rtems/bfin/bfin.h>
|
||||||
|
|
||||||
|
#include <bsp.h>
|
||||||
#include <bspopts.h>
|
#include <bspopts.h>
|
||||||
|
|
||||||
#ifndef LO
|
#ifndef LO
|
||||||
@@ -88,7 +89,7 @@ __start:
|
|||||||
P3 = P4;
|
P3 = P4;
|
||||||
jump (p0) /* Should not return. */
|
jump (p0) /* Should not return. */
|
||||||
|
|
||||||
.global _null_isr
|
.global _bfin_null_isr
|
||||||
_null_isr:
|
_bfin_null_isr:
|
||||||
rti;
|
rti;
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ static rtems_isr clockISR(rtems_vector_number vector) {
|
|||||||
} while (
|
} while (
|
||||||
_Thread_Heir == _Thread_Executing
|
_Thread_Heir == _Thread_Executing
|
||||||
&& _Thread_Executing->Start.entry_point
|
&& _Thread_Executing->Start.entry_point
|
||||||
== rtems_configuration_get_idle_task()
|
== (Thread_Entry) rtems_configuration_get_idle_task()
|
||||||
);
|
);
|
||||||
#else
|
#else
|
||||||
rtems_clock_tick();
|
rtems_clock_tick();
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
/* Real Time Clock Driver for Blackfin
|
/*
|
||||||
|
* Real Time Clock Driver for Blackfin
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
/* UART driver for Blackfin
|
/* UART driver for Blackfin
|
||||||
*
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
* Copyright (c) 2008 Kallisti Labs, Los Gatos, CA, USA
|
* Copyright (c) 2008 Kallisti Labs, Los Gatos, CA, USA
|
||||||
* written by Allan Hessenflow <allanh@kallisti.com>
|
* written by Allan Hessenflow <allanh@kallisti.com>
|
||||||
*
|
*
|
||||||
@@ -8,7 +10,6 @@
|
|||||||
* http://www.rtems.org/license/LICENSE.
|
* http://www.rtems.org/license/LICENSE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <rtems.h>
|
#include <rtems.h>
|
||||||
#include <rtems/libio.h>
|
#include <rtems/libio.h>
|
||||||
#include <rtems/termiostypes.h>
|
#include <rtems/termiostypes.h>
|
||||||
@@ -22,11 +23,10 @@
|
|||||||
/* flags */
|
/* flags */
|
||||||
#define BFIN_UART_XMIT_BUSY 0x01
|
#define BFIN_UART_XMIT_BUSY 0x01
|
||||||
|
|
||||||
|
|
||||||
static bfin_uart_config_t *uartsConfig;
|
static bfin_uart_config_t *uartsConfig;
|
||||||
|
|
||||||
|
static int pollRead(int minor)
|
||||||
static int pollRead(int minor) {
|
{
|
||||||
int c;
|
int c;
|
||||||
uint32_t base;
|
uint32_t base;
|
||||||
|
|
||||||
@@ -44,7 +44,8 @@ static int pollRead(int minor) {
|
|||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
char bfin_uart_poll_read(rtems_device_minor_number minor) {
|
char bfin_uart_poll_read(rtems_device_minor_number minor)
|
||||||
|
{
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
@@ -54,7 +55,8 @@ char bfin_uart_poll_read(rtems_device_minor_number minor) {
|
|||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
void bfin_uart_poll_write(int minor, char c) {
|
void bfin_uart_poll_write(int minor, char c)
|
||||||
|
{
|
||||||
uint32_t base;
|
uint32_t base;
|
||||||
|
|
||||||
base = uartsConfig->channels[minor].uart_baseAddress;
|
base = uartsConfig->channels[minor].uart_baseAddress;
|
||||||
@@ -64,61 +66,13 @@ void bfin_uart_poll_write(int minor, char c) {
|
|||||||
*(uint16_t volatile *) (base + UART_THR_OFFSET) = c;
|
*(uint16_t volatile *) (base + UART_THR_OFFSET) = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* begin BISON */
|
|
||||||
void debug_write_char(char c) {
|
|
||||||
bfin_uart_poll_write(0, c);
|
|
||||||
}
|
|
||||||
|
|
||||||
void debug_write_string(char *s) {
|
|
||||||
|
|
||||||
while (s && *s) {
|
|
||||||
if (*s == '\n')
|
|
||||||
debug_write_char('\r');
|
|
||||||
debug_write_char(*s++);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void debug_write_crlf(void) {
|
|
||||||
|
|
||||||
debug_write_char('\r');
|
|
||||||
debug_write_char('\n');
|
|
||||||
}
|
|
||||||
|
|
||||||
void debug_write_nybble(int nybble) {
|
|
||||||
|
|
||||||
nybble &= 0x0f;
|
|
||||||
debug_write_char((nybble > 9) ? 'a' + (nybble - 10) : '0' + nybble);
|
|
||||||
}
|
|
||||||
|
|
||||||
void debug_write_byte(int byte) {
|
|
||||||
|
|
||||||
byte &= 0xff;
|
|
||||||
debug_write_nybble(byte >> 4);
|
|
||||||
debug_write_nybble(byte & 0x0f);
|
|
||||||
}
|
|
||||||
|
|
||||||
void debug_write_half(int half) {
|
|
||||||
|
|
||||||
half &= 0xffff;
|
|
||||||
debug_write_byte(half >> 8);
|
|
||||||
debug_write_byte(half & 0xff);
|
|
||||||
}
|
|
||||||
|
|
||||||
void debug_write_word(int word) {
|
|
||||||
|
|
||||||
word &= 0xffffffff;
|
|
||||||
debug_write_half(word >> 16);
|
|
||||||
debug_write_half(word & 0xffff);
|
|
||||||
}
|
|
||||||
/* end BISON */
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Console Termios Support Entry Points
|
* Console Termios Support Entry Points
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static ssize_t pollWrite(int minor, const char *buf, size_t len) {
|
static ssize_t pollWrite(int minor, const char *buf, size_t len)
|
||||||
|
{
|
||||||
size_t count;
|
size_t count;
|
||||||
for ( count = 0; count < len; count++ )
|
for ( count = 0; count < len; count++ )
|
||||||
bfin_uart_poll_write(minor, *buf++);
|
bfin_uart_poll_write(minor, *buf++);
|
||||||
@@ -126,13 +80,13 @@ static ssize_t pollWrite(int minor, const char *buf, size_t len) {
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Routine to initialize the hardware. It initialize the DMA,
|
* Routine to initialize the hardware. It initialize the DMA,
|
||||||
* interrupt if required.
|
* interrupt if required.
|
||||||
* @param channel channel information
|
* @param channel channel information
|
||||||
*/
|
*/
|
||||||
static void initializeHardware(bfin_uart_channel_t *channel) {
|
static void initializeHardware(bfin_uart_channel_t *channel)
|
||||||
|
{
|
||||||
uint16_t divisor = 0;
|
uint16_t divisor = 0;
|
||||||
uint32_t base = 0;
|
uint32_t base = 0;
|
||||||
uint32_t tx_dma_base = 0;
|
uint32_t tx_dma_base = 0;
|
||||||
@@ -188,8 +142,6 @@ static void initializeHardware(bfin_uart_channel_t *channel) {
|
|||||||
* We use polling or interrupts only sending one char at a time :(
|
* We use polling or interrupts only sending one char at a time :(
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -199,7 +151,8 @@ static void initializeHardware(bfin_uart_channel_t *channel) {
|
|||||||
* @param termios
|
* @param termios
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
static int setAttributes(int minor, const struct termios *termios) {
|
static int setAttributes(int minor, const struct termios *termios)
|
||||||
|
{
|
||||||
uint32_t base;
|
uint32_t base;
|
||||||
int baud;
|
int baud;
|
||||||
uint16_t divisor;
|
uint16_t divisor;
|
||||||
@@ -207,86 +160,36 @@ static int setAttributes(int minor, const struct termios *termios) {
|
|||||||
|
|
||||||
base = uartsConfig->channels[minor].uart_baseAddress;
|
base = uartsConfig->channels[minor].uart_baseAddress;
|
||||||
switch (termios->c_cflag & CBAUD) {
|
switch (termios->c_cflag & CBAUD) {
|
||||||
case B0:
|
case B0: baud = 0; break;
|
||||||
baud = 0;
|
case B50: baud = 50; break;
|
||||||
break;
|
case B75: baud = 75; break;
|
||||||
case B50:
|
case B110: baud = 110; break;
|
||||||
baud = 50;
|
case B134: baud = 134; break;
|
||||||
break;
|
case B150: baud = 150; break;
|
||||||
case B75:
|
case B200: baud = 200; break;
|
||||||
baud = 75;
|
case B300: baud = 300; break;
|
||||||
break;
|
case B600: baud = 600; break;
|
||||||
case B110:
|
case B1200: baud = 1200; break;
|
||||||
baud = 110;
|
case B1800: baud = 1800; break;
|
||||||
break;
|
case B2400: baud = 2400; break;
|
||||||
case B134:
|
case B4800: baud = 4800; break;
|
||||||
baud = 134;
|
case B9600: baud = 9600; break;
|
||||||
break;
|
case B19200: baud = 19200; break;
|
||||||
case B150:
|
case B38400: baud = 38400; break;
|
||||||
baud = 150;
|
case B57600: baud = 57600; break;
|
||||||
break;
|
case B115200: baud = 115200; break;
|
||||||
case B200:
|
case B230400: baud = 230400; break;
|
||||||
baud = 200;
|
case B460800: baud = 460800; break;
|
||||||
break;
|
default: baud = -1; break;
|
||||||
case B300:
|
|
||||||
baud = 300;
|
|
||||||
break;
|
|
||||||
case B600:
|
|
||||||
baud = 600;
|
|
||||||
break;
|
|
||||||
case B1200:
|
|
||||||
baud = 1200;
|
|
||||||
break;
|
|
||||||
case B1800:
|
|
||||||
baud = 1800;
|
|
||||||
break;
|
|
||||||
case B2400:
|
|
||||||
baud = 2400;
|
|
||||||
break;
|
|
||||||
case B4800:
|
|
||||||
baud = 4800;
|
|
||||||
break;
|
|
||||||
case B9600:
|
|
||||||
baud = 9600;
|
|
||||||
break;
|
|
||||||
case B19200:
|
|
||||||
baud = 19200;
|
|
||||||
break;
|
|
||||||
case B38400:
|
|
||||||
baud = 38400;
|
|
||||||
break;
|
|
||||||
case B57600:
|
|
||||||
baud = 57600;
|
|
||||||
break;
|
|
||||||
case B115200:
|
|
||||||
baud = 115200;
|
|
||||||
break;
|
|
||||||
case B230400:
|
|
||||||
baud = 230400;
|
|
||||||
break;
|
|
||||||
case B460800:
|
|
||||||
baud = 460800;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
baud = -1;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
if (baud > 0 && uartsConfig->channels[minor].uart_baud)
|
if (baud > 0 && uartsConfig->channels[minor].uart_baud)
|
||||||
baud = uartsConfig->channels[minor].uart_baud;
|
baud = uartsConfig->channels[minor].uart_baud;
|
||||||
switch (termios->c_cflag & CSIZE) {
|
switch (termios->c_cflag & CSIZE) {
|
||||||
case CS5:
|
case CS5: lcr = UART_LCR_WLS_5; break;
|
||||||
lcr = UART_LCR_WLS_5;
|
case CS6: lcr = UART_LCR_WLS_6; break;
|
||||||
break;
|
case CS7: lcr = UART_LCR_WLS_7; break;
|
||||||
case CS6:
|
|
||||||
lcr = UART_LCR_WLS_6;
|
|
||||||
break;
|
|
||||||
case CS7:
|
|
||||||
lcr = UART_LCR_WLS_7;
|
|
||||||
break;
|
|
||||||
case CS8:
|
|
||||||
default:
|
default:
|
||||||
lcr = UART_LCR_WLS_8;
|
case CS8: lcr = UART_LCR_WLS_8; break;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
switch (termios->c_cflag & (PARENB | PARODD)) {
|
switch (termios->c_cflag & (PARENB | PARODD)) {
|
||||||
case PARENB:
|
case PARENB:
|
||||||
@@ -320,7 +223,8 @@ static int setAttributes(int minor, const struct termios *termios) {
|
|||||||
* @param len Length of buffer to be transmitted.
|
* @param len Length of buffer to be transmitted.
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
static ssize_t uart_interruptWrite(int minor, const char *buf, size_t len) {
|
static ssize_t uart_interruptWrite(int minor, const char *buf, size_t len)
|
||||||
|
{
|
||||||
uint32_t base = 0;
|
uint32_t base = 0;
|
||||||
bfin_uart_channel_t* channel = NULL;
|
bfin_uart_channel_t* channel = NULL;
|
||||||
|
|
||||||
@@ -358,10 +262,8 @@ void bfinUart_rxIsr(void *_arg)
|
|||||||
/**
|
/**
|
||||||
* TODO: UART RX ISR implementation.
|
* TODO: UART RX ISR implementation.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function implements TX ISR. The function gets called when the TX FIFO is
|
* This function implements TX ISR. The function gets called when the TX FIFO is
|
||||||
* empty. It clears the interrupt and dequeues the character. It only tx one
|
* empty. It clears the interrupt and dequeues the character. It only tx one
|
||||||
@@ -370,7 +272,8 @@ void bfinUart_rxIsr(void *_arg)
|
|||||||
* TODO: error handling.
|
* TODO: error handling.
|
||||||
* @param _arg gets the channel information.
|
* @param _arg gets the channel information.
|
||||||
*/
|
*/
|
||||||
void bfinUart_txIsr(void *_arg) {
|
void bfinUart_txIsr(void *_arg)
|
||||||
|
{
|
||||||
bfin_uart_channel_t* channel = NULL;
|
bfin_uart_channel_t* channel = NULL;
|
||||||
uint32_t base = 0;
|
uint32_t base = 0;
|
||||||
|
|
||||||
@@ -390,13 +293,8 @@ void bfinUart_txIsr(void *_arg) {
|
|||||||
channel->flags &= ~BFIN_UART_XMIT_BUSY;
|
channel->flags &= ~BFIN_UART_XMIT_BUSY;
|
||||||
|
|
||||||
rtems_termios_dequeue_characters(channel->termios, channel->length);
|
rtems_termios_dequeue_characters(channel->termios, channel->length);
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* interrupt based DMA write Routine. It configure the DMA to write len bytes.
|
* interrupt based DMA write Routine. It configure the DMA to write len bytes.
|
||||||
* The DMA supports 64K data only.
|
* The DMA supports 64K data only.
|
||||||
@@ -406,7 +304,8 @@ void bfinUart_txIsr(void *_arg) {
|
|||||||
* @param len length of data items to be written
|
* @param len length of data items to be written
|
||||||
* @return data already written
|
* @return data already written
|
||||||
*/
|
*/
|
||||||
static ssize_t uart_DmaWrite(int minor, const char *buf, size_t len) {
|
static ssize_t uart_DmaWrite(int minor, const char *buf, size_t len)
|
||||||
|
{
|
||||||
uint32_t base = 0;
|
uint32_t base = 0;
|
||||||
bfin_uart_channel_t* channel = NULL;
|
bfin_uart_channel_t* channel = NULL;
|
||||||
uint32_t tx_dma_base = 0;
|
uint32_t tx_dma_base = 0;
|
||||||
@@ -443,14 +342,14 @@ static ssize_t uart_DmaWrite(int minor, const char *buf, size_t len) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* RX DMA ISR.
|
* RX DMA ISR.
|
||||||
* The polling route is used for receiving the characters. This is a place
|
* The polling route is used for receiving the characters. This is a place
|
||||||
* holder for future implementation.
|
* holder for future implementation.
|
||||||
* @param _arg
|
* @param _arg
|
||||||
*/
|
*/
|
||||||
void bfinUart_rxDmaIsr(void *_arg) {
|
void bfinUart_rxDmaIsr(void *_arg)
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* TODO: Implementation of RX DMA
|
* TODO: Implementation of RX DMA
|
||||||
*/
|
*/
|
||||||
@@ -467,7 +366,8 @@ void bfinUart_rxDmaIsr(void *_arg) {
|
|||||||
* @param _arg argument passed to the interrupt handler. It contains the
|
* @param _arg argument passed to the interrupt handler. It contains the
|
||||||
* channel argument.
|
* channel argument.
|
||||||
*/
|
*/
|
||||||
void bfinUart_txDmaIsr(void *_arg) {
|
void bfinUart_txDmaIsr(void *_arg)
|
||||||
|
{
|
||||||
bfin_uart_channel_t* channel = NULL;
|
bfin_uart_channel_t* channel = NULL;
|
||||||
uint32_t tx_dma_base = 0;
|
uint32_t tx_dma_base = 0;
|
||||||
|
|
||||||
@@ -495,19 +395,16 @@ void bfinUart_txDmaIsr(void *_arg) {
|
|||||||
* This routine must not be called.
|
* This routine must not be called.
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function called during exit
|
* Function called during exit
|
||||||
*/
|
*/
|
||||||
void uart_exit(void)
|
static void uart_exit(void)
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* TODO: Flushing of quques
|
* TODO: Flushing of quques
|
||||||
*/
|
*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -571,7 +468,6 @@ rtems_device_driver bfin_uart_open(rtems_device_major_number major,
|
|||||||
TERMIOS_IRQ_DRIVEN /* outputUsesInterrupts */
|
TERMIOS_IRQ_DRIVEN /* outputUsesInterrupts */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
if ( NULL == uartsConfig || 0 > minor || minor >= uartsConfig->num_channels) {
|
if ( NULL == uartsConfig || 0 > minor || minor >= uartsConfig->num_channels) {
|
||||||
return RTEMS_INVALID_NUMBER;
|
return RTEMS_INVALID_NUMBER;
|
||||||
}
|
}
|
||||||
@@ -598,15 +494,17 @@ rtems_device_driver bfin_uart_open(rtems_device_major_number major,
|
|||||||
return sc;
|
return sc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Uart initialization function.
|
* Uart initialization function.
|
||||||
* @param major major number of the device
|
* @param major major number of the device
|
||||||
* @param config configuration parameters
|
* @param config configuration parameters
|
||||||
* @return rtems status code
|
* @return rtems status code
|
||||||
*/
|
*/
|
||||||
rtems_status_code bfin_uart_initialize(rtems_device_major_number major,
|
rtems_status_code bfin_uart_initialize(
|
||||||
bfin_uart_config_t *config) {
|
rtems_device_major_number major,
|
||||||
|
bfin_uart_config_t *config
|
||||||
|
)
|
||||||
|
{
|
||||||
rtems_status_code sc = RTEMS_NOT_DEFINED;
|
rtems_status_code sc = RTEMS_NOT_DEFINED;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
* This file defines Macros for MMR register common to all Blackfin
|
* This file defines Macros for MMR register common to all Blackfin
|
||||||
* Processors.
|
* Processors.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* COPYRIGHT (c) 2006 by Atos Automacao Industrial Ltda.
|
* COPYRIGHT (c) 2006 by Atos Automacao Industrial Ltda.
|
||||||
* modified by Alain Schaefer <alain.schaefer@easc.ch>
|
* modified by Alain Schaefer <alain.schaefer@easc.ch>
|
||||||
|
|||||||
Reference in New Issue
Block a user