Esempio n. 1
0
void UART4_IRQHandler()//UART4 Interrupt handler implementation
{
	int eeRreg;
	uint8_t data;
	ConfigMode=1;
	while ( USART_GetFlagStatus(UART4, USART_FLAG_RXNE) == RESET);
	UART4_DATA=USART_ReceiveData(UART4);
	LEDon;
	if(UART4_DATA==103)
	{ //if "g"
	
		Delay_ms(100);
		sprintf (buff, "x");
		USART_PutString(buff);
		for(eeRreg=0; eeRreg<configDataSize;eeRreg++)
		{
			data = ReadFromEEPROM(eeRreg);
			Delay_ms(1);
			sprintf (buff, "%c", data);
			USART_PutString(buff);
		}
	
	}
	
	if(enable_writing==1)
	{							
		configData[w]=(int)UART4_DATA;
		w++;
		if(w>=configDataSize)
		{
			w=0; 
			enable_writing=0; 
			//saveData();	
			configSave();
		}
	}
	
	
	if(UART4_DATA==104)
	{ // if h (write to eeprom)
		enable_writing=1;
	}
	
	
	if(UART4_DATA==105)
	{ 
		ConfigMode=1;
	}	
	
	if(UART4_DATA==106)
	{
		ConfigMode=0;
	}								
}
Esempio n. 2
0
void USART_PutDecimal(int i)
{
  char str[16], *s;
  int n;
 
  s = str + sizeof(str); // Point to tail
 
  *--s = 0; // NUL
 
  if (i < 0) // Negative
  {
    n = 1;
    i = -i; // Negate
  }
  else
    n = 0;
 
  do
  {
    *--s = '0' + (char)(i % 10);
    i = i / 10;
  }
  while(i);
 
  if (n) // Add sign if negated
    *--s = '-';
 
  USART_PutString(s);
}
Esempio n. 3
0
int main(int argc, char *argv[])
{
  //BOOTLOADER_reset();

  int r;
  __enable_irq();
  //NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x4000); // make sure that
  // interrupts work
  clock_init(); // hey, you can overclock later here. maybe.



  JSON_init();
  USART_Config();
  TIM_init();

  LCD_Configuration();
  LCD_Initialization();
  LCD_Clear(LCD_Black);

  USART_PutString(HOST_USART,"***** INIT DONE *****\n");

  while(1) {

    r = JSON_render();

    // todo: better error reporting
    if(r == 3) {
      // no free bufs
      continue;
    } else if(r != 0) {
      JSON_init(); // reset buffers in case of errors
      char abuf[32];
      itoa(abuf, r, 10);
      USART_PutString(HOST_USART, abuf);
      USART_PutChar(HOST_USART, 'N');
      USART_PutChar(HOST_USART, '\n');
    }
    //USART1_PutChar('A');
    __asm__("WFI"); // sleep for a bit.
  }
  return 0;
}
Esempio n. 4
0
int main(void)
{
    char Message[18];
    DDRD = 0xFF;
    USART_Init(BAUD(1200));
    do
    {
        USART_GetString(Message);
        USART_PutString(Message);
    }
    while (1);
    return 0;
}
Esempio n. 5
0
int main(void)
{
  RCC_Configuration();
 
  GPIO_Configuration();
 
  USART2_Configuration();
 
  //USART_Calc();
 
  while(1){
    USART_SendData(USART2, 'A');
    USART_PutString("\r\n");
  
}; // Don't want to exit
}
Esempio n. 6
0
void USART_Calc(void) // Simple Calculator from keystrokes
{
 // int accum, num;
 // char i;
 
 // accum = 0;
 // num = 0;
 
  while(1)
  {
    USART_SendData(USART2, 'A');
    USART_PutString("\r\n");
   /* i = USART_GetChar();
 
    if ((i >= '0') && (i <= '9')) // Decimal?
    {
      num = (num * 10) + (int)(i - '0'); // Load the number
    }
    else if (i == '+')
    {
      accum += num; // add
      num = 0; // clear
      USART_PutDecimal(accum);
      USART_PutString("\r\n");
    }
    else if (i == '-')
    {
      accum -= num; // subtract
      num = 0; // clear
      USART_PutDecimal(accum);
      USART_PutString("\r\n");
    }
    else if (i == '.') // Print current accumulator and number
    {
      USART_PutString("accum:");
      USART_PutDecimal(accum);
      USART_PutString(", num:");
      USART_PutDecimal(num);
      USART_PutString("\r\n");
    }*/
  }
}
Esempio n. 7
0
void UART4_IRQHandler()//UART4 Interrupt handler implementation
{
    int eeRreg;
    ConfigMode = 1;

    while (USART_GetFlagStatus(UART4, USART_FLAG_RXNE) == RESET);

    UART4_DATA = USART_ReceiveData(UART4);
    LEDon;

    if (UART4_DATA == 103) //if "g"
    {

        Delay_ms(100);
        sprintf(buff, "x");
        USART_PutString(buff);

        for (eeRreg = 0; eeRreg < configDataSize; eeRreg++)
        {
            ReadFromEEPROM(eeRreg);
            Delay_ms(5);
            sprintf(buff, "%c", EepromData);
            USART_PutString(buff);
        }

        // Enable Acknowledgement to be ready for another reception
        I2C_AcknowledgeConfig(I2C2, ENABLE);
    }




    if (enable_writing == 1)
    {
        configData[w] = (int)UART4_DATA;
        w++;

        if (w >= configDataSize)
        {
            w = 0;
            enable_writing = 0;
            saveData();
        }
    }


    if (UART4_DATA == 104) // if h (write to eeprom)
    {

        enable_writing = 1;
    }


    if (UART4_DATA == 105)
    {

        ConfigMode = 1;
    }

    if (UART4_DATA == 106)
    {

        ConfigMode = 0;
    }




}