ооооо ееее нииигааа ... нашёл регистр для отправки посылки путём прямого доступа в память
Цитата
4.2 UARTn Transmit Holding Register (U0THR - 0xE000 C000, U2THR -
0xE007 8000, U3THR - 0xE007 C000 when DLAB = 0, Write Only)
The UnTHR is the top byte of the UARTn TX FIFO. The top byte is the newest character in
the TX FIFO and can be written via the bus interface. The LSB represents the first bit to
transmit.
The Divisor Latch Access Bit (DLAB) in UnLCR must be zero in order to access the
UnTHR. The UnTHR is always Write Only.
Table 379. UART0 Transmit Holding Register (U0THR - address 0xE000 C000,
U2THR - 0xE007 8000, U3THR - 0xE007 C000 when DLAB = 0, Write Only) bit
description
Bit Symbol Description Reset Value
7:0 THR Writing to the UARTn Transmit Holding Register causes the data NA
to be stored in the UARTn transmit FIFO. The byte will be sent
when it reaches the bottom of the FIFO and the transmitter is
available.
пишем функцию отсылки чара
Цитата
int putC(unsigned char ch)
{
int write_stat,fd;
unsigned char *map,data,res;
fd = open("/dev/mem", O_RDWR);
map = mmap(0, 0x100, PROT_READ, MAP_SHARED, fd, UnLCR_BASE_ADDR);
if (map == MAP_FAILED)
{
printf("Error mmapping the file");
return 0;
}
while(!(U0LCR && 0x20));
if (munmap(map, 0x100) == -1)
{
perror("Error un-mmapping the file");
}
close(fd);
fd = open("/dev/mem", O_RDWR);
map = mmap(0, 0x100, PROT_READ, MAP_SHARED, fd, UnTHR_BASE_ADDR);
if (map == MAP_FAILED)
{
printf("Error mmapping the file");
return 0;
}
U3THR = ch;
if (munmap(map, 0x100) == -1)
{
perror("Error un-mmapping the file");
}
close(fd);
return 0;
}
модернизируем отправку
Цитата
tcflush( ttyfd, TCIOFLUSH ); /* flush the input & output streams */
setP01(1,13, 1);
//write_stat = write( ttyfd, query, string_length );
for( i = 0; i < string_length; i++ )
putC(query[i]);
fd = open("/dev/mem", O_RDWR);
map = mmap(0, 0x100, PROT_READ, MAP_SHARED, fd, UnLCR_BASE_ADDR);
if (map == MAP_FAILED)
{
printf("Error mmapping the file");
return 0;
}
while(!(U0LCR && 0x20));
if (munmap(map, 0x100) == -1)
{
perror("Error un-mmapping the file");
}
close(fd);
printf("\n");
setP01(1,13, 0);
и получаем посылку почти чётко вписанную в строб, за качество кода прошу не ругать, ибо делал енто на коленях, по наитию и не успел ещё отредактировать, опять же почему то не получаю ответа от дочернего устройства где то есть косяк, вобщем объективная критика принимается