fix(MP/daemon): change frequency to period
This commit is contained in:
@@ -2,18 +2,19 @@
|
||||
#ifndef COMMON_IPC_H
|
||||
#define COMMON_IPC_H
|
||||
|
||||
#include <stdint.h>
|
||||
#define SOCKET_PATH "/tmp/regulator_daemon.sock"
|
||||
|
||||
/* Commands definitions */
|
||||
#define CMD_SET_MODE 10
|
||||
#define CMD_SET_FREQ 20
|
||||
#define CMD_INC_FREQ 30
|
||||
#define CMD_DEC_FREQ 40
|
||||
#define CMD_SET_MODE 10
|
||||
#define CMD_SET_PERIOD 20
|
||||
#define CMD_INC_PERIOD 30
|
||||
#define CMD_DEC_PERIOD 40
|
||||
|
||||
/* Structure of the message sent through IPC */
|
||||
typedef struct {
|
||||
int command;
|
||||
int value;
|
||||
uint32_t value;
|
||||
} ipc_msg_t;
|
||||
|
||||
#endif /* COMMON_IPC_H */
|
||||
|
||||
@@ -21,25 +21,25 @@ static void process_message(ipc_msg_t *msg) {
|
||||
switch (msg->command) {
|
||||
case CMD_SET_MODE:
|
||||
if (current_cbs.on_set_mode) {
|
||||
current_cbs.on_set_mode(msg->value);
|
||||
current_cbs.on_set_mode((int) msg->value);
|
||||
}
|
||||
break;
|
||||
|
||||
case CMD_SET_FREQ:
|
||||
if (current_cbs.on_set_frequency) {
|
||||
current_cbs.on_set_frequency(msg->value);
|
||||
case CMD_SET_PERIOD:
|
||||
if (current_cbs.on_set_period) {
|
||||
current_cbs.on_set_period((uint32_t) msg->value);
|
||||
}
|
||||
break;
|
||||
|
||||
case CMD_INC_FREQ:
|
||||
if (current_cbs.on_inc_frequency) {
|
||||
current_cbs.on_inc_frequency();
|
||||
case CMD_INC_PERIOD:
|
||||
if (current_cbs.on_inc_period) {
|
||||
current_cbs.on_inc_period();
|
||||
}
|
||||
break;
|
||||
|
||||
case CMD_DEC_FREQ:
|
||||
if (current_cbs.on_dec_frequency) {
|
||||
current_cbs.on_dec_frequency();
|
||||
case CMD_DEC_PERIOD:
|
||||
if (current_cbs.on_dec_period) {
|
||||
current_cbs.on_dec_period();
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
@@ -3,15 +3,17 @@
|
||||
|
||||
#include "../../common/common_ipc.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/*
|
||||
* Structure holding the callbacks for IPC commands.
|
||||
* Each function pointer will be called when the corresponding command is received.
|
||||
*/
|
||||
struct ipc_callbacks_t {
|
||||
void (*on_set_mode)(int mode);
|
||||
void (*on_set_frequency)(int freq);
|
||||
void (*on_inc_frequency)(void);
|
||||
void (*on_dec_frequency)(void);
|
||||
void (*on_set_period)(uint32_t period_ms);
|
||||
void (*on_inc_period)(void);
|
||||
void (*on_dec_period)(void);
|
||||
} ;
|
||||
|
||||
/**
|
||||
|
||||
@@ -35,9 +35,9 @@ int main(void) {
|
||||
btn_set_callback(btn_mode, mode_toggle);
|
||||
|
||||
struct ipc_callbacks_t ipc_cbs = {
|
||||
.on_dec_frequency = decrease_period,
|
||||
.on_inc_frequency = increase_period,
|
||||
// .on_set_frequency = set_period,
|
||||
.on_dec_period = decrease_period,
|
||||
.on_inc_period = increase_period,
|
||||
.on_set_period = set_period,
|
||||
.on_set_mode = set_mode,
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user