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

Split C2A communication functions prototype declaration header #630

Merged
merged 3 commits into from
Aug 25, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions src/components/real/cdh/c2a_communication.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* @file c2a_communication.h
* @brief C2A communication functions
*/

#ifndef C2A_COMMUNICATION_H_
#define C2A_COMMUNICATION_H_

// If the character encoding of C2A is UTF-8, the following functions are not necessary,
// and users can directory use SendFromObc_C2A and ReceivedByObc_C2A UART
// TODO: Delete these functions since C2A is changed to use UTF-8

// C2A communication functions
int OBC_C2A_SendFromObc(int port_id, unsigned char* buffer, int offset, int length);
int OBC_C2A_ReceivedByObc(int port_id, unsigned char* buffer, int offset, int length);

// I2C
int OBC_C2A_I2cWriteCommand(int port_id, const unsigned char i2c_address, const unsigned char* data, const unsigned char length);
int OBC_C2A_I2cWriteRegister(int port_id, const unsigned char i2c_address, const unsigned char* data, const unsigned char length);
int OBC_C2A_I2cReadRegister(int port_id, const unsigned char i2c_address, unsigned char* data, const unsigned char length);

// GPIO
int OBC_C2A_GpioWrite(int port_id, const bool is_high);
bool OBC_C2A_GpioRead(int port_id); // return false when the port_id is not used

#endif // C2A_COMMUNICATION_H_
18 changes: 1 addition & 17 deletions src/components/real/cdh/on_board_computer_with_c2a.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <components/ports/gpio_port.hpp>

#include "on_board_computer.hpp"
#include "c2a_communication.h"

/*
* @class ObcWithC2a
Expand Down Expand Up @@ -270,21 +271,4 @@ class ObcWithC2a : public OnBoardComputer {
static std::map<int, GpioPort*> gpio_ports_c2a_; //!< GPIO ports
};

// If the character encoding of C2A is UTF-8, the following functions are not necessary,
// and users can directory use SendFromObc_C2A and ReceivedByObc_C2A UART
// TODO: Delete these functions since C2A is changed to use UTF-8

// C2A communication functions
int OBC_C2A_SendFromObc(int port_id, unsigned char* buffer, int offset, int length);
int OBC_C2A_ReceivedByObc(int port_id, unsigned char* buffer, int offset, int length);

// I2C
int OBC_C2A_I2cWriteCommand(int port_id, const unsigned char i2c_address, const unsigned char* data, const unsigned char length);
int OBC_C2A_I2cWriteRegister(int port_id, const unsigned char i2c_address, const unsigned char* data, const unsigned char length);
int OBC_C2A_I2cReadRegister(int port_id, const unsigned char i2c_address, unsigned char* data, const unsigned char length);

// GPIO
int OBC_C2A_GpioWrite(int port_id, const bool is_high);
bool OBC_C2A_GpioRead(int port_id); // return false when the port_id is not used

#endif // S2E_COMPONENTS_REAL_CDH_OBC_C2A_HPP_
Loading