ArduSat/libcsp — pull request #25 by bryanyw (2014-03-21 04:22:16+00:00)
Title: improvements to SAM3X CAN interface..like reset.

@jtrutna @jcappaert

- finally got CAN RESET correctly implemented. Previously, reset was being interfered with other types of transmissions that occur as a result of callbacks of ISRs that get woken up from, ironically, clearing the mailboxes. However, the mechanism to reset the CAN controller in the Atmel manual, was correct, but other transmissions made it look like it did not reset. I have added a loop to reset multiple times until the rx/tx errors are set to 0 (and CAN back in ERRA mode).

- added some more checks in can_send to return a failure immediately if 1) in Bus off mode, 2) if can is currently disabled (which it may be if a reset is occurring).

- turned down the "volume" of many CAN warnings we were getting, which was particularly verbose for an interface. I changed csp_log_warn to csp_log_info in places. The intention is not to hide issues ( one can 1. relay on the new GOSH "can if-status" command to see what the overall system status is. 2. turn on logs by typing "debug 3 1") but to reduce distracting output to the shell, especially as the beacon will be transmitting requests over CAN to other modules which may not be available in certain setups. It should be noted that the warnings I encountered are part-and-parcel with my test configuration and none indicated any alert for further research...except for ONE (see next bullet)

- fixed a stupid CSP thing that kept on reporting as an "error" that the buffer was "already free" when the CAN rx cleanup task attempted to clean buffer data. This is because it was indeed already freed after the call to send csp_transaction_persistent returned an error (e.g. a timeout). I added a check to look at the refcount before making a call to csp_buffer_free.