Datasheet

UM10398 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2014. All rights reserved.
User manual Rev. 12.3 — 10 June 2014 331 of 547
NXP Semiconductors
UM10398
Chapter 17: LPC11Cxx C_CAN on-chip drivers
#define CAN_SDOSEG_SEGMENT 0 // segment read/write
#define CAN_SDOSEG_OPEN 1 // channel is opened
#define CAN_SDOSEG_CLOSE 2 // channel is closed
Example call (writing a buffer):
uint8_t write_buffer[0x321];
// CANopen callback for segmented write accesses
uint32_t CANOPEN_sdo_seg_write(
uint16_t index, uint8_t subindex, uint8_t openclose,
uint8_t length, uint8_t *data, uint8_t *fast_resp)
{
static uint16_t write_ofs;
uint16_t i;
if ((index == 0x2200) && (subindex==0))
{
if (openclose == CAN_SDOSEG_OPEN)
{
// Initialize the write buffer
for (i=0; i<sizeof(write_buffer); i++)
{
write_buffer[i] = 0;
}
write_ofs = 0;
}
else if (openclose == CAN_SDOSEG_SEGMENT)
{
*fast_resp = TRUE; // Use fast 1-byte segment write response
i = length;
while (i && (write_ofs < sizeof(write_buffer)))
{
write_buffer[write_ofs++] = *data++;
i--;
}
if (i && (write_ofs >= sizeof(write_buffer))) // Too much data to write
{
return SDO_ABORT_TRANSFER; // Data could not be written
}
}
else if (openclose == CAN_SDOSEG_CLOSE)
{
// Write has successfully finished: mark the buffer valid etc.
}
return 0;
}
else
{
return SDO_ABORT_NOT_EXISTS;
}
}