Functions

xpal_test_comm.c File Reference

#include <stdbool.h>
#include <stdio.h>
#include <util/delay.h>
#include <avr/io.h>
#include <avr/interrupt.h>
#include <string.h>
#include <ctype.h>
#include "xpal_board.h"
#include "xpal_extmem.h"
#include "usb-fifo.h"
#include "keys.h"
#include "display.h"
#include "fontlist.h"
#include "term.h"
#include "xpal_power.h"
#include "xpal_bat.h"
#include "xpal_async32khz.h"
#include "cb_list.h"
#include "xpal_test_comm.h"
#include "adc.h"

Functions

void xt_WriteComMenu (void)
 Write the main menu for comm tests.
void xt_TestUSB (void)
 Test USB Interface.
void xt_TestEx232 (void)
 Test ext232 Interface.
void xt_comm (void)
 Application main loop for the board test system.

Detailed Description

Individual Board Test functions for communication hardware


Function Documentation

void xt_comm ( void   ) 

Application main loop for the board test system.

All individual Board Tests start from here

                  {

        keyscan_t KeyInput = HL_NOKEY;

        do{
                xt_WriteComMenu();

                do{
                        hlGetKeySc( &KeyInput );
                        hl_pwr_EnterSleep();
                }while ( KeyInput == HL_NOKEY );

                term_strprint_P (PSTR("\r\n"));
        
                switch(KeyInput){
                
                        case HL_SCAN_NUM1:{ // ext. RS232
                                term_strprint_P (PSTR("\r\n external RS232 Test\r\n"));
                
                                xt_TestEx232();

                        }break;
                
                        case HL_SCAN_NUM2:{ // GPS module UART Loop test
                                term_strprint_P (PSTR("\r\n GPS UART Test\r\n"));
                                term_strprint_P (PSTR("Not implemented yet...\r\n"));
                                _delay_ms (1000);
                
                        }break;
                
                        case HL_SCAN_NUM3:{ // GPS module UART Display NMEA output
                                term_strprint_P (PSTR("\r\n GPS UART Test\r\n"));
                                term_strprint_P (PSTR("Not implemented yet...\r\n"));
                                _delay_ms (1000);
                
                        }break;
                
                        case HL_SCAN_NUM4:{ // USB
                                term_strprint_P (PSTR("\r\n USB Test\r\n"));

                                xt_TestUSB();
                        }break;
                
                        case HL_SCAN_STAR:{ // EXIT
                                term_strprint_P (PSTR("\r\n EXIT Test functions\r\n"));
                                _delay_ms (1000);
                                hl_lcd_clear ();

                        }break;

                        case HL_NOKEY: break;  // idle loop
                
                        default:  {
                                term_strprint_P (PSTR("\r\n Key has no function\r\n"));
                        };
                }
                KeyInput = HL_NOKEY;
        }while(KeyInput != HL_SCAN_STAR);
}

void xt_TestEx232 ( void   ) 

Test ext232 Interface.

                       {

        uint16_t Kin = HL_NOKEY;
//      volatile char c;

        term_strprint_P (PSTR(" External RS232 tests:\r\n"));
        term_strprint_P (PSTR(" 1 - Echo Test\r\n"));
        term_strprint_P (PSTR(" 2 - #inval Signal \r\n"));
        term_strprint_P (PSTR(" 0 - EXIT\r\n"));

        printf_P (PSTR("External RS232 Test\r\n"));

        while(Kin == HL_NOKEY){
                hlGetKeySc( &Kin );
        }
        switch(Kin){
                case HL_SCAN_NUM1:{ // Echo Test
                        term_strprint_P (PSTR("\r\n Echo all to PC\r\n"));



                }break;
                
                case HL_SCAN_NUM2:{ // #INVAL Test



                }break;
                
                case HL_SCAN_NUM0:{ // EXIT
                        term_strprint_P (PSTR("\r\n EXIT ex232 Test\r\n"));
                        _delay_ms (1000);
                }break;
                default: break;
        }
        term_strprint_P (PSTR("Test Done\r\n"));
        printf_P (PSTR("Test Done\r\n"));
        _delay_ms (2000);               
}

void xt_TestUSB ( void   ) 

Test USB Interface.

                     {

        uint16_t Kin = HL_NOKEY;
        volatile char c, l;

        hl_pwr_state_t pwState = hl_pwr_GetState();

        if(pwState & HL_PWR_USB_ACTIVE){
                // USB is active, Test
                term_strprint_P (PSTR(" USB active, tests avail:\r\n"));
                term_strprint_P (PSTR(" 1 - Echo Test\r\n"));
                term_strprint_P (PSTR(" 2 - TxE Signal \r\n"));
                term_strprint_P (PSTR(" 0 - EXIT\r\n"));

                printf_P (PSTR("USB Test\r\n"));

                while(Kin == HL_NOKEY){
                        hlGetKeySc( &Kin );
                }
                switch(Kin){
                        case HL_SCAN_NUM1:{ // Echo Test
                                term_strprint_P (PSTR("\r\n Echo all to PC\r\n"));
                                printf_P (PSTR("Start typing, eXPal is supposed to echo!!\r\n"));
                                printf_P (PSTR("Ctrl-C to stop the test\r\n"));
                                do{
                                        c = getchar();
                                        if ( isprint(c) ){
                                                putchar(c);
                                                term_print(c);
                                        }                       
                                }while( c != 0x03 ); // ^C to stop              
                        }break;
                
                        case HL_SCAN_NUM2:{ // TXE Test
                                // write fast and directly to USB to trigger TXE
                                for (l=0; l<100; l++){ // number of lines
                                        for (c = 0x41; c < 0x5A; c++){ // A..Z

                                                if( HL_USB_TXE_PIN & _BV(HL_USB_TXE) ){

                                                        term_strprint_P (PSTR("\r\n TXE found active!\r\n"));
                                                        // TXE was triggered, wait for release
                                                        while( HL_USB_TXE_PIN & _BV(HL_USB_TXE));
                                                }else{
                                                        // write character
                                                    *((char *)(HL_USB_BASE_ADR)) = c;                                           
                                                }
                                        }
                                        printf_P (PSTR("\r\n"));
                                }
                        }break;
                
                        case HL_SCAN_NUM0:{ // EXIT
                                term_strprint_P (PSTR("\r\n EXIT USB Test\r\n"));
                                _delay_ms (1000);
                        }break;
                        default: break;
                }
                term_strprint_P (PSTR("Test Done\r\n"));
                printf_P (PSTR("Test Done\r\n"));
                _delay_ms (2000);       
                
        }else{
                // USB in not active, can not test
                term_strprint_P (PSTR(" USB not connected,\r\n"));
                term_strprint_P (PSTR(" connect USB and try again.\r\n"));
                _delay_ms (2000);       
        }
}

void xt_WriteComMenu ( void   ) 

Write the main menu for comm tests.

                          {

        term_strprint_P (PSTR(" eX Pal - COMM Test\r\n"));
        term_strprint_P (PSTR(" ------------------\r\n"));
        term_strprint_P (PSTR(" 1 - ext.232\r\n"));
        term_strprint_P (PSTR(" 2 - ModUART LOOP\r\n"));
        term_strprint_P (PSTR(" 3 - ModUART NMEA\r\n"));
        term_strprint_P (PSTR(" 4 - USB\r\n"));
        term_strprint_P (PSTR(" * - EXIT Test"));
}