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

Clean The IMU code example to fit new Luos implementation. #498

Merged
merged 2 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion examples/projects/l0/gate_serialcom/node_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
* INIT_TIME | 150 | Wait init time before first detection
******************************************************************************/
#define GATE_BUFF_SIZE 1024
#define PIPE_TX_BUFFER_SIZE 1024
#define PIPE_TX_BUFFER_SIZE 2048
#define PIPE_RX_BUFFER_SIZE 2048

/*******************************************************************************
Expand Down
18 changes: 0 additions & 18 deletions examples/projects/l0/imu/include/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,30 +93,12 @@ void Error_Handler(void);
#define INVEN_INT_EXTI_IRQn EXTI0_1_IRQn
#define CS_Pin GPIO_PIN_1
#define CS_GPIO_Port GPIOA
#define POWER_SENSOR_Pin GPIO_PIN_2
#define POWER_SENSOR_GPIO_Port GPIOA
#define LED_Pin GPIO_PIN_3
#define LED_GPIO_Port GPIOA
#define COM_LVL_DOWN_Pin GPIO_PIN_5
#define COM_LVL_DOWN_GPIO_Port GPIOA
#define COM_LVL_UP_Pin GPIO_PIN_6
#define COM_LVL_UP_GPIO_Port GPIOA
#define SCL_Pin GPIO_PIN_10
#define SCL_GPIO_Port GPIOB
#define SDA_Pin GPIO_PIN_11
#define SDA_GPIO_Port GPIOB
#define PTPB_Pin GPIO_PIN_13
#define PTPB_GPIO_Port GPIOB
#define RX_EN_Pin GPIO_PIN_14
#define RX_EN_GPIO_Port GPIOB
#define TX_EN_Pin GPIO_PIN_15
#define TX_EN_GPIO_Port GPIOB
#define PTPA_Pin GPIO_PIN_8
#define PTPA_GPIO_Port GPIOA
#define COM_TX_Pin GPIO_PIN_9
#define COM_TX_GPIO_Port GPIOA
#define COM_RX_Pin GPIO_PIN_10
#define COM_RX_GPIO_Port GPIOA
/* USER CODE BEGIN Private defines */
#define FIRM_REV "0.5.1"
void gyro_data_ready_cb(void);
Expand Down
42 changes: 13 additions & 29 deletions examples/projects/l0/imu/lib/Imu/imu.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
******************************************************************************/
#include "main.h"
#include "imu.h"
#include <mpu_configuration.h>
#include "mpu_configuration.h"
#include "data_builder.h"

/*******************************************************************************
* Definitions
Expand All @@ -18,10 +19,6 @@
volatile uint32_t hal_timestamp = 0;
unsigned char *mpl_key = (unsigned char *)"eMPL 5.1";

service_t *service_pointer;
volatile msg_t pub_msg;
volatile int pub = LUOS_LAST_STD_CMD;

/*******************************************************************************
* Function
******************************************************************************/
Expand All @@ -36,6 +33,7 @@ void Imu_Init(void)
{
revision_t revision = {.major = 1, .minor = 0, .build = 0};
mpu_setup();
HAL_GPIO_WritePin(GPIOA, LED_Pin, GPIO_PIN_RESET);
hal.report.quat = 1;
Luos_CreateService(Imu_MsgHandler, IMU_TYPE, "Imu", revision);
}
Expand All @@ -46,11 +44,15 @@ void Imu_Init(void)
******************************************************************************/
void Imu_Loop(void)
{
if (!Luos_IsDetected())
{
return;
}

// *********************IMU management*******************************
unsigned long sensor_timestamp;
unsigned long timestamp;
unsigned long timestamp = Luos_GetSystick();
int new_data = 0;
timestamp = HAL_GetTick();
static unsigned char new_temp = 0;
#ifdef COMPASS_ENABLED
static unsigned char new_compass = 0;
Expand Down Expand Up @@ -226,11 +228,6 @@ void Imu_Loop(void)
* rate requested by the host.
*/
}
if (hal.update_request == 1)
{
read_from_mpl(service_pointer);
hal.update_request = 0;
}
}
/******************************************************************************
* @brief Msg Handler call back when a msg receive for this service
Expand All @@ -242,19 +239,15 @@ static void Imu_MsgHandler(service_t *service, const msg_t *msg)
{
if (msg->header.cmd == GET_CMD)
{
// fill the message infos
hal.update_request = 1;
service_pointer = service;
hal.source_id = msg->header.source;
pub = LUOS_LAST_STD_CMD;
// Fill the message infos
hal.source_id = msg->header.source;
read_from_mpl(service);
return;
}
if (msg->header.cmd == PARAMETERS)
{
service_pointer = service;
// fill the message infos
// Get the message infos
memcpy(&hal.report, msg->data, sizeof(short));
pub = LUOS_LAST_STD_CMD;
return;
}
}
Expand All @@ -266,12 +259,3 @@ void gyro_data_ready_cb(void)
{
hal.new_gyro = 1;
}

void HAL_SYSTICK_Callback(void)
{
if (pub != LUOS_LAST_STD_CMD)
{
Luos_SendMsg(service_pointer, (msg_t *)&pub_msg);
pub = LUOS_LAST_STD_CMD;
}
}
Loading
Loading