variable size ble transmissions
This commit is contained in:
@@ -305,8 +305,11 @@ int main(void)
|
|||||||
|
|
||||||
if (usb_ready and total_tim6() - usb_buff.last_write > 4000) {
|
if (usb_ready and total_tim6() - usb_buff.last_write > 4000) {
|
||||||
extern dbl_buff<1024, usb_send> usb_buff;
|
extern dbl_buff<1024, usb_send> usb_buff;
|
||||||
extern dbl_buff<1024, uart_send> ble_buff;
|
|
||||||
usb_buff.send();
|
usb_buff.send();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (wb1mmc_ready and total_tim6() - ble_buff.last_write > 4000) {
|
||||||
|
extern dbl_buff<1024, uart_send> ble_buff;
|
||||||
ble_buff.send();
|
ble_buff.send();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,10 +97,11 @@ def update_with_data(ser, types):
|
|||||||
while (index < size):
|
while (index < size):
|
||||||
packet_type = cons[index]
|
packet_type = cons[index]
|
||||||
t = [t for t in types if t['type_code'] == packet_type][0]
|
t = [t for t in types if t['type_code'] == packet_type][0]
|
||||||
#print(index, packet_type, t['type_name'])
|
print(index, packet_type, t['type_name'])
|
||||||
d = cons[index + 1 : index + 1 + t['size']]
|
d = cons[index + 1 : index + 1 + t['size']]
|
||||||
if t['type_name'] == b'packet_imu':
|
if t['type_name'] == b'packet_imu':
|
||||||
process_imu(d, t)
|
pass
|
||||||
|
#process_imu(d, t)
|
||||||
if t['type_name'] == b'packet_msg':
|
if t['type_name'] == b'packet_msg':
|
||||||
print(d)
|
print(d)
|
||||||
index += 1 + t['size']
|
index += 1 + t['size']
|
||||||
|
|||||||
@@ -65,18 +65,18 @@ void PeriphCommonClock_Config(void);
|
|||||||
/* Private user code ---------------------------------------------------------*/
|
/* Private user code ---------------------------------------------------------*/
|
||||||
/* USER CODE BEGIN 0 */
|
/* USER CODE BEGIN 0 */
|
||||||
|
|
||||||
uint8_t uart_rx_data[1024];
|
uint8_t uart_rx_data[1028];
|
||||||
uint8_t uart_tx_data[1] = {'R'};
|
uint8_t uart_tx_data[1] = {'R'};
|
||||||
bool ready_for_data = false;
|
bool ready_for_data = false;
|
||||||
|
|
||||||
uint8_t notify_buffer[128];
|
volatile uint32_t xfer_len;
|
||||||
|
|
||||||
volatile bool do_notify = false;
|
volatile bool do_notify = false;
|
||||||
void SendNotifyTask(void) {
|
void SendNotifyTask(void) {
|
||||||
if (!do_notify) {
|
if (!do_notify) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (int i = 0; i < 8; ++i) {
|
for (int i = 0; 128 * i < xfer_len; ++i) {
|
||||||
Custom_STM_App_Update_Char(
|
Custom_STM_App_Update_Char(
|
||||||
CUSTOM_STM_ARRREAD,
|
CUSTOM_STM_ARRREAD,
|
||||||
uart_rx_data + i * 128
|
uart_rx_data + i * 128
|
||||||
@@ -84,12 +84,15 @@ void SendNotifyTask(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void HAL_UARTEx_RxEventCpltCallback(UART_HandleTypeDef *huart, uint16_t Size) {
|
void HAL_UARTEx_RxEventCallback(UART_HandleTypeDef *huart, uint16_t Size) {
|
||||||
//HAL_GPIO_TogglePin(GPIOA, LED4_Pin);
|
HAL_GPIO_TogglePin(GPIOA, LED5_Pin);
|
||||||
UTIL_SEQ_SetTask(1<<CFG_TASK_SEND_NOTIFY, UTIL_SEQ_RFU);
|
UTIL_SEQ_SetTask(1<<CFG_TASK_SEND_NOTIFY, UTIL_SEQ_RFU);
|
||||||
// Process data here or something
|
// Process data here or something
|
||||||
|
if (huart->gState == HAL_UART_STATE_READY) {
|
||||||
|
HAL_UART_Transmit_DMA(&huart1, uart_tx_data, sizeof(uart_tx_data));
|
||||||
|
}
|
||||||
|
xfer_len = Size;
|
||||||
HAL_UARTEx_ReceiveToIdle_DMA(&huart1, uart_rx_data, sizeof(uart_rx_data));
|
HAL_UARTEx_ReceiveToIdle_DMA(&huart1, uart_rx_data, sizeof(uart_rx_data));
|
||||||
HAL_UART_Transmit_DMA(&huart1, uart_tx_data, sizeof(uart_tx_data));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void HAL_UART_TXCpltCallback(UART_HandleTypeDef *huart) {}
|
void HAL_UART_TXCpltCallback(UART_HandleTypeDef *huart) {}
|
||||||
@@ -160,8 +163,8 @@ int main(void)
|
|||||||
HAL_Delay(1000); // Give the l452 time to start up
|
HAL_Delay(1000); // Give the l452 time to start up
|
||||||
HAL_GPIO_WritePin(GPIOA, LED4_Pin, GPIO_PIN_RESET);
|
HAL_GPIO_WritePin(GPIOA, LED4_Pin, GPIO_PIN_RESET);
|
||||||
HAL_GPIO_WritePin(GPIOA, LED5_Pin, GPIO_PIN_SET);
|
HAL_GPIO_WritePin(GPIOA, LED5_Pin, GPIO_PIN_SET);
|
||||||
|
__HAL_DMA_DISABLE_IT(huart1.hdmarx, DMA_IT_HT);
|
||||||
HAL_UARTEx_ReceiveToIdle_DMA(&huart1, uart_rx_data, sizeof(uart_rx_data));
|
HAL_UARTEx_ReceiveToIdle_DMA(&huart1, uart_rx_data, sizeof(uart_rx_data));
|
||||||
__HAL_DMA_DISABLE_IT(huart1.hdmarx, DMA_IT_HT);
|
|
||||||
HAL_UART_Transmit_DMA(&huart1, uart_tx_data, sizeof(uart_tx_data));
|
HAL_UART_Transmit_DMA(&huart1, uart_tx_data, sizeof(uart_tx_data));
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
/* Private includes ----------------------------------------------------------*/
|
/* Private includes ----------------------------------------------------------*/
|
||||||
/* USER CODE BEGIN Includes */
|
/* USER CODE BEGIN Includes */
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include "gpio.h"
|
||||||
/* USER CODE END Includes */
|
/* USER CODE END Includes */
|
||||||
|
|
||||||
/* Private typedef -----------------------------------------------------------*/
|
/* Private typedef -----------------------------------------------------------*/
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
#include "custom_stm.h"
|
#include "custom_stm.h"
|
||||||
|
|
||||||
/* USER CODE BEGIN Includes */
|
/* USER CODE BEGIN Includes */
|
||||||
#include "gpio.h"
|
#include "usart.h"
|
||||||
/* USER CODE END Includes */
|
/* USER CODE END Includes */
|
||||||
|
|
||||||
/* Private typedef -----------------------------------------------------------*/
|
/* Private typedef -----------------------------------------------------------*/
|
||||||
@@ -39,7 +39,7 @@ typedef struct{
|
|||||||
|
|
||||||
extern uint16_t Connection_Handle;
|
extern uint16_t Connection_Handle;
|
||||||
/* USER CODE BEGIN PTD */
|
/* USER CODE BEGIN PTD */
|
||||||
|
uint8_t uart_to_l452_data[1];
|
||||||
/* USER CODE END PTD */
|
/* USER CODE END PTD */
|
||||||
|
|
||||||
/* Private defines -----------------------------------------------------------*/
|
/* Private defines -----------------------------------------------------------*/
|
||||||
@@ -192,7 +192,10 @@ static SVCCTL_EvtAckStatus_t Custom_STM_Event_Handler(void *Event)
|
|||||||
{
|
{
|
||||||
return_value = SVCCTL_EvtAckFlowEnable;
|
return_value = SVCCTL_EvtAckFlowEnable;
|
||||||
/* USER CODE BEGIN CUSTOM_STM_Service_1_Char_1_ACI_GATT_ATTRIBUTE_MODIFIED_VSEVT_CODE */
|
/* USER CODE BEGIN CUSTOM_STM_Service_1_Char_1_ACI_GATT_ATTRIBUTE_MODIFIED_VSEVT_CODE */
|
||||||
HAL_GPIO_TogglePin(GPIOA, LED4_Pin);
|
if (attribute_modified->Attr_Data[0] != 'R') {
|
||||||
|
uart_to_l452_data[0] = attribute_modified->Attr_Data[0];
|
||||||
|
HAL_UART_Transmit_DMA(&huart1, uart_to_l452_data, 1);
|
||||||
|
}
|
||||||
/* USER CODE END CUSTOM_STM_Service_1_Char_1_ACI_GATT_ATTRIBUTE_MODIFIED_VSEVT_CODE */
|
/* USER CODE END CUSTOM_STM_Service_1_Char_1_ACI_GATT_ATTRIBUTE_MODIFIED_VSEVT_CODE */
|
||||||
} /* if (attribute_modified->Attr_Handle == (CustomContext.CustomArrwriteHdle + CHARACTERISTIC_VALUE_ATTRIBUTE_OFFSET))*/
|
} /* if (attribute_modified->Attr_Handle == (CustomContext.CustomArrwriteHdle + CHARACTERISTIC_VALUE_ATTRIBUTE_OFFSET))*/
|
||||||
/* USER CODE BEGIN EVT_BLUE_GATT_ATTRIBUTE_MODIFIED_END */
|
/* USER CODE BEGIN EVT_BLUE_GATT_ATTRIBUTE_MODIFIED_END */
|
||||||
|
|||||||
Reference in New Issue
Block a user