non ho fatto quel tipo di verifica
comunque il software è questo, ci sono un pò di cicli for per i vari tentativi che ho fatto per settare il registro dell'audioevideo config
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/mman.h>
#include "hps_0.h"
#define LWH2F_REGS_BASE (0XFC000000)
#define LWH2F_REGS_OFST (0XFF200000)
#define LWH2F_REGS_SPAN (0X04000000)
#define LWH2F_REGS_MASK (LWH2F_REGS_SPAN-1)
#define BUF_SIZE 500000
int left_buffer[BUF_SIZE];
int right_buffer[BUF_SIZE];
int buffer_index = 0;
int fd_mem;
void* lwh2f_base;
int32_t* sys_id_addr;
volatile int32_t* audio_addr;
int32_t* audio_cfg;
uint32_t open_peripherals(){
// Map LWH2f bridge address space on a virtual address
fd_mem = open("/dev/mem", (O_RDWR | O_SYNC));
if(fd_mem < 0) {
return 1;
}
lwh2f_base = mmap(NULL, LWH2F_REGS_SPAN, ( PROT_READ | PROT_WRITE ), MAP_SHARED, fd_mem, LWH2F_REGS_BASE);
if(lwh2f_base == MAP_FAILED) {
close(fd_mem);
return 2;
}
// Evaluate all needed Soft IP base addresses, based on previously obtained bridges virtual base addresses
sys_id_addr = (int32_t*) ((uint32_t) lwh2f_base + ((uint32_t) (LWH2F_REGS_OFST+SYSID_QSYS_BASE) & (uint32_t) (LWH2F_REGS_MASK)));
audio_addr = (int32_t*) ((uint32_t) lwh2f_base + ((uint32_t) (LWH2F_REGS_OFST+AUDIO_0_BASE) & (uint32_t) (LWH2F_REGS_MASK)));
audio_cfg= (int32_t*)((uint32_t) lwh2f_base + ((uint32_t) (LWH2F_REGS_OFST+AUDIO_AND_VIDEO_CONFIG_0_BASE) & (uint32_t)(LWH2F_REGS_MASK)));
return 0;
}
// Close all peripherals opened from the application, by closing the virtual memory space mapping their registers
uint32_t close_peripherals() {
// Unmap LWH2f bridge address space
if(munmap(lwh2f_base, LWH2F_REGS_SPAN) != 0) {
return 1;
}
close(fd_mem);
return 0;
}
int main(){
int fifospace;
int i;
printf("open peripherals: %d\n", open_peripherals());
printf("accesso al registro: 0x%08x\n",*sys_id_addr);
*audio_addr= 0xc;
printf("verifica cancella fifo : 0x%08x\n", *audio_addr);
*audio_addr= 0x0;
printf("verifica disattiva cancella : 0x%08x\n", *audio_addr);
printf("statusregister1 cfg: 0x%08x\n",*(audio_cfg+1) );
for(i=0; i<100;i++)
{
fifospace= *(audio_addr+1);
printf("0x%08x\n", fifospace);//check if the LSB of the fifospace register are increasing
}
printf("accesso al leftdata : 0x%08x\n",*audio_addr+2);
printf("accesso al rightdata : 0x%08x\n",*audio_addr+3);
*audio_cfg=0x1;
printf("statusregister2 cfg: 0x%08x\n",*(audio_cfg+1) );
for(i=0; i<100;i++)
{
fifospace= *(audio_addr+1);
printf("0x%08x\n", fifospace);//check if the LSB of the fifospace register are increasing
left_buffer[buffer_index] = *(audio_addr + 2);
right_buffer[buffer_index] = *(audio_addr + 3);
++buffer_index;
}
printf("bufferindex: 0x%08x\n",left_buffer[buffer_index]);
printf("bufferindex2: 0x%08x\n",right_buffer[buffer_index]);
printf("accesso al leftdata : 0x%08x\n",*audio_addr+2);
printf("accesso al rightdata : 0x%08x\n",*audio_addr+3);
printf("close peripherals: %d\n", close_peripherals());
return 0;
}