Open cartercooper opened 4 years ago
I recommend using a callback to receive messages rather than using a receive function.
I will change the I2C_channel_E channel to uint8_t address. I don't think it's necessary to list all the devices that use I2C in the code.
I will change the I2C_channel_E channel to uint8_t address. I don't think it's necessary to list all the devices that use I2C in the code.
I think it will be better to use I2C_channel_E. You're correct that it isn't necessary to list all devices in the I2C code. You can list the I2C devices in the I2C_componentSpecific files.
The I2C is for powerboard right? Just found that you said it's for motor cotroller 3?
The first thing we'll be using it for is probably the motor controller, but you should try to develop with the shared code in mind. The idea is to have shared code that is portable between different boards, with unique component specific files that have specific configuration (pins, # of channels, etc.) for each board/component we implement it on.
In regard of the parameter data in the receive function, according to Carter: I think the idea with that was that you pass the data pointer as a parameter, and the receive function points the data pointer at the data it received, then you're able to access the data you received outside of the function call. This is instead of the data being a return variable
Goal: An I2C driver for Motor Controller 3 and other STM32F4 boards. This code should follow the shared/componentSpecific format if needed, to be modular enough for use on multiple boards.
Constraints/API:
void I2C_init(void);
- initialize I2C pins and peripheral for componentvoid I2C_run(void);
- to run in one of the RTOS tasks - sends messages from send buffer - reads messages on receive bufferbool I2C_send(I2C_channel_E channel, const uint8_t * const data, const uint8_t length);
- places data on send buffer - returns true/false based on success/failbool I2C_receive(I2C_channel_E channel, const uint8_t * const data, const uint8_t length);
- receives I2C message and places on receive buffer.Notes: There is a good example of how to use the I2C peripheral in the repo for motorcontroller2. You can refer to that if you'd like. Feel free to modify constraints if necessary or if it's easier another way, I'm not as familiar as I'd like to be about I2C for STM32 yet.
Current Status
Next Steps