コード例 #1
0
LOCAL void ICACHE_FLASH_ATTR rfid_set_led(uint8 led) {
	char command[10];
	if (led < 2) {
		os_sprintf(command, "ml%d\r", led);
		uart_write_str(command);
#if RFID_DEBUG
		debug("RFID: %s\n", command);
#endif
	}
}
コード例 #2
0
ファイル: main.c プロジェクト: boon-code/rf-driver-unstable
int main(void)
{
	DDRD = _BV(PD6);
	PORTD = _BV(PD6);
	
	uart_init(9600);
	uart_write_str("s \n");
	
	blink();
	
	rfm_init();
	uart_write_str("init\n");
	rfm_frequency(433.92);
	rfm_bandwidth(4, 1, 4);
	rfm_baudrate(19200);
	rfm_power(4, 0);
	
  uart_transmit('\n');
  uart_write_shex(rfm_command(0x0000));
  uart_transmit('\n');
  
  blink();
  
  // rising edge
  MCUCSR &= ~(_BV(ISC2));
  GICR |= _BV(INT2);
  
  rfm_command(0xCA81);			// set FIFO mode
	rfm_command(0x82C8);			// RX on
	rfm_command(0xCA83);
	
	sbi(GIFR, INTF2);
  
  sei();

	while(1)
	{
	  
	}
}
コード例 #3
0
void ICACHE_FLASH_ATTR rfid_set(uint8 freq, uint8 led) {
	char command[10];
	
	if (freq < 10) {
		os_sprintf(command, "mc%d0\r", freq);
		uart_write_str(command);
#if RFID_DEBUG
		debug("RFID: %s\n", command);
#endif
	}
	
	setTimeout(rfid_set_led, led, 10);
}
コード例 #4
0
void ICACHE_FLASH_ATTR rfid_info() {
	rfid_buff_pos = 0;
	rfid_mod = RFID_NONE;
	uart_write_str("\r");
	uart_write_str("i\r");
}
コード例 #5
0
ファイル: Eboot.c プロジェクト: wtos03/Geartronics-Git-Sever
/*--- MAIN -------------------------------------------------------------------*/
int main(void)
{
    uint8_t temp_char,tmp;
 	uint8_t bootFlag = TRUE;
    
    cli();
	
    /* the following code moves the interrupt vector pointer to the bootloader
       section. The problem is the compiler doesn't understand where to put
       the IV table. */
    GICR = _BV(IVCE);       
    GICR = _BV(IVSEL); //move interruptvectors to the Boot sector  ** WRITE 0 TO IVCE use = not |
   

// Initial 7 Segments on E_io
// Set direction of two switch to Input	
    DDRB =  0xFF;   // Output	
    DDRC  = 0x18;  // P3, P4 for  Control 7 segments Digits 

// Enable pull up resistor 
 	PORTC |= 0x24;

	
    /* The slow baud rate is required because of the intel hex parsing overhead.
       If I could figure out how to enable interrupts in the BLS (compiler issue)
       then a higher speed could be used by switching to an interrupt based
       UART ISR. The code could also be optimized. */
    
	uart_init( UART_INTERRUPT,UART_8_N_1,UART_38400);   
 
// poll USART receive complete flag 64k times to catch the 'i' reliably
 
// test if flash is empty (i.e. flash content is 0xff)
	if(pgm_read_byte_near(0x0000) != 0xFF) {
		bootFlag = FALSE; 
	}
	
//  Enter boot mode by press b 	
//	while (!(tmp  = uart_read()));
//	if (tmp == 'b')
//	     bootFlag = TRUE;
		 
// Check SW for enter boot mode either press both SW at the same time	
	tmp = PINC & (0x24);   // PB0, PB3 port
    if (!tmp)    // Press SW tmp = 0
        bootFlag = TRUE;	 
		 

	uart_write_str (VERSION);
// Display b characters 
	E_OUT_PORTA  =  0x7C;  // b
 	E_OUT_PB1(0);
 	E_OUT_PB2(1);
 
    
    /* this main loop is the user 'menu'. */
    while(bootFlag)                             
    {
			   
	if( (tmp = uart_read()) ) 
	{
 	   switch(tmp)
	   {
		case 'u': // download new program
		{
		    /* erase the main flash excepting BLS */
		    buf_address = 0; 
		    while ( APP_END > buf_address )
		    {
			boot_page_erase(buf_address);	// Perform page erase
			boot_spm_busy_wait();		// Wait until the memory is erased.
			buf_address += SPM_PAGESIZE;
		    }
		    buf_address = 0;

		    /* load new program */
			uart_write_str("READY \n");
		    if(( temp_char = ihex_load()))
		    {
				uart_write_str("ERR ");
				uart_write_char(temp_char + '0' );
				uart_write_char('\n');
		    }
		    else
			{
				bootFlag = FALSE ;  // Exit to run
			}
		}
		break;
		
		case 'x':                   //Exit upgrade
		{
			GICR = _BV(IVCE); 
			GICR &= ~(_BV(IVSEL) | _BV(IVCE)); //move interruptvectors to the Application sector  Write 0 to IVCE
		    jump_to_app(); // Jump to application sector
//		    wdt_enable(WDTO_15MS); // Enable Watchdog Timer to give reset
		}
		break;    
		default:
		{
		   uart_write_str(" u - Upload or x - Execute \n");
		}
	   } // end switch
	}  
    }	// end while(1)
// Start to application

	 GICR = _BV(IVCE); 
	 GICR &= ~(_BV(IVSEL) | _BV(IVCE)); //move interruptvectors to the Application sector  Write 0 to IVCE
	 jump_to_app(); // Jump to application sector

    return 0;
}