logo elektroda
logo elektroda
X
logo elektroda
REKLAMA
REKLAMA
Adblock/uBlockOrigin/AdGuard mogą powodować znikanie niektórych postów z powodu nowej reguły.

Jak wysłać te pakiety w standardzie ps/2 host --> device

MasterYoda95 27 Wrz 2010 20:42 1305 5
REKLAMA
  • #1 8557654
    MasterYoda95
    Poziom 10  
    Witam. Ostatnio zajmuję się opracowaniem połączenia Atmegi z myszą ps/2. Na stronie http://www.computer-engineering.org/ps2mouse/ znajduje się dosyć dokładny opis tej transmisji. Większość z tego zrozumiałem, jednak nie rozumiem, o co chodzi w komendach wysyłanych w kierunku host (komputer lub inne ustrojstwo do którego podłączona jest mysz) --> device (w tym wypadku mysz optyczna ps/2). Są one zapisane w niezrozumiałej dla mnie formie, zapis wygląda jak szesnastkowy, ale jest tam x i zero na początku, zresztą sami zobaczcie:
    Lista komend:
    Cytat:
    * 0xFF (Reset) - The mouse responds to this command with "acknowledge" (0xFA) then enters reset mode.
    * 0xFE (Resend) - The host sends this command whenever it receives invalid data from the mouse. The mouse responds by resending the last packet it sent to the host. If the mouse responds to the "Resend" command with another invalid packet, the host may either issue another "Resend" command, issue an "Error" (0xFC) command, cycle the mouse's power supply to reset the mouse, or it may inhibit communication (by bringing the clock line low). This command is not buffered, which means "Resend" will never be sent in response to the "Resend" command.
    * 0xF6 (Set Defaults) - The mouse responds with "acknowledge" (0xFA) then loads the following values: Sampling rate = 100, resolution = 4 counts/mm, Scaling = 1:1, data reporting = disabled. The mouse then resets its movement counters and enters stream mode.
    * 0xF5 (Disable Data Reporting) - The mouse responds with "acknowledge" (0xFA) then disables data reporting and resets its movement counters. This only affects data reporting in stream mode and does not disable sampling. Disabled stream mode functions the same as remote mode.
    * 0xF4 (Enable Data Reporting) - The mouse responds with "acknowledge" (0xFA) then enables data reporting and resets its movement counters. This command may be issued while the mouse is in remote mode, but it will only affect data reporting in stream mode.
    * 0xF3 (Set Sample Rate) - The mouse responds with "acknowledge" (0xFA) then reads one more byte from the host. The mouse saves this byte as the new sample rate. After receiving the sample rate, the mouse again responds with "acknowledge" (0xFA) and resets its movement counters. Valid sample rates are 10, 20, 40, 60, 80, 100, and 200 samples/sec.
    * 0xF2 (Get Device ID) - The mouse responds with "acknowledge" (0xFA) followed by its device ID (0x00 for the standard PS/2 mouse). The mouse should also reset its movement counters.
    * 0xF0 (Set Remote Mode) - The mouse responds with "acknowledge" (0xFA) then resets its movement counters and enters remote mode.
    * 0xEE (Set Wrap Mode) - The mouse responds with "acknowledge" (0xFA) then resets its movement counters and enters wrap mode.
    * 0xEC (Reset Wrap Mode) - The mouse responds with "acknowledge" (0xFA) then resets its movement counters and enters the mode it was in prior to wrap mode (stream mode or remote mode).
    * 0xEB (Read Data) - The mouse responds with "acknowledge" (0xFA) then sends a movement data packet. This is the only way to read data in remote mode. After the data packet has successfully been sent, the mouse resets its movement counters.
    * 0xEA (Set Stream Mode) - The mouse responds with "acknowledge" (0xFA) then resets its movement counters and enters stream mode.
    * 0xE9 (Status Request) - The mouse responds with "acknowledge" (0xFA) then sends the following 3-byte status packet (then resets its movement counters)

    chodzi mi o te symbole typu 0xEA, wiem, że to pewnie lamerskie pytanie, ale naprawdę nie wiem o co chodzi.
    Ps. Rozumiem jak zainicjować transmisję, w jaki sposób przesyłać i jak ją zakończyć w tym kierunku, chodzi mi tylko o te symbole. Wiem, że jedna ramka danych jest ośmiobitowa.
  • REKLAMA
  • #2 8557953
    sedr
    Poziom 17  
    0x to oznaczenie, że literał bądź ciąg znaków jest przedstawiony w systemie szesnastkowym.
  • REKLAMA
  • #3 8560995
    MasterYoda95
    Poziom 10  
    Aha, to wszystko wyjaśnia, wystarczy zamieniić te liczby na system binarny i przesłać je do urządzenia. Ale chyba nie da się w 8 bitach przesłać szesnastkowego FF bo jest to 256 a w systemie binarnym 10000000 więc w ośmiu bitach się "nie mieści", z innymi nie ma problemu, bo są mniejsze.
  • REKLAMA
  • #4 8561250
    tymon_x
    Poziom 30  
    MasterYoda95 napisał:
    Aha, to wszystko wyjaśnia, wystarczy zamieniić te liczby na system binarny i przesłać je do urządzenia. Ale chyba nie da się w 8 bitach przesłać szesnastkowego FF bo jest to 256 a w systemie binarnym 10000000 więc w ośmiu bitach się "nie mieści", z innymi nie ma problemu, bo są mniejsze.

    0xFF to binarnie 0b1111 1111, czyli 255. Zakres liczb 8-bitowego (integer bez znaku) to od 0 do 255, czyli szesnastkowo od 0x00 do 0xFF. Użyj kalkulatora naukowego w Windowsie jak nie wierzysz (; (albo dowolnego innego jak masz linucha)
  • REKLAMA
  • #5 8563114
    arturt134
    Poziom 27  
    Bez obrazy, ale myślę, że temat trochę przerasta Twoje umiejętności. Spróbuj może najpierw czegoś prostszego, typu dołączenie LCD i wyświetlenie napisu "Hello World", lub wysłanie tego przez zwykły RS232.

    No i oczywiście jakaś książka o programowaniu mikrokontrolerów byłaby na miejscu... Na tym forum na pewno znajdziesz jakieś propozycje.
  • #6 8572290
    MasterYoda95
    Poziom 10  
    Rzeczywiście, FF to 255, błąd w obliczeniach. Co do książki, to czytałem trochę w necie na temat uC i niedługo kupię sobie np Atmegę8 i programatorek to najpierw się trochę pobawię w różne migające diody, napisy na lcd itp żeby trochę "poczuć" uC, a potem spróbuję szczęścia z tą myszką (chcę zrobić taki miernik przesunięcia, który wyświetla przesunięcie w cm w osi X i Y). Dzięki za odpowiedzi i pozdrawiam!
REKLAMA