Skip to content

Commit

Permalink
Updated EUSART trx to use LDMA
Browse files Browse the repository at this point in the history
  • Loading branch information
edward62740 committed Jan 8, 2023
1 parent 93ccab6 commit 99fe0ed
Show file tree
Hide file tree
Showing 21 changed files with 24,703 additions and 24,703 deletions.
Binary file modified Documentation/pwr.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
310 changes: 155 additions & 155 deletions IPR/mg24_code/ipr/.cproject

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2,076 changes: 1,038 additions & 1,038 deletions IPR/mg24_code/ipr/.project

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion IPR/mg24_code/ipr/.projectlinkstore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"data":[{"hit":29,"alias":"main.c","type":"FILE","data":"C:/Users/Workstation/Desktop/IPR/IPR/mg24_code/ipr/main.c"},{"hit":20,"alias":"sleepy-mtd.c","type":"FILE","data":"C:/Users/Workstation/Desktop/IPR/IPR/mg24_code/ipr/sleepy-mtd.c"},{"hit":19,"alias":"app_coap.c","type":"FILE","data":"C:/Users/Workstation/Desktop/IPR/IPR/mg24_code/ipr/app_coap.c"},{"hit":17,"alias":"app_main.c","type":"FILE","data":"C:/Users/Workstation/Desktop/IPR/IPR/mg24_code/ipr/app_main.c"},{"hit":9,"alias":"Software Components","type":"NAVIGATION","data":"softwarecomponents"},{"hit":7,"alias":"opt3001.c","type":"FILE","data":"C:/Users/Workstation/Desktop/IPR/IPR/mg24_code/ipr/opt3001.c"},{"hit":5,"alias":"Stack (MTD)","type":"COMPONENT","data":"{\"componentId\":\"ot_stack_mtd\"}"},{"hit":4,"alias":"app_util.c","type":"FILE","data":"C:/Users/Workstation/Desktop/IPR/IPR/mg24_code/ipr/app_util.c"},{"hit":1,"alias":"UARTDRV USART (vcom)","type":"COMPONENT","data":"{\"componentId\":\"uartdrv_usart\",\"instanceName\":\"vcom\"}"},{"hit":1,"alias":"NVM3 Default Instance","type":"COMPONENT","data":"{\"componentId\":\"nvm3_default\"}"},{"hit":0,"alias":"README.md","type":"FILE","data":"C:/Users/Workstation/Desktop/IPR/IPR/mg24_code/ipr/README.md"},{"hit":0,"alias":"Pin Tool","type":"TOOL","data":"pintool"},{"hit":0,"alias":"Memory Editor","type":"TOOL","data":"memoryeditor"},{"hit":0,"alias":"docs.silabs.com","type":"EXTERNAL_URL","data":"https://docs.silabs.com/"},{"hit":1,"alias":"Device Init: DC-DC","type":"COMPONENT","data":"{\"componentId\":\"device_init_dcdc\"}"},{"hit":0,"alias":"Device Init: EMU","type":"COMPONENT","data":"{\"componentId\":\"device_init_emu\"}"},{"hit":0,"alias":"HFXO Manager","type":"COMPONENT","data":"{\"componentId\":\"hfxo_manager\"}"},{"hit":0,"alias":"Power Manager","type":"COMPONENT","data":"{\"componentId\":\"power_manager\"}"},{"hit":0,"alias":"Memory Configuration","type":"COMPONENT","data":"{\"componentId\":\"sl_memory\"}"},{"hit":0,"alias":"SPIDRV EUSART (radar)","type":"COMPONENT","data":"{\"componentId\":\"spidrv_eusart\",\"instanceName\":\"radar\"}"},{"hit":0,"alias":"I2CSPM (opt)","type":"COMPONENT","data":"{\"componentId\":\"i2cspm\",\"instanceName\":\"opt\"}"}]}
{"data":[{"hit":58,"alias":"main.c","type":"FILE","data":"C:/Users/Workstation/Desktop/IPR/IPR/mg24_code/ipr/main.c"},{"hit":32,"alias":"app_coap.c","type":"FILE","data":"C:/Users/Workstation/Desktop/IPR/IPR/mg24_code/ipr/app_coap.c"},{"hit":20,"alias":"sleepy-mtd.c","type":"FILE","data":"C:/Users/Workstation/Desktop/IPR/IPR/mg24_code/ipr/sleepy-mtd.c"},{"hit":19,"alias":"Software Components","type":"NAVIGATION","data":"softwarecomponents"},{"hit":18,"alias":"app_main.c","type":"FILE","data":"C:/Users/Workstation/Desktop/IPR/IPR/mg24_code/ipr/app_main.c"},{"hit":8,"alias":"Stack (MTD)","type":"COMPONENT","data":"{\"componentId\":\"ot_stack_mtd\"}"},{"hit":19,"alias":"SPIDRV EUSART (radar)","type":"COMPONENT","data":"{\"componentId\":\"spidrv_eusart\",\"instanceName\":\"radar\"}"},{"hit":7,"alias":"opt3001.c","type":"FILE","data":"C:/Users/Workstation/Desktop/IPR/IPR/mg24_code/ipr/opt3001.c"},{"hit":9,"alias":"DMADRV","type":"COMPONENT","data":"{\"componentId\":\"dmadrv\"}"},{"hit":4,"alias":"app_util.c","type":"FILE","data":"C:/Users/Workstation/Desktop/IPR/IPR/mg24_code/ipr/app_util.c"},{"hit":1,"alias":"UARTDRV USART (vcom)","type":"COMPONENT","data":"{\"componentId\":\"uartdrv_usart\",\"instanceName\":\"vcom\"}"},{"hit":1,"alias":"NVM3 Default Instance","type":"COMPONENT","data":"{\"componentId\":\"nvm3_default\"}"},{"hit":1,"alias":"Device Init: DC-DC","type":"COMPONENT","data":"{\"componentId\":\"device_init_dcdc\"}"},{"hit":1,"alias":"Device Init: EMU","type":"COMPONENT","data":"{\"componentId\":\"device_init_emu\"}"},{"hit":1,"alias":"HFXO Manager","type":"COMPONENT","data":"{\"componentId\":\"hfxo_manager\"}"},{"hit":1,"alias":"Power Manager","type":"COMPONENT","data":"{\"componentId\":\"power_manager\"}"},{"hit":0,"alias":"README.md","type":"FILE","data":"C:/Users/Workstation/Desktop/IPR/IPR/mg24_code/ipr/README.md"},{"hit":0,"alias":"Pin Tool","type":"TOOL","data":"pintool"},{"hit":0,"alias":"Memory Editor","type":"TOOL","data":"memoryeditor"},{"hit":0,"alias":"docs.silabs.com","type":"EXTERNAL_URL","data":"https://docs.silabs.com/"},{"hit":0,"alias":"Memory Configuration","type":"COMPONENT","data":"{\"componentId\":\"sl_memory\"}"},{"hit":0,"alias":"I2CSPM (opt)","type":"COMPONENT","data":"{\"componentId\":\"i2cspm\",\"instanceName\":\"opt\"}"},{"hit":0,"alias":"Device Init: HFXO","type":"COMPONENT","data":"{\"componentId\":\"device_init_hfxo\"}"},{"hit":0,"alias":"Device Init: LFXO","type":"COMPONENT","data":"{\"componentId\":\"device_init_lfxo\"}"},{"hit":0,"alias":"RAIL Utility, PA","type":"COMPONENT","data":"{\"componentId\":\"rail_util_pa\"}"},{"hit":0,"alias":"SPIDRV Core","type":"COMPONENT","data":"{\"componentId\":\"spidrv_core\"}"}]}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
fileModificationValidator.projectStoredChoice=false
75 changes: 64 additions & 11 deletions IPR/mg24_code/ipr/A111/integration/acc_hal_integration_efr.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,25 @@
* @brief Size of SPI transfer buffer
*/
#ifndef A111_SPI_MAX_TRANSFER_SIZE
#define A111_SPI_MAX_TRANSFER_SIZE 65535
#define A111_SPI_MAX_TRANSFER_SIZE 2048 // Maximum LDMA transfer
#endif

