BoardSpecific.c File Reference

Board Specific Support Functions: Implementation More...

#include <BoardSupport/inc/stdtypes.h>
#include <stdlib.h>
#include <stdio.h>
#include <stddef.h>
#include <inttypes.h>
#include <time.h>
#include <string.h>
#include <Libs/NETlib/net.h>
#include <BoardSupport/inc/BoardSpecific.h>
#include <Common/Common.h>
#include <Common/uartio.h>
#include <Common/timer.h>
#include <Common/CPrintf.h>

Functions

void BoardAppInit (uint32_t dsp_clock)
 board specific initialization More...
 
void BoardPeripheralInit (void)
 board specific peripheral initialization More...
 
void BoardPeripheralClose (void)
 close board specific peripherals More...
 
void BoardInitializeInterrupts (void)
 initialize interrupts More...
 
void BoardEnableInterrupts (void)
 global enable interrupts More...
 
void BoardDisableInterrupts (void)
 
void BoardDisableEDMA (void)
 
void link_status (uint8_t mode)
 link status change callback function More...
 
uint16_t monitor_link_status (tpOutputFunc pLog)
 monitor link status change More...
 
uint16_t monitor_ip_address (tpOutputFunc pLog)
 monitor IP assignment More...
 
int InitializeNetwork (uint16_t icmp_size)
 Initialize MAC, sockets and protocols. More...
 
void LED_init ()
 
void LED_off (unsigned int ledNum)
 
void LED_on (unsigned int ledNum)
 
void LED_toggle (unsigned int ledNum)
 
uint16_t LED_state (void)
 
void KEY_init (void)
 
int KEY_pressed (unsigned int keyNum)
 

Variables

uint32_t DspClock =UINT32_C(0)
 
uint32_t TimerClock =UINT32_C(0)
 
char module_str [] = {"DM2DM642"}
 
char sym_animate [] = "-\\|/"
 
uint8_t _link_mode = 0xff
 
volatile uint16_t _link = 0
 
SOCKET * icmp_so
 
static unsigned int ledstate = 0
 

