Skip to content

Commit

Permalink
Merge pull request #630 from ut-issl/feature/split-c2a-communication-…
Browse files Browse the repository at this point in the history
…declaration-header

Split C2A communication functions prototype declaration header
  • Loading branch information
200km authored Aug 25, 2024
2 parents 4ed7960 + acf63db commit 67ebdc2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 17 deletions.
26 changes: 26 additions & 0 deletions src/components/real/cdh/c2a_communication.hpp
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 @@ -8,6 +8,7 @@

#include <components/ports/gpio_port.hpp>

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

/*
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_

0 comments on commit 67ebdc2

Please sign in to comment.