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 329 of 547
NXP Semiconductors
UM10398
Chapter 17: LPC11Cxx C_CAN on-chip drivers
17.4.14 CANopen SDO expedited write callback
The CANopen SDO expedited write callback function is called by the CANopen handler.
The callback passes on the new data and is called before the new data has been written,
allowing to reject or condition the data.
Example call:
// CANopen callback for expedited write accesses
uint32_t CANOPEN_sdo_exp_write(uint16_t index, uint8_t subindex, uint8_t
*dat_ptr)
{
// Writing 0xAA55 to entry [2001h,0] unlocks writing the config table
if ((index == 0x2001) && (subindex == 0))
if (*(uint16_t *)dat_ptr == 0xAA55)
{
write_config_ena = TRUE;
return(TRUE);
}
else
return(FALSE); // Reject any other value
}
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.15 CANopen SDO segmented read callback
The CANopen SDO segmented read callback function is called by the CANopen handler.
The callback function allows the following actions:
inform about the opening of the read channel.
provide data segments of up to seven bytes to the reading host.
close the channel when all data has been read.
abort the transmission at any time.
// Values for CANOPEN_sdo_seg_read/write() callback 'openclose' parameter
#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 (reading a buffer):
uint8_t read_buffer[0x123];
// CANopen callback for segmented read accesses
uint32_t CANOPEN_sdo_seg_read(
uint16_t index, uint8_t subindex, uint8_t openclose,
uint8_t *length, uint8_t *data, uint8_t *last)
{
static uint16_t read_ofs;
uint16_t i;