Advertisement
Guest User

Untitled

a guest
Feb 7th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.23 KB | None | 0 0
  1.  
  2.  
  3. int coeff_id=0; //index used to cycle through the different sets of coefficients
  4.  
  5. //note - the 0th entry here is multiplied by two to avoid the 0.5's
  6.  
  7. alt_8 C_m1_m1[7] = {2, 1, 1, 1,-1, 0,-1}; //coeffs0 byte 1
  8. alt_8 C_m1_0[7] = {2, 1, 1,-2,-1,-1,-2}; //coeffs0 byte 0
  9. alt_8 C_m1_p1[7] = {2, 1, 2, 1,-1, 0,-1}; //coeffs1 byte 3
  10. alt_8 C_0_m1[7] = {1, 1, 2,-2,-1,-1,-2}; //coeffs1 byte 2
  11. alt_8 C_0_0[7] = {2, 8, 4, 5, 9, 5, 28}; //coeffs1 byte 1
  12. alt_8 C_0_p1[7] = {1, 1, 2,-2,-1,-1,-2}; //coeffs1 byte 0
  13. alt_8 C_p1_m1[7] = {2, 1, 2, 1,-1, 0,-1}; //coeffs2 byte 3
  14. alt_8 C_p1_0[7] = {2, 1, 1,-2,-1,-1,-2}; //coeffs2 byte 2
  15. alt_8 C_p1_p1[7] = {2, 1, 1, 1,-1, 0,-1}; //coeffs2 byte 1
  16. alt_8 scale[7] = {16,16,16,1, 1, 1, 16}; //coeffs2 byte 0
  17.  
  18. alt_u32 coeffs0=0x0000, coeffs1=0x0000, coeffs2=0x0000;
  19.  
  20.  
  21. -------------------------------------------------------------------------------------
  22.  
  23.  
  24. // when push button 3 pressed
  25. case 3 :
  26.  
  27. coeffs0=0x0000; //reset all coefficients to zero
  28. coeffs1=0x0000;
  29. coeffs2=0x0000;
  30.  
  31.  
  32. //we use three 32-bit variables here
  33. //we have 8*10 = 80 bits of coefficient data we need to transfer
  34. //we use all 32 bits of coeffs1 and coeffs2
  35. //we only need 16 bits of coeffs0
  36.  
  37. //all of this shifting and ORing below fills the coeffs variables with the coefficient
  38. //data we've set above.
  39.  
  40. coeffs0 = C_m1_m1[coeff_id] & 0xFF; //coeffs0 contains 2 8-bit values
  41. coeffs0 <<= 8;
  42. coeffs0 = coeffs0 | (C_m1_0[coeff_id] & 0xFF);
  43.  
  44. coeffs1 = C_m1_p1[coeff_id] & 0xFF; //coeffs1 contains 4 8-bit values
  45. coeffs1 <<= 8;
  46. coeffs1 = coeffs1 | (C_0_m1[coeff_id] & 0xFF);
  47. coeffs1 <<= 8;
  48. coeffs1 = coeffs1 | (C_0_0[coeff_id] & 0xFF);
  49. coeffs1 <<= 8;
  50. coeffs1 = coeffs1 | (C_0_p1[coeff_id] & 0xFF);
  51.  
  52. coeffs2 = C_p1_m1[coeff_id] & 0xFF; //coeffs2 contains 4 8-bit values
  53. coeffs2 <<= 8;
  54. coeffs2 = coeffs1 | (C_p1_0[coeff_id] & 0xFF);
  55. coeffs2 <<= 8;
  56. coeffs2 = coeffs1 | (C_p1_p1[coeff_id] & 0xFF);
  57. coeffs2 <<= 8;
  58. coeffs2 = coeffs1 | (scale[coeff_id] & 0xFF);
  59.  
  60. printf("ID: %d\nCoeffs0: %.8X \nCoeffs1: %.8X \nCoeffs1: %.8X\n\n",coeff_id,coeffs0, coeffs1, coeffs2);
  61.  
  62. IOWR(NIOS_LCD_CAMERA_COMPONENT_0_IMAGELINE_BASE, 4, 5); //filter_config=5 for the verilog files
  63.  
  64. //write the coefficients to the new registers we've created
  65.  
  66. IOWR(NIOS_LCD_CAMERA_COMPONENT_0_IMAGELINE_BASE, 5, coeffs0);
  67. IOWR(NIOS_LCD_CAMERA_COMPONENT_0_IMAGELINE_BASE, 6, coeffs1);
  68. IOWR(NIOS_LCD_CAMERA_COMPONENT_0_IMAGELINE_BASE, 7, coeffs2);
  69.  
  70. coeff_id ++; //increment the coeff_id, so the next time you press key 3, it uses the next set of coefficients
  71.  
  72.  
  73. if(coeff_id==7)coeff_id=0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement