Code: Select all
#define ChipSelect GPIOE_ODR.B3
char readbuff[64], writebuff[64];
char okunan=0;
signed int xi=0,yi=1,zi;
void kurulum()
{
GPIO_Digital_Output(&GPIOE_ODR, _GPIO_PINMASK_3);
ChipSelect=1;
SPI1_Init();
ChipSelect=0;
SPI_Write(0x0F|0x80);
okunan=SPI1_Read(0);
ChipSelect=1;
if(okunan==0x3F)
{
ChipSelect=0;
SPI1_Write(0x20);
SPI1_Write(0x67);
ChipSelect=1;
}
}
void ChipOku()
{
ChipSelect=0;
SPI1_Write(0x27|0x80);
okunan=SPI1_Read(0);
ChipSelect=1;
if(okunan&1)
{
ChipSelect=0;
SPI1_Write(0x28 | 0x80);
i=SPI1_Read(0);
ChipSelect=1;
delay_us(10);
ChipSelect=0;
SPI1_Write(0x29 | 0x80);
i=(SPI1_Read(0)<<8);
ChipSelect=1;
}
if(okunan&2)
{
ChipSelect=0;
SPI1_Write(0x2A | 0x80);
yi=SPI1_Read(0);
ChipSelect=1;
delay_us(10);
ChipSelect=0;
SPI1_Write(0x2B | 0x80);
yi=(SPI1_Read(0)<<8);
ChipSelect=1;
}
if(okunan&4)
{
ChipSelect=0;
SPI1_Write(0x2C | 0x80);
zi=SPI1_Read(0);
ChipSelect=1;
delay_us(10);
ChipSelect=0;
SPI1_Write(0x2D | 0x80);
zi=(SPI1_Read(0)<<8);
ChipSelect=1;
}
}
void main()
{
kurulum();
HID_Enable(&readbuff, &writebuff);
do
{
ChipOku();
writebuff[0]=xi; //
writebuff[1]=yi; // the problem is happening right here
writebuff[2]=zi; //
HID_Write(&writebuff, 64);
Delay_ms(100);
}
while(1);
}
void USB_Kesmesi() iv IVT_INT_OTG_FS ics ICS_AUTO
{
USB_Interrupt_Proc();
}
for example ;
xi=123 , it means writebuff[0] should be 123. But writebuff[0] = 0 , I checked it on hardware debug , again and again .
I also tried this codes below, and its working correctly
Code: Select all
int i =123;
writebuff[0]=i;
HID_Write(&writebuff, 64);
And please dont delete this post again i need help, i checked the forum , i cant find any issue similar like that
Im really confused