コード例 #1
0
ファイル: cmd_test.c プロジェクト: embisi-github/embisi_gip
/*f command_timer_read
 */
static int command_timer_read( void *handle, int argc, unsigned int *args )
{
    unsigned int s;

    GIP_TIMER_READ_0(s);
    uart_tx_string("cntr: ");
    uart_tx_hex8(s);
    uart_tx_nl();

    GIP_TIMER_READ_1(s);
    uart_tx_string("val1: ");
    uart_tx_hex8(s);
    uart_tx_nl();

    GIP_TIMER_READ_2(s);
    uart_tx_string("val2: ");
    uart_tx_hex8(s);
    uart_tx_nl();

    GIP_TIMER_READ_3(s);
    uart_tx_string("val3: ");
    uart_tx_hex8(s);
    uart_tx_nl();

    return 0;
}
コード例 #2
0
void main(void)
{
  stop_watchdog();
  set_clk_8MHz();


  interrupts_enable();
  lcd_init();

  uart_init();
  uart_tx_string("Register Value:");

  unsigned char i2creceive[8];
  i2c_master_init();
  unsigned char data[1] = {0x6F};
  lcd_goto(1,0);
  lcd_print("R: ");
  lcd_print(int2HEXcharArray(*data));
  lcd_goto(2,0);
  lcd_print("V: ");
  i2c_writeByte(1,data,0x50);
  __delay_cycles(300);  // delay some time to get a better view on the signals on the scope
  unsigned char rx_byte = i2c_receiveSingleByte(0x50);
  __delay_cycles(300);
  uart_tx_string(int2HEXcharArray(rx_byte));
  lcd_print(int2HEXcharArray(rx_byte));

  __delay_cycles(300);
  uart_tx_string("\n");


  for (;;)
  {

  }
}
コード例 #3
0
ファイル: monitor.c プロジェクト: embisi-github/embisi_gip
/*f command_flash_boot
 */
static int command_flash_boot( int argc, unsigned int *args )
{
    if (argc<1)
    {
        int i, offset;
        unsigned int csum;
        char buffer[256];
        for (i=0; i<16; i++)
        {
            offset = 0;
            if ( (flash_read_object( i<<17, &csum, buffer, &offset, sizeof(buffer) )>0) &&
                 (buffer[0]==obj_type_description) )
            {
                uart_tx_hex8( i );
                uart_tx_string(" : ");
                uart_tx_string_nl(buffer+1);
            }
        }
        return 0;
    }
    return !flash_boot( args[0]<<17 );
}
コード例 #4
0
ファイル: monitor.c プロジェクト: embisi-github/embisi_gip
/*f test_entry_point
 */
extern int test_entry_point()
{
    int i, j, k, l;
    int error;
    int length;
    char buffer[256];
    const t_command *cmd;
    t_command_chain cmd_chain, *chain;
    int argc;
    unsigned int args[MAX_ARGS];
 
#ifdef LINUX
    static int heap[65536];
    fprintf(stderr,"256kB heap at %p\n",heap);
#endif

    cmd_chain.cmds = monitor_cmds;
    cmd_chain.next = (t_command_chain *)0;
    chain_extra_cmds( &cmd_chain );
    uart_init();
    extra_init();
    while (1)
    {
        /*b Display the prompt
         */
        uart_tx_string( "\r\nOK > ");

        /*b Wait for incoming string, echoing each byte as it comes
         */
        length = 0;
        while (1)
        {
            if (uart_rx_poll())
            {
                char c;
                c = uart_rx_byte();
                if (c<32)
                {
                    uart_tx_nl();
                    break;
                }
                if (c==8)
                {
                    if (length>0)
                    {
                        length--;
                        uart_tx(c);
                    }
                }
                if (length<(int)(sizeof(buffer))-1)
                {
                    buffer[length++] = c;
                    uart_tx(c);
                }
            }
        }
        buffer[length]=0;

        /*b Parse the string
         */
        for (i=0; buffer[i]==' '; i++);
        cmd = (t_command *)0;
        for (chain = &cmd_chain; (!cmd) && chain; chain=chain->next)
        {
            for (j=0; (!cmd) && (chain->cmds[j].name); j++)
            {
                //fprintf(stderr,"Compare buffer %s with command %s\n", buffer, chain->cmds[j].name );
                l = 1;
                for (k=0; chain->cmds[j].name[k]; k++)
                {
                    if (chain->cmds[j].name[k] != buffer[i+k])
                    {
                        l = 0;
                        break;
                    }
                }
                if (l)
                {
                    cmd = &(chain->cmds[j]);
                    break;
                }
            }
        }
        argc=0;
        if (cmd)
        {
            while (buffer[i] && (argc<MAX_ARGS))
            {
                for (; (buffer[i]!=' ') && (buffer[i]); i++); // skip to white space
                for (; (buffer[i]==' ') && (buffer[i]); i++); // skip past white space
                if (buffer[i])
                {
                    args[argc] = 0;
                    while ((buffer[i]!=' ') && (buffer[i]))
                    {
                        args[argc] = (args[argc]<<4) | ((buffer[i]>'9') ? ((buffer[i]&0xf)+9) : (buffer[i]&0xf));
                        i++;
                    }
                    argc++;
                }
            }
        }

        /*b Obey the string
         */
        error = 1;
        if (cmd)
        {
//            fprintf(stderr,"Command %d\n", command);
            error = cmd->fn( argc, args );
        }
        if (error)
        {
            uart_tx_string_nl( "\n\rError" );
        }
    }
}