GLAST / LAT > DAQ and FSW > FSW > Doxygen Index> CTDB / V5-5-5 > co1553_bc / linux-gcc
#include <stdlib.h>
#include <string.h>
#include <CTDB/CO1553_bc.h>
#include <CTDB/CO1553_util.h>
#include <CCSDS/CCSDS_pkt.h>
#include <PBS/LI.h>
#include <PBS/FPA.h>
#include <PBS/TOC.h>
#include <PBS/MBA.h>
#include <MSG/MSG_pubdefs.h>
Defines | |
#define | MEM_ALLOC(_size) MBA_alloc((_size)) |
#define | MEM_FREE(_mem) MBA_free((_mem)) |
Functions | |
Command Receive Interface Functions | |
unsigned int | CO1553_bcCmdRxSizeof (void) |
unsigned int | CO1553_bcCmdRxInit (CO1553_BC_Cmd_Rx *cmd, unsigned int queueSize, unsigned int pktSize) |
Initialize an command receive interface descriptor. | |
unsigned int | CO1553_bcCmdRxExit (CO1553_BC_Cmd_Rx *cmd) |
Destroy an command receive interface descriptor. | |
unsigned int | CO1553_bcCmdRxMsg (CO1553_BC_Cmd_Rx *cmd, unsigned short *devPtr, CO1553_BC_Mem_Copy *copyFunc) |
Process a 1553 message transmit for the command receive interface. | |
unsigned int | CO1553_bcCmdRxPktSend (CO1553_BC_Cmd_Rx *cmd, void *pkt, CO1553_BC_Pkt_Free *freeHandler, void *freeArg, const TOC *timeout) |
Send a CCSDS command packet to the 1553 command receive interface. | |
Command Transmit Interface Functions | |
unsigned int | CO1553_bcCmdTxSizeof (void) |
unsigned int | CO1553_bcCmdTxInit (CO1553_BC_Cmd_Tx *cmd, unsigned int queueSize, unsigned int pktSize) |
Initialize an command transmit interface descriptor. | |
unsigned int | CO1553_bcCmdTxExit (CO1553_BC_Cmd_Tx *cmd) |
Destroy an command transmit interface descriptor. | |
unsigned int | CO1553_bcCmdTxMsg (CO1553_BC_Cmd_Tx *cmd, unsigned short *devPtr, CO1553_BC_Mem_Copy *copyFunc) |
Process a 1553 message transmit for the command transmit interface. | |
unsigned int | CO1553_bcCmdTxPktRecv (CO1553_BC_Cmd_Tx *cmd, void **pkt, const TOC *timeout) |
Receive a CCSDS command packet from the 1553 command transmit interface. | |
unsigned int | CO1553_bcCmdTxPktFree (CO1553_BC_Cmd_Tx *cmd, void *pkt) |
Free a CCSDS command transmit packet buffer. |
The functions are for use by a bus controller 1553 controller device driver.
#define MEM_ALLOC | ( | _size | ) | MBA_alloc((_size)) |
Helper macro to call user defined memory allocator.
_size | The size in bytes of memory to allocate. |
#define MEM_FREE | ( | _mem | ) | MBA_free((_mem)) |
Helper macro to call user defined memory allocator.
_mem | A pointer to the memory to free. |
unsigned int CO1553_bcCmdRxExit | ( | CO1553_BC_Cmd_Rx * | cmd | ) |
Destroy an command receive interface descriptor.
Release resources from a 1553 CCSDS command receive interface.
cmd | An command receive interface descriptor. |
References MEM_FREE, _CO1553_BC_Cmd_Rx::msg_buf, _CO1553_BC_Cmd_Rx::pkt_fpa, _CO1553_BC_Cmd_Rx::pkt_pool, and _CO1553_BC_Cmd_Rx::pkt_queue.
unsigned int CO1553_bcCmdRxInit | ( | CO1553_BC_Cmd_Rx * | cmd, | |
unsigned int | queueSize, | |||
unsigned int | pktSize | |||
) |
Initialize an command receive interface descriptor.
Initializes a 1553 CCSDS command receive packet interface for a bus controller. The command receive packet output queue is created.
cmd | An command receive interface descriptor. | |
queueSize | The maximum number of command packets to allow on the CCSDS output queue. | |
pktSize | The maximum size in bytes, including header, of a telecommand packet on this subaddress interface. |
References CO1553_MSG_SIZE, _CO1553_BC_Cmd_Rx::hdr_size, MEM_ALLOC, _CO1553_BC_Cmd_Rx::msg_buf, _CO1553_BC_Cmd_Rx::pkt_fpa, _CO1553_BC_Cmd_Rx::pkt_pool, _CO1553_BC_Cmd_Rx::pkt_queue, and _CO1553_BC_Cmd_Rx::pkt_size.
unsigned int CO1553_bcCmdRxMsg | ( | CO1553_BC_Cmd_Rx * | cmd, | |
unsigned short * | devPtr, | |||
CO1553_BC_Mem_Copy * | copyFunc | |||
) |
Process a 1553 message transmit for the command receive interface.
Announces the beginning of a new 1553 frame to the 1553 command receive packet interface. This function is called by a 1553 controller driver when the next bus frame has a telecommand receive transfer slot availble on the 1553 bus.
The packet output queue is seached for new packets ready for transmission. If a new command packet is available on the queue, a 1553 command message containing the packet is copied to the device.
cmd | An command interface descriptor. | |
devPtr | A pointer to the 1553 device memory where the first 1553 command message should be copied to. | |
copyFunc | A device specific memory copy function for accessing 1553 device memory. |
References CO1553_MSG_SIZE, CO1553_MSG_WORDS, _CO1553_BC_Pkt_Desc::free_arg, _CO1553_BC_Pkt_Desc::free_handler, _CO1553_BC_Cmd_Rx::msg_buf, _CO1553_BC_Cmd_Rx::pkt_fpa, _CO1553_BC_Pkt_Desc::pkt_ptr, _CO1553_BC_Cmd_Rx::pkt_queue, and _CO1553_BC_Pkt_Desc::pkt_size.
unsigned int CO1553_bcCmdRxPktSend | ( | CO1553_BC_Cmd_Rx * | cmd, | |
void * | pkt, | |||
CO1553_BC_Pkt_Free * | freeHandler, | |||
void * | freeArg, | |||
const TOC * | timeout | |||
) |
Send a CCSDS command packet to the 1553 command receive interface.
Places a CCSDS command receive packet on the bus controller command output queue. The command receive subaddress interface will remove packets from this queue and send them as fast as 1553 command receive message bandwidth allows.
The packet buffer memory remains allocated as long as the packet is on the output queue. After the packet has been transmitted, a user supplied callback freeHandler will be called to release the packet memory.
cmd | An command receive interface descriptor. | |
pkt | A pointer to the CCSDS packet header of the packet to send. | |
freeHandler | The packet buffer memory free callback. | |
freeArg | The argument passed to the freeHandler callback. | |
timeout | The number of system clock ticks to wait for a packet on the queue. |
References _CO1553_BC_Pkt_Desc::free_arg, _CO1553_BC_Pkt_Desc::free_handler, _CO1553_BC_Cmd_Rx::hdr_size, _CO1553_BC_Pkt_Desc::node, _CO1553_BC_Cmd_Rx::pkt_fpa, _CO1553_BC_Pkt_Desc::pkt_ptr, _CO1553_BC_Cmd_Rx::pkt_queue, _CO1553_BC_Pkt_Desc::pkt_size, and _CO1553_BC_Cmd_Rx::pkt_size.
unsigned int CO1553_bcCmdRxSizeof | ( | void | ) |
unsigned int CO1553_bcCmdTxExit | ( | CO1553_BC_Cmd_Tx * | cmd | ) |
Destroy an command transmit interface descriptor.
Release resources from a 1553 CCSDS telecommand transmit interface.
cmd | An command transmit interface descriptor. |
References MEM_FREE, _CO1553_BC_Cmd_Tx::pkt_fpa, _CO1553_BC_Cmd_Tx::pkt_pool, and _CO1553_BC_Cmd_Tx::pkt_queue.
unsigned int CO1553_bcCmdTxInit | ( | CO1553_BC_Cmd_Tx * | cmd, | |
unsigned int | queueSize, | |||
unsigned int | pktSize | |||
) |
Initialize an command transmit interface descriptor.
Initializes a 1553 CCSDS command transmit packet interface for a bus controller. The command transmit packet input queue is created.
cmd | An command transmit interface descriptor. | |
queueSize | The maximum number of command packets to allow on the CCSDS input queue. | |
pktSize | The maximum size in bytes, including header, of a telecommand packet on this subaddress interface. |
References CO1553_MSG_SIZE, _CO1553_BC_Cmd_Tx::hdr_size, MEM_ALLOC, _CO1553_BC_Cmd_Tx::pkt_fpa, _CO1553_BC_Cmd_Tx::pkt_pool, _CO1553_BC_Cmd_Tx::pkt_queue, _CO1553_BC_Cmd_Tx::pkt_size, and _CO1553_BC_Cmd_Tx::xfer_counter.
unsigned int CO1553_bcCmdTxMsg | ( | CO1553_BC_Cmd_Tx * | cmd, | |
unsigned short * | devPtr, | |||
CO1553_BC_Mem_Copy * | copyFunc | |||
) |
Process a 1553 message transmit for the command transmit interface.
Announces to the 1553 command transmit packet interface the reception of a 1553 command output message. This function is called by a 1553 controller driver when the next 1553 command message in a frame has been received by the 1553 device.
The next 1553 command message is copied from the device memory and is delivered to the command input queue as a CCSDS telecommand packet if the transfer request counter has updated.
cmd | A command transmit interface descriptor. | |
devPtr | A pointer to the 1553 device memory where the incomming 1553 message should be copied from. | |
copyFunc | A device specific memory copy function for accessing 1553 device memory. |
References CO1553_MSG_WORDS, _CO1553_BC_Cmd_Tx::hdr_size, _CO1553_BC_Cmd_Tx::pkt_fpa, _CO1553_BC_Cmd_Tx::pkt_queue, _CO1553_BC_Cmd_Tx::pkt_size, and _CO1553_BC_Cmd_Tx::xfer_counter.
unsigned int CO1553_bcCmdTxPktFree | ( | CO1553_BC_Cmd_Tx * | cmd, | |
void * | pkt | |||
) |
Free a CCSDS command transmit packet buffer.
Returns a borrowed CCSDS command packet buffer to the bus controller command transmit interface.
cmd | A command transmit interface descriptor. | |
pkt | A pointer to the packet buffer to free. |
References _CO1553_BC_Cmd_Tx::pkt_fpa.
unsigned int CO1553_bcCmdTxPktRecv | ( | CO1553_BC_Cmd_Tx * | cmd, | |
void ** | pkt, | |||
const TOC * | timeout | |||
) |
Receive a CCSDS command packet from the 1553 command transmit interface.
Attempts to get the next available command packet from the bus controller command packet input queue. The command packet transmit interface places new packets on this queue as 1553 command output messages arrive on the bus.
The packet buffer memory is loaned to the user. Call CO1553_bcCmdTxPktFree() to return the packet buffer to the remote terminal command interface.
cmd | A command transmit interface descriptor. | |
pkt | Upon success, a pointer to the packet buffer is returned here. | |
timeout | The time to wait for a packet on the queue. |
References _CO1553_BC_Cmd_Tx::pkt_queue.
unsigned int CO1553_bcCmdTxSizeof | ( | void | ) |