Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int coeff_id=0; //index used to cycle through the different sets of coefficients
- //note - the 0th entry here is multiplied by two to avoid the 0.5's
- alt_8 C_m1_m1[7] = {2, 1, 1, 1,-1, 0,-1}; //coeffs0 byte 1
- alt_8 C_m1_0[7] = {2, 1, 1,-2,-1,-1,-2}; //coeffs0 byte 0
- alt_8 C_m1_p1[7] = {2, 1, 2, 1,-1, 0,-1}; //coeffs1 byte 3
- alt_8 C_0_m1[7] = {1, 1, 2,-2,-1,-1,-2}; //coeffs1 byte 2
- alt_8 C_0_0[7] = {2, 8, 4, 5, 9, 5, 28}; //coeffs1 byte 1
- alt_8 C_0_p1[7] = {1, 1, 2,-2,-1,-1,-2}; //coeffs1 byte 0
- alt_8 C_p1_m1[7] = {2, 1, 2, 1,-1, 0,-1}; //coeffs2 byte 3
- alt_8 C_p1_0[7] = {2, 1, 1,-2,-1,-1,-2}; //coeffs2 byte 2
- alt_8 C_p1_p1[7] = {2, 1, 1, 1,-1, 0,-1}; //coeffs2 byte 1
- alt_8 scale[7] = {16,16,16,1, 1, 1, 16}; //coeffs2 byte 0
- alt_u32 coeffs0=0x0000, coeffs1=0x0000, coeffs2=0x0000;
- -------------------------------------------------------------------------------------
- // when push button 3 pressed
- case 3 :
- coeffs0=0x0000; //reset all coefficients to zero
- coeffs1=0x0000;
- coeffs2=0x0000;
- //we use three 32-bit variables here
- //we have 8*10 = 80 bits of coefficient data we need to transfer
- //we use all 32 bits of coeffs1 and coeffs2
- //we only need 16 bits of coeffs0
- //all of this shifting and ORing below fills the coeffs variables with the coefficient
- //data we've set above.
- coeffs0 = C_m1_m1[coeff_id] & 0xFF; //coeffs0 contains 2 8-bit values
- coeffs0 <<= 8;
- coeffs0 = coeffs0 | (C_m1_0[coeff_id] & 0xFF);
- coeffs1 = C_m1_p1[coeff_id] & 0xFF; //coeffs1 contains 4 8-bit values
- coeffs1 <<= 8;
- coeffs1 = coeffs1 | (C_0_m1[coeff_id] & 0xFF);
- coeffs1 <<= 8;
- coeffs1 = coeffs1 | (C_0_0[coeff_id] & 0xFF);
- coeffs1 <<= 8;
- coeffs1 = coeffs1 | (C_0_p1[coeff_id] & 0xFF);
- coeffs2 = C_p1_m1[coeff_id] & 0xFF; //coeffs2 contains 4 8-bit values
- coeffs2 <<= 8;
- coeffs2 = coeffs1 | (C_p1_0[coeff_id] & 0xFF);
- coeffs2 <<= 8;
- coeffs2 = coeffs1 | (C_p1_p1[coeff_id] & 0xFF);
- coeffs2 <<= 8;
- coeffs2 = coeffs1 | (scale[coeff_id] & 0xFF);
- printf("ID: %d\nCoeffs0: %.8X \nCoeffs1: %.8X \nCoeffs1: %.8X\n\n",coeff_id,coeffs0, coeffs1, coeffs2);
- IOWR(NIOS_LCD_CAMERA_COMPONENT_0_IMAGELINE_BASE, 4, 5); //filter_config=5 for the verilog files
- //write the coefficients to the new registers we've created
- IOWR(NIOS_LCD_CAMERA_COMPONENT_0_IMAGELINE_BASE, 5, coeffs0);
- IOWR(NIOS_LCD_CAMERA_COMPONENT_0_IMAGELINE_BASE, 6, coeffs1);
- IOWR(NIOS_LCD_CAMERA_COMPONENT_0_IMAGELINE_BASE, 7, coeffs2);
- coeff_id ++; //increment the coeff_id, so the next time you press key 3, it uses the next set of coefficients
- if(coeff_id==7)coeff_id=0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement