20 #define _IPM_RX_TIMEOUT_MARK 0xFFFFFFFF // value returned by read function on to
21 #define _IPM_RX_TIMEOUT 20 // tx word timeout
22 #define _IPM_TX_GRANT_TIMEOUT 100 // tx grant timeout
25 #define _MAC_LO(ARR) ( ( ( ARR[1] ) << 16 ) | ( ARR )[2] )
27 #define _MAC_HI(ARR) ( ( ARR )[0] )
30 static void ipMuxCfgMod(
IpMuxCfg * cfg)
37 for (i = 0; i < 4; ++i)
47 static void ipMuxCfgSvr(
IpMuxCfg * cfg)
54 for (i = 0; i < 4; ++i)
79 return !(
IPMCTRL->ACSR & IPM_ACSR_EMPTY(IPM_CH_C));
83 static inline bool ipMuxWaitRx()
87 while (
IPMCTRL->ACSR & IPM_ACSR_EMPTY(IPM_CH_C))
96 bool ipMuxRx(
void * buf, uint32_t buflen, uint32_t * rxlen)
98 uint16_t * rx = (uint16_t *)buf;
102 if (!ipMuxWaitRx()) {
111 bool sopFound =
true;
115 volatile unsigned int * ptr =
IPMFIFO;
127 if (!ipMuxWaitRx()) {
151 bool ipMuxTx(
void * buf, uint32_t txlen,
bool done)
168 uint16_t * tx = (uint16_t *)buf;
170 int len = (txlen + 1) >> 1;
174 static volatile unsigned int * ptr =
IPMFIFO;
177 for (i = 0; i < len; ++i) {
195 while ( (
IPMPKGEN->TXSTM_INFO & IPM_TXSTM_INFO_PKT_DONE(mask) ) != IPM_TXSTM_INFO_PKT_DONE(mask))
201 if (ipmFlushOp & IPMUX_FLUSH_OP_START)
IPMCTRL->ACSR = acsr | IPM_ACSR_FLUSH(mask);
202 if (ipmFlushOp & IPMUX_FLUSH_OP_END)
IPMCTRL->ACSR = acsr & ~IPM_ACSR_FLUSH_MASK;
207 printf(
"IpMux dump\n");
208 printf(
"- ACSR : %08x\n",
IPMCTRL->ACSR);
209 printf(
"- MAC_SVR : %04x%08x\n",
IPMCTRL->MAC_SVR_HI,
IPMCTRL->MAC_SVR_LO);
210 printf(
"- MAC_MOD : %04x%08x\n",
IPMCTRL->MAC_MOD_HI,
IPMCTRL->MAC_MOD_LO);
211 uint8_t * ip = (uint8_t *) &
IPMCTRL->IP_SVR;
212 printf(
"- IP_SRV : %d.%d.%d.%d\n", ip[0], ip[1], ip[2], ip[3]);
213 ip = (uint8_t *) &
IPMCTRL->IP_MOD;
214 printf(
"- IP_MOD : %d.%d.%d.%d\n", ip[0], ip[1], ip[2], ip[3]);
215 printf(
"- PORTS : %04x %04x %04x %04x\n",
#define IPMCTRL
IPMux Control.
void ipMuxCfgRemote(IpMuxCfg *svrCfg)
Configure IPmux with remote settings.
#define IPM_FIFO_EOP
End of packet marker.
bool ipMuxTx(void *buf, uint32_t txlen, bool done)
Sends data to the IPMux's CPU interface.
#define IPM_UDP_PORT_SVR_SHIFT
Shift for server port.
#define IPM_ACSR_TX_REQ
TX request.
#define IPMUX_CH_CPU
CPU channel.
IPMux configuration structure.
bool ipMuxRx(void *buf, uint32_t buflen, uint32_t *rxlen)
Received data from the IPMux's CPU interface.
#define IPMPKGEN
IPMux Control.
void ipMuxFlush(uint32_t channelMask, uint8_t ipmFlushOp)
Flushes the IPMUX's FIFO's.
void ipMuxDumpRegs()
Debug function to see whats inside.
static void ipMuxFlushCPU()
Flushes the.
bool ipMuxRxAvail()
Returns whether or not there is data available for reception.
#define IPM_ACSR_TX_GRANT
TX grant.
static uint32_t timeOutInit(uint32_t msec)
Initializes a timeout with the specified no of msecs.
uint16_t mac[3]
MAC address.
static bool timeOut(uint32_t to)
Checks whether or not the timeout has expired.
Manages the global system error.
#define IPM_UDP_PORT_MOD_MASK
Mask for module port (source)
void ipMuxInit(IpMuxCfg *modCfg, bool flush)
Initializes the IPMux local (module) only.
#define IPM_UDP_PORT_MOD_SHIFT
Shift for module port.
#define E_OUTOFMEMORY
Generic error: There is no more memory.
This module is responsible for distributing error codes.
Various useful functions.
#define E_TIMEOUT
Generic error: Timeout error.
#define IPM_FIFO_DATA_MASK
Data mask.
#define LOG_DEF(NAME,...)
Define a logger for a module.
uint16_t prt[4]
Port numbers.
This file assigns all device structures to memory mapped structures.
bool errSet(uint32_t code, const char *error, const char *name)
Sets an error.
#define ERROR(CODE,...)
Expands an error code to an error code with a description (if ERROR_W_DESCR is declared).
#define IPM_FIFO_SOP
Start of packet marker.
Implements a generic logger facility.
#define IPM_UDP_PORT_SVR_MASK
Mask for server port (target)
#define IPMFIFO
IPMux FIFO.
#define IPM_FIFO_DATA_SHIFT
Data shift.