#define ACC_BOARD_REF_FREQ 26000000

// LDMA channels for receive and transmit servicing
#define RX_LDMA_CHANNEL 0
#define TX_LDMA_CHANNEL 1

// LDMA descriptor and transfer configuration structures for TX channel
LDMA_Descriptor_t ldmaTXDescriptor;
LDMA_TransferCfg_t ldmaTXConfig;

// LDMA descriptor and transfer configuration structures for RX channel
LDMA_Descriptor_t ldmaRXDescriptor;
LDMA_TransferCfg_t ldmaRXConfig;

volatile bool _await_ldma_spi;

static inline void disable_interrupts(void) {
__disable_irq();
}
Expand All @@ -48,26 +62,65 @@ static inline void enable_interrupts(void) {
__ISB();
}

void LDMA_IRQHandler()
{
uint32_t flags = LDMA_IntGet();

// Clear the transmit channel's done flag if set
if (flags & (1 << TX_LDMA_CHANNEL))
LDMA_IntClear(1 << TX_LDMA_CHANNEL);

/*
* Clear the receive channel's done flag if set and change receive
* state to done.
*/
if (flags & (1 << RX_LDMA_CHANNEL))
{
LDMA_IntClear(1 << RX_LDMA_CHANNEL);
_await_ldma_spi = true;
}

// Stop in case there was an error
if (flags & LDMA_IF_ERROR)
__BKPT(0);
}

