diff --git a/Source/main/ppi2c/pp_handler.cpp b/Source/main/ppi2c/pp_handler.cpp index 9a8a388..f80ff78 100644 --- a/Source/main/ppi2c/pp_handler.cpp +++ b/Source/main/ppi2c/pp_handler.cpp @@ -258,4 +258,13 @@ bool PPHandler::add_app(uint8_t *binary, uint32_t size) app_list.push_back({binary, size}); return true; +} + +void PPHandler::add_custom_command(uint16_t command, pp_i2c_command got_command, pp_i2c_command send_command) +{ + pp_custom_command_list_element_t element; + element.command = command; + element.got_command = got_command; + element.send_command = send_command; + custom_command_list.push_back(element); } \ No newline at end of file diff --git a/Source/main/ppi2c/pp_handler.hpp b/Source/main/ppi2c/pp_handler.hpp index 96039c7..30e3f3c 100644 --- a/Source/main/ppi2c/pp_handler.hpp +++ b/Source/main/ppi2c/pp_handler.hpp @@ -9,6 +9,9 @@ #include #include "driver/i2c.h" +/* + All callbasck are from IRQ, so a lot of things won't work from it. Also the code needs to be as fast as possible. +*/ class PPHandler { public: @@ -16,16 +19,16 @@ class PPHandler static void set_module_name(std::string name); // this will set the module name static void set_module_version(uint32_t version); // this will set the module version - static void set_get_features_CB(get_features_CB cb); // this will be called to get the features of the module see SupportedFeatures - static void set_get_gps_data_CB(get_gps_data_CB cb); // this will be called when the module asked for gps data - static void set_get_orientation_data_CB(get_orientation_data_CB cb); // this will be called when the module asked for orientation data - static void set_get_environment_data_CB(get_environment_data_CB cb); // this will be called when the module asked for environment data - static void set_get_light_data_CB(get_light_data_CB cb); // this will be called when the module asked for light data + static void set_get_features_CB(get_features_CB cb); // IRQ CALLBACK! this will be called to get the features of the module see SupportedFeatures + static void set_get_gps_data_CB(get_gps_data_CB cb); // IRQ CALLBACK! this will be called when the module asked for gps data + static void set_get_orientation_data_CB(get_orientation_data_CB cb); // IRQ CALLBACK! this will be called when the module asked for orientation data + static void set_get_environment_data_CB(get_environment_data_CB cb); // IRQ CALLBACK! this will be called when the module asked for environment data + static void set_get_light_data_CB(get_light_data_CB cb); // IRQ CALLBACK! this will be called when the module asked for light data static uint32_t get_appCount(); // this will return the app count static bool add_app(uint8_t *binary, uint32_t size); // this will add an app to the module.app size must be %32 == 0 - static void add_cutsom_command(pp_custom_command_list_element_t element); // this will add a custom command to the module, see pp_custom_command_list_element_t! + static void add_custom_command(uint16_t command, pp_i2c_command got_command, pp_i2c_command send_command); // Callbacks are from IRQ! This will add a custom command to the module, see pp_custom_command_list_element_t! private: // base working code diff --git a/Source/main/ppi2c/pp_structures.hpp b/Source/main/ppi2c/pp_structures.hpp index 37e544e..0a44e5a 100644 --- a/Source/main/ppi2c/pp_structures.hpp +++ b/Source/main/ppi2c/pp_structures.hpp @@ -86,8 +86,6 @@ typedef struct uint32_t binary_size; } standalone_app_info; -#define USER_COMMANDS_START 0x7F01 - enum class Command : uint16_t { COMMAND_NONE = 0, @@ -106,12 +104,6 @@ enum class Command : uint16_t COMMAND_GETFEAT_DATA_ORIENTATION, COMMAND_GETFEAT_DATA_ENVIRONMENT, COMMAND_GETFEAT_DATA_LIGHT, - // UART specific commands - COMMAND_UART_REQUESTDATA_SHORT = USER_COMMANDS_START, - COMMAND_UART_REQUESTDATA_LONG, - COMMAND_UART_BAUDRATE_INC, - COMMAND_UART_BAUDRATE_DEC, - COMMAND_UART_BAUDRATE_GET, }; @@ -132,14 +124,13 @@ typedef struct std::vector *data; } pp_command_data_t; -typedef void (*pp_got_command)(pp_command_data_t data); -typedef void (*pp_send_command)(pp_command_data_t data); +typedef void (*pp_i2c_command)(pp_command_data_t data); typedef struct { uint16_t command; - pp_got_command got_command; - pp_send_command send_command; + pp_i2c_command got_command; + pp_i2c_command send_command; } pp_custom_command_list_element_t; #endif \ No newline at end of file