10.1.2 Setting Callbacks
The user can set their own callbacks using the following function pointer defined in the PL360 Host Controller descriptor:
typedef void (*pf_set_callbacks_t)(atpl360_dev_callbacks_t *dev_cb);
Parameters:
atpl360_dev_callbacks_t | Pointer to callbacks struct |
The structure used as the input of the pf_set_callbacks_t function contains the pointers to the functions to be executed for the different PL360 Host Controller events:
typedef struct atpl360_dev_callbacks {
pf_data_confirm_t data_confirm;
pf_data_indication_t data_indication;
pf_addons_event_t addons_event;
pf_exeption_event_t exception_event;
pf_handle_cb_t sleep_mode_cb;
pf_handle_cb_t debug_mode_cb;
} atpl360_dev_callbacks_t;
where:
- data_confirm function is used to notify of the result of the last message transmission
- data_indication function is used to notify of the reception of a new message
- addons_event function is used to notify that there is a new message to be sent to a PLC Microchip Tool
- exception_event function is used to notify of any exception which occurs in the communication with the PL360 device
- sleep_mode_cb function is used to notify when Sleep mode has been disabled. It’s strongly recommended to use this callback function to restore any additional configuration to PL360 device from user application.
- debug_mode_cb function is used to notify when Debug mode has been disabled. It’s strongly recommended to use this callback function to restore any additional configuration to PL360 device from user application.
Exception values are defined as
follows:
typedef enum {
ATPL360_EXCEPTION_UNEXPECTED_SPI_STATUS = 0, /* SPI has detected an unexpected status */
ATPL360_EXCEPTION_SPI_CRITICAL_ERROR, /* SPI critical error. */
ATPL360_EXCEPTION_RESET, /* Reset device */
} atpl360_exception_t;
Tip: SPI critical error means that
the PL360 firmware cannot be loaded into the PL360 device. A possible reason for this would
be that the SPI is not working properly.