//----------------------------------------
// Implementation of RSS HAL handlers
//----------------------------------------

static void acc_hal_integration_sensor_transfer(acc_sensor_id_t sensor_id,
uint8_t *buffer, size_t buffer_size) {
(void) sensor_id; // Ignore parameter sensor_id
uint8_t *buffer, size_t buffer_size) {
(void) sensor_id; // Ignore parameter sensor_id

GPIO_PinOutClear(A111_CS_PORT, A111_CS_PIN);
GPIO_PinOutClear(A111_CS_PORT, A111_CS_PIN);

__asm__("nop"); // no-op, CS set-up time
_await_ldma_spi = false;

/* Polling method appears to consume less current over time than interrupt */
for(size_t i=0; i<buffer_size; i++)
buffer[i] = EUSART_Spi_TxRx(EUSART0, buffer[i]);
// Source is outbuf, destination is EUSART1_TXDATA, and length if BUFLEN
ldmaTXDescriptor = (LDMA_Descriptor_t)LDMA_DESCRIPTOR_SINGLE_M2P_BYTE(buffer, &(EUSART1->TXDATA), buffer_size);

// De-assert chip select upon transfer completion (drive high)
GPIO_PinOutSet(A111_CS_PORT, A111_CS_PIN);
// Transfer a byte on free space in the EUSART FIFO
ldmaTXConfig = (LDMA_TransferCfg_t)LDMA_TRANSFER_CFG_PERIPHERAL(ldmaPeripheralSignal_EUSART1_TXFL);

// Source is EUSART1_RXDATA, destination is inbuf, and length if BUFLEN
ldmaRXDescriptor = (LDMA_Descriptor_t)LDMA_DESCRIPTOR_SINGLE_P2M_BYTE(&(EUSART1->RXDATA), buffer, buffer_size);

// Transfer a byte on receive FIFO level event
ldmaRXConfig = (LDMA_TransferCfg_t)LDMA_TRANSFER_CFG_PERIPHERAL(ldmaPeripheralSignal_EUSART1_RXFL);

LDMA_StartTransfer(RX_LDMA_CHANNEL, &ldmaRXConfig, &ldmaRXDescriptor);
LDMA_StartTransfer(TX_LDMA_CHANNEL, &ldmaTXConfig, &ldmaTXDescriptor);

// Wait in EM1 until all data is received
while (!_await_ldma_spi)
EMU_EnterEM1();

// De-assert chip select upon transfer completion (drive high)
GPIO_PinOutSet(A111_CS_PORT, A111_CS_PIN);
}


static void acc_hal_integration_sensor_power_on(acc_sensor_id_t sensor_id) {
(void) sensor_id; // Ignore parameter sensor_id

Expand All @@ -82,7 +135,7 @@ static void acc_hal_integration_sensor_power_off(acc_sensor_id_t sensor_id) {

GPIO_PinOutClear(A111_EN_PORT, A111_EN_PIN);
GPIO_PinOutClear(A111_CS_PORT, A111_CS_PIN);
acc_integration_sleep_ms(5);
//acc_integration_sleep_ms(5);
}

static bool acc_hal_integration_wait_for_sensor_interrupt(acc_sensor_id_t sensor_id, uint32_t timeout_ms) {
Expand Down
Binary file modified IPR/mg24_code/ipr/GNU ARM v10.2.1 - Default/ipr.axf
Binary file not shown.
2 changes: 1 addition & 1 deletion IPR/mg24_code/ipr/GNU ARM v10.2.1 - Default/ipr.axf.rsp

Large diffs are not rendered by default.

Binary file modified IPR/mg24_code/ipr/GNU ARM v10.2.1 - Default/ipr.bin
Binary file not shown.
Loading

0 comments on commit 99fe0ed

Please sign in to comment.