ps2.h File Reference

PS/2 protocol interface. More...

#include <inttypes.h>

Include dependency graph for ps2.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void ps2_init ()
 Init PS/2 related I/O and interrupts.
uint8_t ps2_avail ()
 Check if the input buffer contains at least one byte.
uint8_t ps2_getbyte ()
 Get one byte from input buffer. ps_avail() must be checked before doing so.
void ps2_sendbyte (uint8_t)
 Transmit one byte and wait for completion.
uint8_t ps2_busy ()
 Check if PS/2 statemachine is in IDLE state.
void ps2_enable_recv (uint8_t)
 Suspend or enable PS/2 device by pulling clock line low.


Detailed Description

PS/2 protocol interface.


Function Documentation

uint8_t ps2_avail (  ) 

Check if the input buffer contains at least one byte.

00116                     {
00117     return rx_head != rx_tail;
00118 } 

uint8_t ps2_busy (  ) 

Check if PS/2 statemachine is in IDLE state.

00065 { return state != IDLE; }

void ps2_enable_recv ( uint8_t   ) 

Suspend or enable PS/2 device by pulling clock line low.

Parameters:
1 = enable
00088                                      {
00089     if (enable) {
00090         state = IDLE;
00091         ps2_dir(1,1);
00092         // enable INT0 interruptt
00093         GIFR |= _BV(INTF0);
00094         GICR |= _BV(INT0);
00095     } else {
00096         // disable INT0, then everything else
00097         GICR &= ~_BV(INT0);
00098         ps2_clk(0);
00099         ps2_dir(1,0);
00100     }
00101 }

Here is the call graph for this function:

uint8_t ps2_getbyte (  ) 

Get one byte from input buffer. ps_avail() must be checked before doing so.

00120                       {
00121     uint8_t result = rx_buf[rx_tail];
00122     rx_tail = (rx_tail + 1) % PS2_RXBUF_LEN;
00123     
00124     return result;
00125 }

void ps2_init (  ) 

Init PS/2 related I/O and interrupts.

00067                 {
00068     state = IDLE;
00069     rx_head = 0;
00070     rx_tail = 0;
00071     ps2_enable_recv(0);
00072     
00073     MCUCR |= _BV(ISC01); // falling edge for INT00
00074     TIMSK &= ~_BV(TOIE0);
00075 }

Here is the call graph for this function:

void ps2_sendbyte ( uint8_t   ) 

Transmit one byte and wait for completion.

00127                                 {
00128     while (state != IDLE);
00129      
00130     // 1. pull clk low for 100us
00131     ps2_enable_recv(0);
00132 
00133     tx_byte = byte;
00134     state = TX_REQ0;
00135     
00136     // 128us
00137     TCNT0 = 255-4; 
00138     TIMSK |= _BV(TOIE0);
00139     TCCR0 = 4;
00140     
00141     while (state != IDLE);
00142 }

Here is the call graph for this function:


Generated on Fri Nov 13 04:21:25 2009 for [M]ouse by  doxygen 1.5.9