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 330 of 547
NXP Semiconductors
UM10398
Chapter 17: LPC11Cxx C_CAN on-chip drivers
if ((index == 0x2200) && (subindex==0))
{
if (openclose == CAN_SDOSEG_OPEN)
{
// Initialize the read buffer with "something"
for (i=0; i<sizeof(read_buffer); i++)
{
read_buffer[i] = (i+5) + (i<<2);
}
read_ofs = 0;
}
else if (openclose == CAN_SDOSEG_SEGMENT)
{
i = 7;
while (i && (read_ofs < sizeof(read_buffer)))
{
*data++ = read_buffer[read_ofs++];
i--;
}
*length = 7-i;
if (read_ofs == sizeof(read_buffer)) // The whole buffer read:
// this is last segment
{
*last = TRUE;
}
}
return 0;
}
else
{
return SDO_ABORT_NOT_EXISTS;
}
}
Remark: If the flag isr_handled was set TRUE when initializing CANopen, this callback
function will be called by the CAN API interrupt handler and therefore will execute on the
interrupt level.
17.4.16 CANopen SDO segmented write callback
The CANopen SDO segmented write callback function is called by the CANopen handler.
The callback function allows the following actions:
inform about the opening and closing of the write channel.
pass on data segments of up to seven bytes from the writing host.
abort the transmission at any time, for example when there is a buffer overflow.
Responses can be selected to be 8-byte (CANopen standard compliant) or 1-byte (faster
but not supported by all SDO clients).
// Values for CANOPEN_sdo_seg_read/write() callback 'openclose' parameter