A while ago I put together a C driver for the MRF24J40 802.15.4 modules from microchip. I had been using them as a cheap alternative to xbees in some AVR projects. As I’ve been moving on to STM32 parts for hobby projects, (more power, cheaper) I started off porting my driver code from AVR over to cortex m3.
This has been quite an experience. The arm toolchain experience, and particularly the libc support and general documentation is completely different to, say, avr-libc (AVR-libc is a great project, reallly solid)
However, with lots of learning, and lots of mistakes, I’ve got it all working. It’s a first cut, but the basic features are there. There’s no magic for DMA, and you have to do a lot of the pin setup yourself, but this is Cortex M3, there’s so many pins you could be using for this! I’ve tried to reduce the required function calls as much as possible, but there’s still room for improvement.
// Required by the user code extern void mrf_select(void); // Chip select, if necessary extern void mrf_deselect(void); // chip deselect, if necessary extern uint8_t spi_tx(uint8_t cData); extern void _delay_ms(int); // only used at init time. |
This still needs to move to a clear sub project, currently it’s a separate code base to the AVR code.
Get the code now!
More to come, as it gets tidied up and put into use!
Leave a Comment