Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FreeRTOS: A few small fixes to make the FreeRTOS port simpler #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

alistair23
Copy link

This contains two commits that help when porting to FreeRTOS.

@ghost
Copy link

ghost commented Nov 19, 2020

CLA assistant check
All CLA requirements met.

@alistair23
Copy link
Author

Ping!

1 similar comment
@alistair23
Copy link
Author

Ping!

Add a default send and receive function that can be used.
Currently cmd_channel_freertos.c includes a receive and send function,
but these can't directly be called from struct cmd_channel. Let's add
default implementations that can be used.

The queue being global allows it to be accessed from interrupt service
routines (ISRs) which is generally where the data will be processed, at
least for receives.

Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
void cmd_channel_packet_default_init (struct cmd_channel *channel)
{
channel->receive_packet = cmd_channel_receive_packet;
channel->send_packet = cmd_channel_send_packet;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're looking to turn this into a proper implementation of cmd_channel and do it in way that is consistent with the overall architecture and existing coding style, we would do the following:

  1. Define a new 'struct cmd_channel_freertos' that derives from cmd_channel. This new structure would contain the Rx and Tx queues necessary for receive_packet and send_packet, removing the dependencies on any global context.
  2. Create cmd_channel_freertos_init and cmd_channel_freertos_release functions to initialize and free the instance. The init function returns int (returning error for null parameters), while release returns void (probably with an empty implementation since nothing would be internally created).
  3. The init function would take the cmd_channel_freertos instance to initialize and the Rx and Tx queue instances to use with the channel. It would save these internally and set the function pointers.
  4. The functions you have here as cmd_channel_receive_packet/send_packet would be named cmd_channel_freertos_receive_packet/send_packet, which would probably require a name change of the existing functions. No comment block is necessary on these functions since they are implementations of a base API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants