signal gpio_clk: std_logic;
signal dat_reg : STD_LOGIC_VECTOR (127 downto 0); --shift register for spi
signal position: std_logic_vector(31 downto 0); --pozice z qcounteru
+ signal index_position: std_logic_vector(11 downto 0); --pozice irc_i
signal ce0_old: std_logic_vector(1 downto 0);
--pwm signals
pwm(3) <= pwm_sig(3) and dip_sw(3);
+ process
+ begin
+ wait until (irc_i'event and irc_i='1');
+ index_position(11 downto 0)<=position(11 downto 0);
+ end process;
process
begin
income_data_valid<='0';
dat_reg(127 downto 96) <= position(31 downto 0); --pozice
dat_reg(95 downto 93) <= hal_in(1 to 3); --halovy sondy
- dat_reg(92 downto 90) <= pwm_en_p(1 to 3); --enable positive
- dat_reg(89 downto 87) <= pwm_en_n(1 to 3); --shutdown
- dat_reg(86 downto 81) <= (others=>'0');--pwm_match(1)(10 downto 5); --6 MSb of PWM1
+ dat_reg(92 downto 81) <= index_position(11 downto 0); --position of irc_i
dat_reg(80 downto 72) <=adc_m_count(8 downto 0); --count of measurments
--data order schould be: ch2 downto ch0 downto ch1
dat_reg(71 downto 0) <= adc_channels(71 downto 0); --current mesurments
}
void substractOffset(struct rpi_in* data, struct rpi_in* offset){
+ data->pozice_raw=data->pozice;
data->pozice-=offset->pozice;
return;
}
}
puts("");
printf("\npozice=%d\n",(int32_t)data.pozice);
+ printf("raw_pozice=%d\n",(int32_t)data.pozice_raw);
+ printf("raw_pozice last11=%u\n",(data.pozice_raw&0x7FF));
+ printf("index position=%d\n",(int16_t)data.index_position);
printf("hal1=%d, hal2=%d, hal3=%d\n",data.hal1,data.hal2,data.hal3);
printf("en1=%d, en2=%d, en3=%d (Last sent)\n",!!(0x40&test),!!(0x20&test),!!(0x10&test));
printf("shdn1=%d, shdn2=%d, shdn3=%d (L.s.)\n",!!(0x08&test),!!(0x04&test),!!(0x02&test));
uint8_p[1]=rx[2];
uint8_p[2]=rx[1];
uint8_p[3]=rx[0]; /*MSB*/ /*with sign bit*/
- uint8_p[4]=uint8_p[5]=uint8_p[6]=uint8_p[7]=0;
/*halove sondy
* hal1 - bit95
in.hal2=!!(0x40 & rx[4]);
in.hal3=!!(0x20 & rx[4]);
- /*pwm enable
- * en1 - bit92
- * en2 - bit91
- * en2 - bit90
+ /* index position
+ * bits 92 downto 81
+ * 92..88 in rx[4] last 5 bits (from left)
+ * 87..81 in rx[5] first 7 bits (from left)
*/
- in.en1=!!(0x10 & rx[4]);
- in.en2=!!(0x08 & rx[4]);
- in.en3=!!(0x04 & rx[4]);
-
- /*shutdown
- * shdn1 - bit89
- * shdn2 - bit88
- * shdn3 - bit87
- */
- in.shdn1=!!(0x02 & rx[4]);
- in.shdn2=!!(0x01 & rx[4]);
- in.shdn3=!!(0x80 & rx[5]);
+ in.index_position=0x1F & rx[4];
+ in.index_position<<=8;
+ in.index_position|=0xFE & rx[5];
+ in.index_position>>=1;
/* current measurments count
* bits 80 downto 72
* \brief Struktura pro prichozi data z fpga.
*/
struct rpi_in{
- uint64_t pozice; /*use twice the origin size to avoid underflow when sunstracting offset*/
+ uint32_t pozice; /*continue with normal size and test it..*/
+ uint32_t pozice_raw; /*with offset*/
uint32_t ch0, ch1, ch2;
int8_t hal1,hal2,hal3; /* bool values */
int8_t en1, en2, en3; /*(bool)last read pwm-enable values - !they are changed after reading ! */
int8_t b54, b53, b52, b51, b50, b49, b48, b47, b46, b45, b44, b43, b42, b41, b40, b39, b38, b37, b36; /*bits for debug*/
uint16_t adc_m_count; /*current measurments count*/
uint8_t debug_rx[16];
+ uint16_t index_position; /* raw position of irc_i */
};
/**