CAN bus message handler for the ATmega16M1
Files: api.h, api.c
The goal of this CAN API is to abstract the inner mechanisms of the CAN bus away from each individual sensor node. Nodes do not have to interact with the registers of the CAN controller, they need only use the available API methods.
Each node implementing this API has access to 2 methods (initCan and sendCANmsg) and must implement 1 method of its own in order to use the API (handleCANmsg). Please see the demo in this project for an example of these methods in use.
In order to use this API, you need to implement handleCANmsg, even if you do not intend to send any messages to a given chip. See api.h for more info on implementing this method.
Git subtree is a tool to embed a repository inside of another repository. This is desirable because we want to be able to embed AVR-CAN inside of all of REVO's other repositories. Follow the instructions below to add or update this repo as a subtree.
- From the top level of your repository, run the following command:
git subtree add --prefix=src/AVR-CAN git@github.com:OlinREVO/AVR-CAN.git master --squash
- Find the line in your Makefile that starts with CFLAGS. Add "-Isrc/AVR-CAN/" to the end of it. This allows gcc to find api.h.
- Add src/AVR-CAN/ to your list of sources. You may be able to do that using a line such as "SOURCES += src/AVR-CAN/", but this will vary based on your Makefile.
- You will need to commit and push these changes to make them visible to others.
- From the top level of your repository, run the following command:
git subtree pull --prefix=src/AVR-CAN git@github.com:OlinREVO/AVR-CAN.git master --squash
- You will need to commit and push these changes to make them visible to others.
For demo code using the CAN API, check out the 'demos' branch of this repository.