API
The baud rate of the CAN component is set by the BAUD_RATE define in the CanIncludes.h
file.
-
void initPacket(struct CanPacket &p)
Clear the fields in a packet structure to zero.
-
void randomizePacket(struct CanPacket &p, int bitZero)
Produce a random packet in the given packet structure.
Parameters: |
- p – The packet to randomize
- bitZero – The least significant bit of the ID field
|
-
void sendPacket(chanend c, struct CanPacket &p)
Send a packet to the CAN PHY thread.
Parameters: |
- c – The transmit channel linked to the CAN Phy thread
- p – The packet structure to transmit
|
Before calling this function, a single word should be pushed into the transmit channel, using outuint(c,0)
-
void receivePacket(chanend c, struct CanPacket &p)
Receive a packet from the CAN Phy thread.
Parameters: |
- c – The receive channel of the CAN Phy thread
- p – The packet structure to receive data into
|
The CAN Phy thread will preceed the packet with a single unsigned integer. This integer must be consumed, either using an inuint(), or by selecting on the channel in a select statement block using inuint_byref()
-
void canPhyRxTx(chanend rxChan, chanend txChan, clock clk, buffered in port:32 canRx, port canTx)
The top level thread function for the CAN Phy interface.
Parameters: |
- rxChan – The channel to receive packets from the CAN Phy thread
- txChan – The channel to send packets to the CAN Phy thread
- clk – A clock block for associating with the CAN interface
- canRx – The CAN Rx port, a one bit port which is operated in buffered mode
- canTx – The CAN Tx port, a one bit port
|