| Line No. | Rev | Author | Line |
|---|---|---|---|
| 1 | 6 | kaklik | //***************************************************************************** |
| 2 | // File Name : encodertest.c |
||
| 3 | // |
||
| 4 | // Title : example usage of encoder driver functions |
||
| 5 | // Revision : 1.0 |
||
| 6 | // Notes : |
||
| 7 | // Target MCU : Atmel AVR series |
||
| 8 | // Editor Tabs : 4 |
||
| 9 | // |
||
| 10 | // Revision History: |
||
| 11 | // When Who Description of change |
||
| 12 | // ----------- ----------- ----------------------- |
||
| 13 | // 27-Jan-2003 pstang Created the program |
||
| 14 | //***************************************************************************** |
||
| 15 | |||
| 16 | |||
| 17 | //----- Include Files --------------------------------------------------------- |
||
| 18 | #include <avr/io.h> // include I/O definitions (port names, pin names, etc) |
||
| 19 | #include <avr/interrupt.h> // include interrupt support |
||
| 20 | |||
| 21 | #include "global.h" // include our global settings |
||
| 22 | #include "uart.h" // include uart function library |
||
| 23 | #include "rprintf.h" // include printf function library |
||
| 24 | #include "timer.h" // include timer function library (timing, PWM, etc) |
||
| 25 | #include "vt100.h" // include VT100 terminal support |
||
| 26 | #include "encoder.h" // include encoder driver |
||
| 27 | |||
| 28 | void encoderTest(void); |
||
| 29 | |||
| 30 | //----- Begin Code ------------------------------------------------------------ |
||
| 31 | int main(void) |
||
| 32 | { |
||
| 33 | // initialize our libraries |
||
| 34 | // initialize the UART (serial port) |
||
| 35 | uartInit(); |
||
| 36 | // set the baud rate of the UART for our debug/reporting output |
||
| 37 | uartSetBaudRate(9600); |
||
| 38 | // initialize the timer system |
||
| 39 | timerInit(); |
||
| 40 | // initialize rprintf system |
||
| 41 | rprintfInit(uartSendByte); |
||
| 42 | // initialize vt100 library |
||
| 43 | vt100Init(); |
||
| 44 | |||
| 45 | // clear the terminal screen |
||
| 46 | vt100ClearScreen(); |
||
| 47 | |||
| 48 | // run the test |
||
| 49 | encoderTest(); |
||
| 50 | |||
| 51 | return 0; |
||
| 52 | } |
||
| 53 | |||
| 54 | void encoderTest(void) |
||
| 55 | { |
||
| 56 | // initialize the encoders |
||
| 57 | encoderInit(); |
||
| 58 | |||
| 59 | // print a little intro message so we know things are working |
||
| 60 | rprintf("\r\nWelcome to the encoder test!\r\n"); |
||
| 61 | |||
| 62 | // report encoder position continuously |
||
| 63 | while(1) |
||
| 64 | { |
||
| 65 | rprintfProgStrM("Encoder0: "); |
||
| 66 | // print encoder0 position |
||
| 67 | // use base-10, 10 chars, signed, pad with spaces |
||
| 68 | rprintfNum(10, 10, TRUE, ' ', encoderGetPosition(0)); |
||
| 69 | |||
| 70 | rprintfProgStrM(" Encoder1: "); |
||
| 71 | // print encoder1 position |
||
| 72 | // use base-10, 10 chars, signed, pad with spaces |
||
| 73 | rprintfNum(10, 10, TRUE, ' ', encoderGetPosition(1)); |
||
| 74 | |||
| 75 | // print carriage return and line feed |
||
| 76 | rprintfCRLF(); |
||
| 77 | } |
||
| 78 | } |
||
| 79 |
Powered by WebSVN v2.8.3