Detailed Description

                          _         _             _
                       __| |    ___(_) ____ _ __ | |_
                      / _` |   / __| |/ _` | '_ \| __|
                     | (_| | _ \__ \ | (_| | | | | |_
                      \__,_|(_) ___/_|\__, |_| |_|\__|
                     Signalprocessing |___/ Technology
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

Function Documentation

void BoardAppInit ( uint32_t  dsp_clock)
Parameters
dsp_clock[Hz]
Returns
nothing

Make board specific settings. Store or determine configured clocks. Call further board specific initialization functions for e.g PLL, EMIF, XINTF and prepare interrupts.

Examples:
BoardSpecific.c.
232 {
233  /***************************************************************************
234  locals
235  ***************************************************************************/
236 
238 // BoardDisableEDMA();
239 
240  /***************************************************************************
241  store DSP clock
242  ***************************************************************************/
243  DspClock = dsp_clock;
244  TimerClock = dsp_clock>>3;
245 
246  /***************************************************************************
247  basic initialisation, call bios function init_module()
248  ***************************************************************************/
249  DM2_init();
250 
251  /***************************************************************************
252  initialize interrupt system
253  ***************************************************************************/
254 #if (!(defined(USE_DSPBIOS) || defined(USE_SYSBIOS)))
255 // DM2_intInit (&DM2_intServiceTable);
256 #endif
257 }
void BoardDisableInterrupts(void)
Definition: BoardSpecific.c:383
far void DM2_init(void)
uint32_t DspClock
Definition: BoardSpecific.c:122
uint32_t TimerClock
Definition: BoardSpecific.c:123
void BoardPeripheralInit ( void  )
Parameters
-
Returns
nothing
Examples:
BoardSpecific.c.
267 {
268  /***************************************************************************
269  initialize Chip Support Library
270  ***************************************************************************/
271  CSL_init();
272 
273  /***************************************************************************
274  make SDRAM cacheable
275  ***************************************************************************/
276  CACHE_enableCaching(CACHE_EMIFA_CE00);
277  CACHE_enableCaching(CACHE_EMIFA_CE01);
278  CACHE_enableCaching(CACHE_EMIFA_CE02);
279  CACHE_enableCaching(CACHE_EMIFA_CE03);
280 
281  /***************************************************************************
282  initialize FLASH
283  ***************************************************************************/
284  DM2_flashOpen();
285 #ifdef USE_SPIDRIVE
286 
287 
288  /***************************************************************************
289  configure GPIO2 (PRGIO[6]) as input for card detect signal
290  ***************************************************************************/
291  // ConfigureCardDetect (6);
292  ConfigureCardDetect (15);
293 #endif
294 
295 }
far size_t DM2_flashOpen(void)
void BoardPeripheralClose ( void  )
Parameters
-
Returns
nothing
Examples:
BoardSpecific.c.
305 {
306  /***************************************************************************
307  stop timer
308  ***************************************************************************/
309 #ifdef INC_TIMER
310  StopSystemTimer ();
311 #endif
312  //~ TIMER(0)->ctl = 0x301;
313  //~ TIMER_close (h_timer[0]);
314  //~ TIMER_close (h_timer[1]);
315  //~ TIMER_close (h_timer[2]);
316  //~ TIMER_resetAll();
317 
318  /***************************************************************************
319  disable interrupt
320  ***************************************************************************/
321  _disable_interrupts();
322 
323  /***************************************************************************
324  disable DMA
325  ***************************************************************************/
326  //...
327 
328  /***************************************************************************
329  close peripherals
330  ***************************************************************************/
331 #ifdef _UARTIO_H_
332  if (h_Uart) DM2_uartClose (h_Uart);
333 #endif
334 
335 #ifdef _USBIO_H_
336  DM2_usbClose();
337 #endif
338 
339 }
far void DM2_usbClose(void)
far int DM2_uartClose(T_Handle h_uart)
void StopSystemTimer(void)
stop system timer
Definition: timer.c:461
T_Handle h_Uart
void BoardInitializeInterrupts ( void  )
Parameters
-
Returns
nothing
Examples:
BoardSpecific.c.
349 {
350 #if (!(defined(USE_DSPBIOS) || defined(USE_SYSBIOS)))
351 // if (intcInit() != intcInit_OK) // required only once
352 // {
353 // prg_exit ("error");
354 // }
355 #endif
356 }
void BoardEnableInterrupts ( void  )
Parameters
-
Returns
nothing
Examples:
BoardSpecific.c.
366 {
367  // DM2_intStart();
368  _enable_interrupts();
369 
370  /**************************************************************************
371  enable the bits for non maskable interrupt (0x02)
372  **************************************************************************/
373  IER |= 0x2;
374 }
void BoardDisableInterrupts ( void  )
Examples:
BoardSpecific.c.
384 {
385 
386  /***************************************************************************
387  clear CPU interrupts
388  ***************************************************************************/
389  IER = 0;
390  ICR = 0xFFFF;
391  CSR &= ~1;
392 
393 }
void BoardDisableEDMA ( void  )
Examples:
BoardSpecific.c.
403 {
404 // CSL_Edma3ccRegsOvly Edma3cc0Regs = (CSL_Edma3ccRegsOvly)CSL_EDMA3CC_0_REGS;
405 
406 // Edma3cc0Regs->IECR = 0xffffffff; // IER - Disable interrupts
407 // Edma3cc0Regs->EECR = 0xffffffff; // EER - Disable events
408 // Edma3cc0Regs->ICR = 0xffffffff; // ICR - Clear interrupts
409 // Edma3cc0Regs->ECR = 0xffffffff; // ICRH - Clear events
410 }
int InitializeNetwork ( uint16_t  icmp_size)
Parameters
icmp_size- space for ICMP (ping))
Returns
0 - success or >0 - error occurred
Examples:
BoardSpecific.c.
598 {
599  /***************************************************************************
600  locals
601  ***************************************************************************/
602  uint16_t buffer[3];
603  char uid[6];
604  static uint32_t NetInitStatus = 0; // not initialized
605 
606 
607  if (NetInitStatus) return (0);
608 
609  /***************************************************************************
610  initialize DM642 EMAC
611  possible values
612  mode: FDX_100, FDX_10, HDX_100, HDX_10, AUTO_NEG
613  MAC Address
614  link_status: callback function or NULL
615  ***************************************************************************/
616  if ( !DM2_EmacInit (eth.mode, eth.mac, link_status) )
617  {
618 #ifdef EMAC_DETAIL
619  return (1);
620 #else
621  prg_exit ("\r\nDM2_EmacInit() function failed\r\nEthernet defect"); /* initialize EMAC error */
622 #endif
623  }
624 
625 
626  /***************************************************************************
627  in case of DHCP create unique network name
628  ***************************************************************************/
629  if (!((eth.ip[0]-'0')<=9))
630  {
631  /***********************************************************************
632  read internal MAC address
633  ***********************************************************************/
634  get_mac_address (0, buffer);
635 
636  if ( strlen(eth.ip) < (30-5) ) // check space for MAC ID
637  {
638  /*******************************************************************
639  append lower MAC address bits to module name for unique host name.
640  eth.ip is defined in netconfig.c as a 30 byte char array. Don't
641  use host names larger than 30 bytes or increase the array size.
642  *******************************************************************/
643  sprintf (uid, "-%04X", htons(buffer[2]));
644  strcat (eth.ip, uid);
645  }
646  else
647  {
648 #ifdef EMAC_DETAIL
649  return (2);
650 #else
651  prg_exit ("\r\nhostname too long"); /* initialize EMAC error */
652 #endif
653  }
654  }
655 
656  /***************************************************************************
657  init sockets
658  1. parameter: own IP address or own HOST_NAME
659  2. parameter: subnet mask
660  3. parameter: gateway address
661  4. parameter NULL - own IP address is valid
662  DHCP_ENABLE - IP comes from a DHCP Server
663  own HOST_NAME is valid
664  5. parameter DNS Server IP or NULL
665  6. parameter DNS_ENABLE or NULL
666  ***************************************************************************/
667  if ( !net_init (eth.ip,
669  eth.gateway,
671  eth.dns,
672  eth.dns_setting))
673  {
674 #ifdef EMAC_DETAIL
675  return (3);
676 #else
677  prg_exit ("net_init() failed"); /* out of memory, try to increase heap */
678 #endif
679  }
680 
681  /***************************************************************************
682  in case of DHCP reset IP address
683  ***************************************************************************/
684  if (!((eth.ip[0]-'0')<=9))
685  {
686  set_ip_address (0, "0.0.0.0");
687  }
688 
689  /***************************************************************************
690  install icmp socket (for ping)
691  ***************************************************************************/
692  if ( (icmp_so = install_icmp_socket (icmp_size)) == NULL)
693  {
694 #ifdef EMAC_DETAIL
695  return (4);
696 #else
697  prg_exit ("ICMP socket error"); /* possibly insufficient heap */
698 #endif
699  }
700 
701  NetInitStatus = 1; // network initialized
702 
703  /***************************************************************************
704  success
705  ***************************************************************************/
706  return (0);
707 }
#define prg_exit(s)
Definition: Common.h:267
char dns[16]
Definition: net.h:171
int32_t net_init(char *ip, char *subnet, char *gateway, uint32_t(*dhcp_func)(char *, uint16_t), char *dns, uint32_t(*dns_func)(void))
Main network initialization function.
char mac[18]
Definition: net.h:169
#define NULL
Definition: net.h:126
void * DM2_EmacInit(uint8_t mode, char *mac_addr_str, void(*link_status)(unsigned char))
Initialize EMAC module.
unsigned short uint16_t
Definition: stdint.h:45
char subnet_mask[16]
Definition: net.h:172
char gateway[16]
Definition: net.h:173
SOCKET * icmp_so
Definition: BoardSpecific.c:148
uint32_t(* dhcp_setting)(char *, uint16_t)
Definition: net.h:168
unsigned int uint32_t
Definition: stdint.h:47
static char buffer[100]
Definition: blocksend.c:158
uint8_t mode
Definition: net.h:174
void link_status(uint8_t mode)
link status change callback function
Definition: BoardSpecific.c:434
char ip[31]
Definition: net.h:170
uint32_t get_mac_address(uint16_t dev_nr, uint16_t *dest)
Get MAC address.
uint32_t(* dns_setting)(void)
Definition: net.h:167
adapter_t eth
Definition: netconfig.c:62
uint32_t set_ip_address(uint16_t dev_nr, char *addr_str)
Set IP address.
static uint16_t htons(uint16_t val)
Convert a short int from host to network byte order.
Definition: net.h:1890
SOCKET * install_icmp_socket(uint16_t size)
Install an ICMP socket for ping and messages.
void LED_init ( )

Function LED_init

Turn all LEDs off

Parameter Returns Calls

Examples:
BoardSpecific.c.
1271 {
1272  ledstate = 0;
1273 }
static unsigned int ledstate
Definition: BoardSpecific.c:174
void LED_off ( unsigned int  ledNum)

Function LED_off

Parameter Returns Calls

Examples:
BoardSpecific.c.
1285 {
1286  /* Check bounds for ledNum */
1287  if (ledNum >= 4)
1288  return;
1289  /* Clear the LED bit */
1290  ledstate &= ~(1 << ledNum);
1291 }
static unsigned int ledstate
Definition: BoardSpecific.c:174
void LED_on ( unsigned int  ledNum)

Function LED_on

Parameter Returns Calls

Examples:
BoardSpecific.c.
1303 {
1304  /* Check bounds for ledNum */
1305  if (ledNum >= 4)
1306  return;
1307  /* Set the LED bit */
1308  ledstate |= (1 << ledNum);
1309 }
static unsigned int ledstate
Definition: BoardSpecific.c:174
void LED_toggle ( unsigned int  ledNum)

Function LED_toggle

Parameter Returns Calls

Examples:
BoardSpecific.c.
1321 {
1322  unsigned int led_mask = 1 << (ledNum);
1323  /* Check bounds for ledNum */
1324  if (ledNum >= 4)
1325  return;
1326  /* Set the LED bit */
1327  if ( ledstate & led_mask )
1328  LED_off(ledNum);
1329  else
1330  LED_on(ledNum);
1331 }
void LED_on(unsigned int ledNum)
Definition: BoardSpecific.c:1302
void LED_off(unsigned int ledNum)
Definition: BoardSpecific.c:1284
static unsigned int ledstate
Definition: BoardSpecific.c:174
uint16_t LED_state ( void  )

Function LED_state

Parameter Returns Calls

Examples:
BoardSpecific.c.
1343 {
1344  return (ledstate);
1345 }
static unsigned int ledstate
Definition: BoardSpecific.c:174
void KEY_init ( void  )

Function KEY_init

Examples:
BoardSpecific.c.
1359 {
1360  //~ keystate = 0;
1361  /***************************************************************************
1362  Initialize KEYs
1363  ***************************************************************************/
1364 }
int KEY_pressed ( unsigned int  keyNum)

Function KEY_pressed

Examples:
BoardSpecific.c.
1372 {
1373  UNREFERENCED_PARAMETER(keyNum);
1374  /* Check bounds for keyNum */
1375  //~ if ((keyNum >= SW1) && (keyNum <= SW0) )
1376  //~ return ( EZDSP5502_I2CGPIO_readLine (keyNum) == 0);
1377  //~ else
1378  return 0;
1379 
1380 }
#define UNREFERENCED_PARAMETER(P)
Definition: Common.h:115

Variable Documentation

uint32_t DspClock =UINT32_C(0)
Examples:
BoardSpecific.c.
uint32_t TimerClock =UINT32_C(0)
Examples:
BoardSpecific.c.
char module_str[] = {"DM2DM642"}
Examples:
BoardSpecific.c.
char sym_animate[] = "-\\|/"
Examples:
BoardSpecific.c.
uint8_t _link_mode = 0xff

use Operation Mode parameter to detect link mode FULL_DUPLEX 0x01 SPEED_100 0x04 SPEED_1000 0x20

Examples:
Blocksend.c, and BoardSpecific.c.
_link = 0

reflects the link status

Global variable that reflects the current link status:

  • 0 = no link
  • 1 = link established successfully
See also
BoardSpecific.c, link_status()
Warning
_link is only valid when the link-status callback function link_status() is used
Examples:
BoardSpecific.c, DNSTest.c, Ping2.c, Send.c, and SMTP.c.
SOCKET* icmp_so
Examples:
BoardSpecific.c, and Ping2.c.
unsigned int ledstate = 0
static
Examples:
BoardSpecific.c.