BoardSpecific.c
/***************************************************************************//**
@file BoardSpecific.c
@brief @ref P_BOARDSPEC "Board Specific Support Functions": Implementation
@verbatim
_ _ _
__| | ___(_) ____ _ __ | |_
/ _` | / __| |/ _` | '_ \| __|
| (_| | _ \__ \ | (_| | | | | |_
\__,_|(_) ___/_|\__, |_| |_|\__|
Signalprocessing |___/ Technology
@endverbatim
@author D.SignT GmbH & Co. KG, Claus Hermbusche
@date 2019-06-04
This module contains board specific support functions for LED access, timer
initialization, UART access
@cond Software License Agreement
Copyright (C) 2001-2019 D.SignT GmbH & Co. KG - http://www.dsignt.de
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the
distribution.
Neither the name of D.SignT GmbH & Co. KG nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
Disclaimer
THIS SOFTWARE IS PROVIDED BY D.SIGNT GMBH & CO. KG "AS IS" AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL D.SIGNT GMBH & CO. KG BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@endcond
*******************************************************************************/
/*******************************************************************************
SYS/BIOS specific
*******************************************************************************/
#if defined(USE_SYSBIOS)
#include <xdc/std.h>
#include <xdc/runtime/Error.h>
// #include <xdc/runtime/System.h>
// #include <ti/sysbios/BIOS.h>
#include <ti/sysbios/knl/Clock.h>
// #include <ti/sysbios/knl/Task.h>
// #include <ti/sysbios/knl/Semaphore.h>
// #include <ti/sysbios/hal/Hwi.h>
// #include <ti/sysbios/timers/timer64/Timer.h>
#endif
/*******************************************************************************
include stdtypes.h to avoid data type mismatch
*******************************************************************************/
/*******************************************************************************
include Runtime Source
*******************************************************************************/
#include <stdlib.h>
#include <stdio.h>
#include <stddef.h>
#include <inttypes.h>
#include <time.h>
#include <string.h>
/*******************************************************************************
network support functions
*******************************************************************************/
#include <Libs/NETlib/net.h> /* D.Module network support */
/*******************************************************************************
board specific functions
*******************************************************************************/
#include <BoardSupport/inc/BoardSpecific.h> /* board support functions */
/*******************************************************************************
common support functions
*******************************************************************************/
#include <Common/Common.h> /* on exit function */
#include <Common/uartio.h> /* UART support */
#include <Common/timer.h> /* timer setting */
#include <Common/CPrintf.h> /* CPrintf defines */
#ifdef __cplusplus
extern "C" {
#endif /* !__cplusplus */
/*******************************************************************************
local prototypes
*******************************************************************************/
#ifdef __cplusplus
} // extern "C"
#endif
/******************************************************************************/
/* */
/* GLOBALS */
/* */
/******************************************************************************/
/*******************************************************************************
predefined messages
*******************************************************************************/
char module_str[] = {"DM2DM642"};
char sym_animate[] = "-\\|/";
#if (defined(_NET_H_) || defined(_DSKNET_H_) || defined(HAVE_LINK_STATUS))
/***************************************************************************//**
use Operation Mode parameter to detect link mode
FULL_DUPLEX 0x01
SPEED_100 0x04
SPEED_1000 0x20
*******************************************************************************/
/***************************************************************************//**
reflects the link status
*******************************************************************************/
volatile uint16_t _link = 0;
/*******************************************************************************
ICMP socket
*******************************************************************************/
SOCKET *icmp_so;
#endif
#ifdef _UARTIO_H_
/*******************************************************************************
handle for UART
*******************************************************************************/
char *printf_uart_str = {"\r\n please connect a free serial PC port to the RS232 connector \r\n on your D.Base2 and start a terminal program configured to\r\n >>115200 baud, 8 bits, 1 stop bit, no parity<<\r\n to see CPrintf outputs\r\n"};
// #pragma DATA_SECTION (UART_Printf_Buffer, ".commondata");
char UART_Printf_Buffer[512];
#endif
#ifdef INC_TIMER
TIMER_Handle hSystemTimer = INV; /* timer handle */
#if defined(USE_SYSBIOS)
Clock_Handle hTimerClock;
#endif
#endif
/*******************************************************************************
ledstate
*******************************************************************************/
static unsigned int ledstate = 0;
#ifdef INC_MMCSPIDRIVE
uint32_t _cd_gpio = 0; /* card detect GPI */
#endif
#ifdef INC_CMD
/*******************************************************************************
array to hold a command line
*******************************************************************************/
#ifndef CMDLINE_MAX_LEN
#define CMDLINE_MAX_LEN 79 /* max command line characters */
#endif
static char aCmdLine[CMDLINE_MAX_LEN+1] = { 0 }; /* command line */
T_ComDevice CmdDevice =
{
#ifdef _UARTIO_H_
/*.out =*/ BoardUartWriteChar, /* output function */
/*.outf =*/ BoardUartWriteFormattedString, /* formatted string output function */
/*.outs =*/ BoardUartWriteString, /* string output function */
/*.in =*/ BoardUartReadChar, /* input */
#else
/*.out =*/ NULL, /* output function */
/*.outf =*/ NULL, /* formatted string output function */
/*.outs =*/ NULL, /* string output function */
/*.in =*/ NULL, /* input */
#endif
/*.gp =*/ NULL, /* active server */
/*.CmdTab =*/ NULL, /* command table */
/*.InputParser =*/ NULL, /* input parser callback */
/*.aCmdLine =*/ aCmdLine, /* command line */
/*.dev =*/ COM_DEV_UART /* device type */
};
#endif
/******************************************************************************/
/* */
/* FUNCTIONS */
/* */
/******************************************************************************/
/*******************************************************************************
@brief board specific initialization
@param dsp_clock [Hz]
@return nothing
@details Make board specific settings. Store or determine configured clocks.
Call further board specific initialization functions for e.g PLL,
EMIF, XINTF and prepare interrupts.
*******************************************************************************/
void BoardAppInit (uint32_t dsp_clock)
{
/***************************************************************************
locals
***************************************************************************/
// BoardDisableEDMA();
/***************************************************************************
store DSP clock
***************************************************************************/
DspClock = dsp_clock;
TimerClock = dsp_clock>>3;
/***************************************************************************
basic initialisation, call bios function init_module()
***************************************************************************/
/***************************************************************************
initialize interrupt system
***************************************************************************/
#if (!(defined(USE_DSPBIOS) || defined(USE_SYSBIOS)))
// DM2_intInit (&DM2_intServiceTable);
#endif
}
/*******************************************************************************
@brief board specific peripheral initialization
@param -
@return nothing
*******************************************************************************/
{
/***************************************************************************
initialize Chip Support Library
***************************************************************************/
CSL_init();
/***************************************************************************
make SDRAM cacheable
***************************************************************************/
CACHE_enableCaching(CACHE_EMIFA_CE00);
CACHE_enableCaching(CACHE_EMIFA_CE01);
CACHE_enableCaching(CACHE_EMIFA_CE02);
CACHE_enableCaching(CACHE_EMIFA_CE03);
/***************************************************************************
initialize FLASH
***************************************************************************/
#ifdef USE_SPIDRIVE
/***************************************************************************
configure GPIO2 (PRGIO[6]) as input for card detect signal
***************************************************************************/
// ConfigureCardDetect (6);
ConfigureCardDetect (15);
#endif
}
/*******************************************************************************
@brief close board specific peripherals
@param -
@return nothing
*******************************************************************************/
{
/***************************************************************************
stop timer
***************************************************************************/
#ifdef INC_TIMER
#endif
//~ TIMER(0)->ctl = 0x301;
//~ TIMER_close (h_timer[0]);
//~ TIMER_close (h_timer[1]);
//~ TIMER_close (h_timer[2]);
//~ TIMER_resetAll();
/***************************************************************************
disable interrupt
***************************************************************************/
_disable_interrupts();
/***************************************************************************
disable DMA
***************************************************************************/
//...
/***************************************************************************
close peripherals
***************************************************************************/
#ifdef _UARTIO_H_
#endif
#ifdef _USBIO_H_
#endif
}
/*******************************************************************************
@brief initialize interrupts
@param -
@return nothing
*******************************************************************************/
{
#if (!(defined(USE_DSPBIOS) || defined(USE_SYSBIOS)))
// if (intcInit() != intcInit_OK) // required only once
// {
// prg_exit ("error");
// }
#endif
}
/*******************************************************************************
@brief global enable interrupts
@param -
@return nothing
*******************************************************************************/
{
// DM2_intStart();
_enable_interrupts();
/**************************************************************************
enable the bits for non maskable interrupt (0x02)
**************************************************************************/
IER |= 0x2;
}
/*******************************************************************************
@brief clear all pending Interrupts
@param -
@return -
*******************************************************************************/
{
/***************************************************************************
clear CPU interrupts
***************************************************************************/
IER = 0;
ICR = 0xFFFF;
CSR &= ~1;
}
/*******************************************************************************
@brief stop all pending DMA actions
@param -
@return -
*******************************************************************************/
void BoardDisableEDMA(void)
{
// CSL_Edma3ccRegsOvly Edma3cc0Regs = (CSL_Edma3ccRegsOvly)CSL_EDMA3CC_0_REGS;
// Edma3cc0Regs->IECR = 0xffffffff; // IER - Disable interrupts
// Edma3cc0Regs->EECR = 0xffffffff; // EER - Disable events
// Edma3cc0Regs->ICR = 0xffffffff; // ICR - Clear interrupts
// Edma3cc0Regs->ECR = 0xffffffff; // ICRH - Clear events
}
/******************************************************************************/
/* */
/* Network specific functions */
/* */
/******************************************************************************/
#if (defined(_NET_H_) || defined(_DSKNET_H_) || defined(HAVE_LINK_STATUS))
/**************************************************************************//**
@addtogroup INITLINKSTATUS Link Status Callback
@{
*******************************************************************************/
/*******************************************************************************
@brief link status change callback function
@param mode - HDX_10, HDX_100, FDX_10, FDX_100, FDX1000
@return nothing
@see DM2_EmacInit
*******************************************************************************/
void link_status (uint8_t mode)
{
_link_mode = mode;
switch (mode)
{
case 0xff:
/*******************************************************************
reset global link status
*******************************************************************/
_link = 0;
/*******************************************************************
in case of DHCP reset IP address
*******************************************************************/
if (!((eth.ip[0]-'0')<=9))
{
set_ip_address (0, "0.0.0.0");
}
break;
default:
/*******************************************************************
set global link status
*******************************************************************/
_link |= 1;
/*******************************************************************
clear ARP cache
*******************************************************************/
/*******************************************************************
in case of DHCP re-trigger DHCP request
*******************************************************************/
if ((!((eth.ip[0]-'0')<=9)) && eth.dhcp_setting)
{
}
break;
}
}
/*******************************************************************************
@brief monitor link status change
@param pLog - printf function or NULL
@return TRUE (1) - link status changed
@return FALSE (0) - link status not changed
@details Use this function in your main loop to detect a link status change.
Global flag _link_mode is monitored and in case of change a LED
can be toggled or a message can be printed on the default output
terminal.
Parameter pLog can be a standard formatted print function like
printf or CPrintf. If this parameter is NULL, no output is printed.
The return value can be used for event processing in case of a
status change.
@note _link_mode is only valid, if a link_status callback function is
used and the _link_mode is set.
@example DHCPTest.c
*******************************************************************************/
{
/***************************************************************************
locals
***************************************************************************/
static uint8_t _link_mode_old = 0xff;
if (_link_mode_old != _link_mode)
{
_link_mode_old = _link_mode;
if (pLog) pLog ("\n\r Link status changed: ");
switch (_link_mode)
{
case 0xff:
LED_off (2);
if (pLog) pLog ("No Link\r\n");
break;
default:
LED_on (2);
if (pLog) pLog ("Linked at %d%sMbit %s duplex\r\n",
(_link_mode & SPEED_100) ? 100:10,
(_link_mode & SPEED_1000) ? "00 ":" ",
(_link_mode & FULL_DUPLEX) ? "full":"half");
break;
}
return (1);
}
return (0);
}
/*******************************************************************************
@brief monitor IP assignment
@param pLog - printf function or NULL
@return TRUE (1) - IP address assigned
@return FALSE (0) - IP address not changed
@details Use this function to monitor IP assignment. Useful when the IP
address is assigned dynamically by DHCP.
The return value can be used for event processing, e.g. send a
welcome message or email.
Parameter pLog can be a standard formatted print function like
printf or CPrintf. If this parameter is NULL, no output is printed.
@example DHCPTest.c
*******************************************************************************/
{
/***************************************************************************
locals
***************************************************************************/
static uint16_t wait_for_ip = 1;
uint16_t ret = 0;
/***************************************************************************
try to detect IP assignment
***************************************************************************/
if ((ip=get_ip_address (0)) == UINT32_C(0)) // no IP address assigned
{
wait_for_ip = 1;
return(ret);
}
if (wait_for_ip)
{
wait_for_ip = 0;
ret = 1;
if (pLog)
{
if (IS_LINKLOCAL(ip))
{
pLog (" !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\r\n");
pLog (" !!! warning: no DHCP server available !!!\r\n");
pLog (" !!! assigned IP address is a link-local address !!!\r\n");
pLog (" !!! make sure your host is in the same local !!!\r\n");
pLog (" !!! subnet: 169.254.x.x !!!\r\n");
pLog (" !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\r\n");
}
pLog ("\r\n network configuration:");
net_print_stat (0, pLog);
}
}
return (ret);
}
/*@}*/
/*******************************************************************************
@brief Initialize MAC, sockets and protocols
@param icmp_size - space for ICMP (ping))
@return 0 - success or >0 - error occurred
*******************************************************************************/
int InitializeNetwork ( uint16_t icmp_size)
{
/***************************************************************************
locals
***************************************************************************/
char uid[6];
static uint32_t NetInitStatus = 0; // not initialized
if (NetInitStatus) return (0);
/***************************************************************************
initialize DM642 EMAC
possible values
mode: FDX_100, FDX_10, HDX_100, HDX_10, AUTO_NEG
MAC Address
link_status: callback function or NULL
***************************************************************************/
{
#ifdef EMAC_DETAIL
return (1);
#else
prg_exit ("\r\nDM2_EmacInit() function failed\r\nEthernet defect"); /* initialize EMAC error */
#endif
}
/***************************************************************************
in case of DHCP create unique network name
***************************************************************************/
if (!((eth.ip[0]-'0')<=9))
{
/***********************************************************************
read internal MAC address
***********************************************************************/
get_mac_address (0, buffer);
if ( strlen(eth.ip) < (30-5) ) // check space for MAC ID
{
/*******************************************************************
append lower MAC address bits to module name for unique host name.
eth.ip is defined in netconfig.c as a 30 byte char array. Don't
use host names larger than 30 bytes or increase the array size.
*******************************************************************/
sprintf (uid, "-%04X", htons(buffer[2]));
strcat (eth.ip, uid);
}
else
{
#ifdef EMAC_DETAIL
return (2);
#else
prg_exit ("\r\nhostname too long"); /* initialize EMAC error */
#endif
}
}
/***************************************************************************
init sockets
1. parameter: own IP address or own HOST_NAME
2. parameter: subnet mask
3. parameter: gateway address
4. parameter NULL - own IP address is valid
DHCP_ENABLE - IP comes from a DHCP Server
own HOST_NAME is valid
5. parameter DNS Server IP or NULL
6. parameter DNS_ENABLE or NULL
***************************************************************************/
if ( !net_init (eth.ip,
{
#ifdef EMAC_DETAIL
return (3);
#else
prg_exit ("net_init() failed"); /* out of memory, try to increase heap */
#endif
}
/***************************************************************************
in case of DHCP reset IP address
***************************************************************************/
if (!((eth.ip[0]-'0')<=9))
{
set_ip_address (0, "0.0.0.0");
}
/***************************************************************************
install icmp socket (for ping)
***************************************************************************/
if ( (icmp_so = install_icmp_socket (icmp_size)) == NULL)
{
#ifdef EMAC_DETAIL
return (4);
#else
prg_exit ("ICMP socket error"); /* possibly insufficient heap */
#endif
}
NetInitStatus = 1; // network initialized
/***************************************************************************
success
***************************************************************************/
return (0);
}
#endif
/******************************************************************************/
/* */
/* UART specific functions */
/* */
/******************************************************************************/
#ifdef _UARTIO_H_
/***************************************************************************//**
@brief Initialize UART
@param -
@return 0 - success
!0 - error
*******************************************************************************/
int BoardUartInit ( void)
{
/***************************************************************************
locals
***************************************************************************/
char c=0;
/***************************************************************************
open UART 0
***************************************************************************/
/***************************************************************************
flush UART
***************************************************************************/
if ( h_Uart )
{
while ( DM2_uartRead(h_Uart, &c) ) asm(" nop");
} // if
/***************************************************************************
return success
***************************************************************************/
return (h_Uart == NULL);
}
/*******************************************************************************
@brief write string over UART
@param str - string to write
@return -
*******************************************************************************/
void BoardUartWriteString ( const char *str)
{
}
/*******************************************************************************
@brief write formatted string over UART
@param format - format string to write
@return -
*******************************************************************************/
int BoardUartWriteFormattedString (const char *format, ...)
{
va_list argptr;
int cnt = 0;
/***************************************************************************
initializes variable argument list
***************************************************************************/
#pragma diag_suppress 238
va_start (argptr, format);
#pragma diag_default 238
/***************************************************************************
print to buffer
***************************************************************************/
cnt = vsprintf (UART_Printf_Buffer, format, argptr);
/***************************************************************************
vsprintf returns the amount of printed characters. The user buffer size is
limited to TELNET_OUTPUT_BUFFER_SIZE. Check for buffer overflow and exit if
necessary.
***************************************************************************/
if (cnt > 512)
{
prg_exit ("buffer overflow");
}
BoardUartWriteString ( UART_Printf_Buffer);
/***************************************************************************
end variable argument list
***************************************************************************/
va_end(argptr);
return (cnt);
}
/*******************************************************************************
@brief read String from UART
@param dst - pointer to destination buffer
@param maxlen - maximum string length (size of destination buffer) in bytes
@param timeout - number of retries until data is received, 0 = no timeout
@param echo - echo received characters
@return pointer to destination buffer, 0 if timeout
@note This function reads an ASCIIZ string from the UART.
If a line end character (<CR> and/or <LF>)is received or
maxcount is reached, a terminating 0 is appended and the
function returns. Line end characters are skipped from the string.
<BACKSPACE> deletes the previous character from the string.
<ESC> terminates and returns an empty string.
@note all line end characters are accepted (CR, LF, CR+LF)
@note This function uses a global variable to store the last line end
character - it is not re-entrant-safe
@note Echo requires a full-duplex UART line interface, not supported with RS485
@note This is a blocking function !
*******************************************************************************/
char *BoardUartReadString ( char *dst, size_t maxlen, uint32_t timeout, int32_t echo)
{
/***************************************************************************
locals
***************************************************************************/
/* - */
return (DM2_uartReadStr (h_Uart, dst, maxlen, timeout, echo));
}
/*******************************************************************************
@brief write one character via the UART
@param c - character to write
@return true (1) if successful, false (0) if transmitter not ready
*******************************************************************************/
{
return ( DM2_uartWrite(h_Uart, c));
}
/*******************************************************************************
@brief read one character from the UART
@param c - pointer to character storage
@return true (1) if successful, false (0) if receiver empty
*******************************************************************************/
{
return (DM2_uartRead(h_Uart, c));
}
#endif
/******************************************************************************/
/* */
/* USB specific functions */
/* */
/******************************************************************************/
#ifdef _USBIO_H_
/*******************************************************************************
@brief Initialize USB
@param epnr - endpoints to use
@param callback user callback function
@return 0 - success
1 - "Error configuring endpoint" error
2 - "USB device already open" error
*******************************************************************************/
int BoardUsbInit ( int epnr, void(* callback)())
{
/***************************************************************************
locals
***************************************************************************/
unsigned int ret;
T_DM2_usbEndpoint ep; /* endpoint configuration */
/***************************************************************************
open USB device
***************************************************************************/
ret = DM2_usbOpen(0);
if (ret == 0)
{
/***********************************************************************
USB device already opened, try to re-open
***********************************************************************/
ret = DM2_usbOpen(0);
if (ret == 0)
{
return(2);
}
}
/***************************************************************************
configure USB endpoints
use EP1IN and EP1OUT in double buffered bulk mode
***************************************************************************/
if ( epnr & 1 )
{
ep.endpoint = 0x81; // EP1 IN (DSP to PC)
ep.attrib = 2; // bulk
ep.fs_size = 64; // max. packetsize in bytes
ep.hs_size = 512;
ep.fs_poll = 0; // polling intervall, 0 for bulk
ep.hs_poll = 0;
ep.dblbuf = 1; // double-buffered
{
return(1);
}
ep.endpoint = 0x01; // EP1 OUT (PC to DSP)
{
return(1);
}
} // if
if ( epnr & 2 )
{
ep.endpoint = 0x82; // EP2 IN (DSP to PC)
ep.attrib = 2; // bulk
ep.fs_size = 64; // max. packetsize in bytes
ep.hs_size = 512;
ep.fs_poll = 0; // polling intervall, 0 for bulk
ep.hs_poll = 0;
ep.dblbuf = 1; // double-buffered
{
return(1);
}
ep.endpoint = 0x02; // EP2 OUT (PC to DSP)
{
return(1);
}
} // if
/***************************************************************************
register USB callback function
***************************************************************************/
return(0);
}
/*******************************************************************************
@brief service USB events, re-map board events to USBIO events
@param -
@return pending events
*******************************************************************************/
uint32_t BoardUsbService ( void )
{
/***************************************************************************
locals
***************************************************************************/
uint32_t usbevt;
uint32_t usbioevt = 0;
/***************************************************************************
process USB standard requests;
the returned usbevt contains user events to process
***************************************************************************/
usbevt = DM2_usbIntService();
/***************************************************************************
map board specific event flags to USBIO driver flags
***************************************************************************/
if (usb_configured)
{
if (usbevt & DM2_USB_INTEVT_EP1TX)
{
usbioevt |= USBIO_INTEVT_EP1TX;
}
if (usbevt & DM2_USB_INTEVT_EP1RX)
{
usbioevt |= USBIO_INTEVT_EP1RX;
}
if (usbevt & DM2_USB_INTEVT_EP2TX)
{
usbioevt |= USBIO_INTEVT_EP2TX;
}
if (usbevt & DM2_USB_INTEVT_EP2RX)
{
usbioevt |= USBIO_INTEVT_EP2RX;
}
/***********************************************************************
return pending events
***********************************************************************/
return (usbioevt);
}
else
{
return (0);
}
}
/*******************************************************************************
@brief re-map USBIO events to board events, acknowledge USB events
@param events - events to acknowledge
@return -
*******************************************************************************/
void BoardUsbIntAck ( uint32_t events)
{
/***************************************************************************
locals
***************************************************************************/
uint32_t usbevt = 0;
if (events & USBIO_INTEVT_EP1TX)
{
}
if (events & USBIO_INTEVT_EP1RX)
{
}
if (events & USBIO_INTEVT_EP2TX)
{
}
if (events & USBIO_INTEVT_EP2RX)
{
}
DM2_usbIntAck (usbevt);
}
/*******************************************************************************
@brief write a data block
@param endpoint - endpoint
@param src - pointer to data source
@param cnt - number of bytes to write
@return number of bytes written
@note A maximum of maxp (max packet size) bytes will be written.
Typical values are 512 bytes for high-speed bulk transfers
and 64 bytes for full-speed bulk transfers
*******************************************************************************/
//~ size_t BoardUsbWriteBlock (uint32_t endpoint, void *src, size_t cnt)
//~ {
//~ return (DM2_usbWriteBlock (endpoint, src, cnt));
//~ }
/*******************************************************************************
@brief send a zero data packet
@param endpoint - endpoint
@return nothing
*******************************************************************************/
//~ void BoardUsbSendZeroPacket (int endpoint)
//~ {
//~ DM2_usbSendZeroPacket (endpoint);
//~ }
/*******************************************************************************
@brief read a data block
@param dst - pointer to destination
@param endpoint - endpoint
@return number of bytes read
@note If 0 is returned, the host has sent a zero data packet.
******************************************************************************/
//~ size_t BoardUsbReadBlock (void *dst, int endpoint)
//~ {
//~ return (DM2_usbReadBlock (dst, endpoint));
//~ }
#endif
/******************************************************************************/
/* */
/* Timer specific functions */
/* */
/******************************************************************************/
#ifdef INC_TIMER
/*******************************************************************************
@brief Initialize timer
@param timer_clock - PLL configured timer clock speed (in MHz)
@param port - timer port
@param utime - desired timer frequency in u-seconds
@return false - success
true - timer frequency not accessible
*******************************************************************************/
int BoardInitializeTimer ( uint32_t timer_clock, int port, uint32_t utime )
{
/***************************************************************************
locals
***************************************************************************/
if ( (port >= TIMER_DEVICE_CNT) && (port != -1) )
{
return (1);
}
if ( (utime == 0) || (timer_clock <1000000) )
{
return (1);
}
/***************************************************************************
close Timer if alread open
***************************************************************************/
if (hSystemTimer != INV)
{
TIMER_close (hSystemTimer);
}
/***************************************************************************
open and configure Timer
***************************************************************************/
if ((hSystemTimer = TIMER_open(port, TIMER_OPEN_RESET)) == INV)
{
return (1);
}
SystemTimerDev = ((Uint32)(hSystemTimer->baseAddr)==_TIMER_BASE_DEV0)?0:1;
TIMER_configArgs(hSystemTimer, 0x201, (timer_clock/1000000)*utime, 0); // ctl, per, cnt
return (0);
}
/*******************************************************************************
@brief install timer interrupt handler
@param cpuint - CPU interrupt
@param port - timer port
@param eventTimerHandler - timer interrupt handler
@return -
*******************************************************************************/
void BoardPlugTimerHandler (int32_t cpuint, int port, void (*eventTimerHandler)(void))
{
if ( (port >= TIMER_DEVICE_CNT) && (port != -1) )
{
}
if (hSystemTimer == INV)
{
}
/***************************************************************************
map interrupt vector table to address 0
map Timer event to CPU interrupt SYSTEM_TIMER_INT (valid: 4..15)
install Timer interrupt service
enable Timer event interrupts
***************************************************************************/
IRQ_setVecs((void*)0);
IRQ_map (IRQ_EVT_TINT0+SystemTimerDev, cpuint);
IRQ_hook(SYSTEM_TIMER_INT, (void *)(int)eventTimerHandler);
IRQ_enable(IRQ_EVT_TINT0+SystemTimerDev);
/***************************************************************************
global interrupt enable (NMI must be enabled too !)
***************************************************************************/
IRQ_nmiEnable();
IRQ_globalEnable();
}
/*******************************************************************************
@brief start timer
@param port - timer port
@return -
*******************************************************************************/
void BoardStartTimer ( int port)
{
if ( (port >= TIMER_DEVICE_CNT) && (port != -1) )
{
}
if (hSystemTimer == INV)
{
}
TIMER_start(hSystemTimer);
}
/*******************************************************************************
@brief stop timer
@param port - timer port
@return -
*******************************************************************************/
void BoardStopTimer ( int port)
{
if ( (port >= TIMER_DEVICE_CNT) && (port != -1) )
{
}
if (hSystemTimer == INV)
{
}
TIMER_pause(hSystemTimer);
}
#endif // INC_TIMER
/******************************************************************************/
/* */
/* LED specific functions */
/* */
/******************************************************************************/
/*******************************************************************************
Function LED_init
Turn all LEDs off
Parameter
Returns
Calls
*******************************************************************************/
void LED_init()
{
ledstate = 0;
}
/*******************************************************************************
Function LED_off
Parameter
Returns
Calls
*******************************************************************************/
void LED_off(unsigned int ledNum)
{
/* Check bounds for ledNum */
if (ledNum >= 4)
return;
/* Clear the LED bit */
ledstate &= ~(1 << ledNum);
}
/*******************************************************************************
Function LED_on
Parameter
Returns
Calls
*******************************************************************************/
void LED_on(unsigned int ledNum)
{
/* Check bounds for ledNum */
if (ledNum >= 4)
return;
/* Set the LED bit */
ledstate |= (1 << ledNum);
}
/*******************************************************************************
Function LED_toggle
Parameter
Returns
Calls
*******************************************************************************/
void LED_toggle(unsigned int ledNum)
{
unsigned int led_mask = 1 << (ledNum);
/* Check bounds for ledNum */
if (ledNum >= 4)
return;
/* Set the LED bit */
if ( ledstate & led_mask )
LED_off(ledNum);
else
LED_on(ledNum);
}
/*******************************************************************************
Function LED_state
Parameter
Returns
Calls
*******************************************************************************/
{
return (ledstate);
}
/******************************************************************************/
/* */
/* KEY specific functions */
/* */
/******************************************************************************/
/*******************************************************************************
Function KEY_init
*******************************************************************************/
void KEY_init(void)
{
//~ keystate = 0;
/***************************************************************************
Initialize KEYs
***************************************************************************/
}
/*******************************************************************************
Function KEY_pressed
*******************************************************************************/
int KEY_pressed (unsigned int keyNum)
{
/* Check bounds for keyNum */
//~ if ((keyNum >= SW1) && (keyNum <= SW0) )
//~ return ( EZDSP5502_I2CGPIO_readLine (keyNum) == 0);
//~ else
return 0;
}
/*******************************************************************************
the following functions are required for the MMCSPIDRIVE library
*******************************************************************************/
#ifdef INC_MMCSPIDRIVE
/*******************************************************************************
@brief detect SPI card
@details This function must be defined at user-level and is called from the
MMCSPI driver. The card detect signal is asserted by GPI and depends on
custom board design.
@param param - unused parameter
@return 1 - card inserted
@return 0 - card ejected
*******************************************************************************/
int CardDetect (uint32_t param)
{
(void)param;
/***************************************************************************
set GPO
***************************************************************************/
return ( (CARD_STATUS & DC_REG_STAT0) ? 0 : 1);
}
/*******************************************************************************
@brief select SPI card
@details This function must be defined at user-level and is called from the
MMCSPI driver. The card chip select signal is asserted by GPO and depends on
custom board design. For the DSK6713 by default the CPLD signal DC_REG_CNTL0
is used. Any free GPO may be used instead.
@param -
@return nothing
*******************************************************************************/
void SpiSelectCard ( void )
{
/***************************************************************************
set GPO
***************************************************************************/
SELECT_CARD;
}
/*******************************************************************************
@brief de-select SPI card
@details This function must be defined at user-level and is called from the
MMCSPI driver. The card chip select signal is asserted by GPO and depends on
custom board design. For the DSK6713 by default the CPLD signal DC_REG_CNTL0
is used. Any free GPO may be used instead.
@param -
@return nothing
*******************************************************************************/
void SpiDeselectCard ( void )
{
/***************************************************************************
set GPO
***************************************************************************/
DESELECT_CARD;
}
#endif // #ifdef _MMCSPI_H_