~joshrig/tuna

00368e5dee4a3665f016f069aa3b3fe8b196dfb6 — Joshua Lynch a month ago 4a1795c
move back to using 16bit samples
1 files changed, 18 insertions(+), 18 deletions(-)

M src/daq.c
M src/daq.c => src/daq.c +18 -18
@@ 47,7 47,7 @@ struct shm
typedef struct daq_state daq_state_t;
struct daq_state
{
    __IO uint32_t dma_buf[N_DMA_SAMPLES];
    __IO uint16_t dma_buf[N_DMA_SAMPLES];

    shm_t         shm;
    


@@ 76,7 76,7 @@ void daq_init(void)
    me->shm.valid         = false;
    me->daq_enabled       = false;

    memset((void *)me->dma_buf, 0, N_DMA_SAMPLES * sizeof(uint32_t));
    memset((void *)me->dma_buf, 0, N_DMA_SAMPLES * sizeof(uint16_t));


    dma_init();


@@ 95,20 95,6 @@ void daq_init(void)
}


void daq_set_shm_cmd(uint32_t addr, uint32_t len)
{
    // this will evaluate true if len is NOT a power of 2
    if (len & (len - 1))
        return;

    
    me->shm.buf   = (uint32_t *)addr;
    me->shm.len   = len;
    me->shm.nsamp = len / sizeof(uint32_t);
    me->shm.valid = true;
}


void daq_start_simulation_cmd()
{
    if (me->daq_enabled == true || me->shm.valid == false)


@@ 141,6 127,20 @@ static void sim_task(void *ctxt)
}


void daq_set_shm_cmd(uint32_t addr, uint32_t len)
{
    // this will evaluate true if len is NOT a power of 2
    if (len & (len - 1))
        return;

    
    me->shm.buf   = (uint32_t *)addr;
    me->shm.len   = len;
    me->shm.nsamp = len / sizeof(uint32_t);
    me->shm.valid = true;
}


void daq_clear_shm_cmd(void)
{
    if (me->shm.valid == false)


@@ 228,7 228,7 @@ void daq_process_data(void)
void adc_dma_fill_buffer(uint32_t offset)
{
    for (int i = 0; i < N_DMA_SAMPLES / 2; i++)
        me->shm.buf[me->shm.wc++ % me->shm.nsamp] = me->dma_buf[i + offset];
        me->shm.buf[me->shm.wc++ % me->shm.nsamp] = (uint32_t)me->dma_buf[i + offset];
}




@@ 399,7 399,7 @@ void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc)
        hdma_adc1.Init.PeriphInc           = DMA_PINC_DISABLE;
        hdma_adc1.Init.MemInc              = DMA_MINC_ENABLE;
        hdma_adc1.Init.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD;
        hdma_adc1.Init.MemDataAlignment    = DMA_MDATAALIGN_WORD;
        hdma_adc1.Init.MemDataAlignment    = DMA_MDATAALIGN_HALFWORD;
        hdma_adc1.Init.Mode                = DMA_CIRCULAR;
        hdma_adc1.Init.Priority            = DMA_PRIORITY_HIGH;
        hdma_adc1.Init.FIFOMode            = DMA_FIFOMODE_DISABLE;