Esempio n. 1
1
void main() 
{
   output_low(PIN_A2); //Apaga LED_1
   output_low(PIN_B2); //Apaga LED_2
   enable_interrupts(INT_EXT);//Ativação da interrupção externa      
   lcd_init();//Inicialização da biblioteca para o uso do LCD
   enable_interrupts(INT_SSP);//Ativação da interrupção SPI 
   enable_interrupts(GLOBAL); //Ativação da interrupção Global 
   setup_spi(spi_master | spi_l_to_h |SPI_SAMPLE_AT_END | SPI_SS_DISABLED);
   
   while(1)
   {
   delay_ms(40);
   spi_write(15);
  } 
}
Esempio n. 2
0
void main(void) 
{
  //we use PIN_C2 as an event to determine if we should start the USB CDC
  //bootloader.  if it is not low (button is not pressed) then goto the 
  //application, else if is low (button is pressed) then do the bootloader.
  output_bit(PIN_C2, 1);

  if(!input(PIN_C2))
  {
    setup_spi(SPI_MASTER | SPI_L_TO_H | SPI_XMIT_L_TO_H | SPI_CLK_DIV_16);

    //Max7219 Initialized
    initLedDriver();

    g_InBootloader = TRUE;
    usb_cdc_init();
    usb_init();
    while(!usb_enumerated());
    load_program();
  }

  g_InBootloader = FALSE;
#ASM
  goto APPLICATION_START
#ENDASM
}
int board_init(void)
{
	/* address of boot parameters */
	gd->bd->bi_boot_params = PHYS_SDRAM + 0x100;

#ifdef CONFIG_MXC_SPI
	setup_spi();
#endif
	imx_iomux_v3_setup_multiple_pads(
		usdhc2_pads, ARRAY_SIZE(usdhc2_pads));
	imx_iomux_v3_setup_multiple_pads(i2c0_mux_pads,
					 ARRAY_SIZE(i2c0_mux_pads));
	imx_iomux_v3_setup_multiple_pads(
		gpio_pads, ARRAY_SIZE(gpio_pads));
	gpio_direction_output(IMX_GPIO_NR(1, 7),0);   /* GPIO7 */
	gpio_direction_output(IMX_GPIO_NR(1, 8),0);   /* GPIO8 */
	gpio_direction_input(IMX_GPIO_NR(7, 13));     /* GPIO18 */
	gpio_direction_input(IMX_GPIO_NR(4, 5));      /* GPIO19 */
	gpio_direction_output(IMX_GPIO_NR(3, 29), 1); /* EIM_D29: ONOFF */

	gpio_direction_output(IMX_GPIO_NR(3,20),0);
	gpio_direction_output(IMX_GPIO_NR(2,23),1); /* enable RTC */
	setup_i2c(0, CONFIG_SYS_I2C_SPEED, 0x7f, &i2c_pad_info0);
	setup_i2c(1, CONFIG_SYS_I2C_SPEED, 0x7f, &i2c_pad_info1);
	setup_i2c(2, CONFIG_SYS_I2C_SPEED, 0x7f, &i2c_pad_info2);

	return 0;
}
void init_pic()
{
   setup_adc_ports(AN0);
   setup_adc(ADC_CLOCK_DIV_32);
   setup_psp(PSP_DISABLED);
   setup_spi(FALSE);
   setup_counters( RTCC_INTERNAL, RTCC_DIV_1 | RTCC_8_BIT);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_comparator(NC_NC_NC_NC);
   setup_vref(FALSE);
   enable_interrupts(INT_RTCC);
   enable_interrupts(INT_EXT);
   enable_interrupts(GLOBAL);

   EXT_INT_EDGE(L_TO_H);

   OUTPUT_B(0);
   OUTPUT_C(0);

   SET_TRIS_B(0b01000111);   //pins B0, B1, B2 and B6 are set to give inputs. B0 is the external interuupt pin
                             //B0, B1 & B2 are used for people counting. B6 for zero crossing detection in fan controlling
   SET_TRIS_C(0b00000000);
   SET_TRIS_D(0b00000000);   //D port except D0 pin, is used for lcd panel

   set_adc_channel(0);            //the next read_adc call will read channel 0
}
Esempio n. 5
0
void main()
{
   
   setup_adc_ports(NO_ANALOGS);
   setup_adc(ADC_OFF);
   setup_spi(SPI_SS_DISABLED);
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_comparator(NC_NC_NC_NC);
   setup_vref(FALSE);
   
   TX = 0;
   RX = 1;
   
   TRIS_B = 0x00;
   
   while(1)
   {
      //putc(getc());
      LED = 1;
      delay_ms(300);
      
      LED = 0;
      delay_ms(300);
      
      if(verificaFlag())
      {
         if(recebeByte())
            enviaByte('T');
      }      
   }
}
Esempio n. 6
0
int board_init(void)
{
    struct iomuxc *const iomuxc_regs = (struct iomuxc *)IOMUXC_BASE_ADDR;

    clrsetbits_le32(&iomuxc_regs->gpr[1],
                    IOMUXC_GPR1_OTG_ID_MASK,
                    IOMUXC_GPR1_OTG_ID_GPIO1);

    imx_iomux_v3_setup_multiple_pads(misc_pads, ARRAY_SIZE(misc_pads));

    /* address of boot parameters */
    gd->bd->bi_boot_params = PHYS_SDRAM + 0x100;

#ifdef CONFIG_MXC_SPI
    setup_spi();
#endif
    imx_iomux_v3_setup_multiple_pads(
        usdhc2_pads, ARRAY_SIZE(usdhc2_pads));
    setup_i2c(0, CONFIG_SYS_I2C_SPEED, 0x7f, &i2c_pad_info0);
    setup_i2c(1, CONFIG_SYS_I2C_SPEED, 0x7f, &i2c_pad_info1);
    setup_i2c(2, CONFIG_SYS_I2C_SPEED, 0x7f, &i2c_pad_info2);

#ifdef CONFIG_CMD_SATA
    setup_sata();
#endif

    return 0;
}
Esempio n. 7
0
//=============================================================================
void init_prog(void)
{
setup_wdt(WDT_OFF);
setup_adc_ports(NO_ANALOGS|VSS_VDD);
setup_adc(ADC_OFF);
setup_psp(PSP_DISABLED);                                                
setup_spi(SPI_SS_DISABLED);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_16|RTCC_8_BIT);// TIMER0
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_timer_3(T3_DISABLED|T3_DIV_BY_1);
setup_comparator(NC_NC_NC_NC);                                           
setup_vref(FALSE);
setup_low_volt_detect(FALSE);              
setup_oscillator(OSC_32MHZ);                                        

set_tris_a(0xFF);//7F
set_tris_b(0xFF); //FF
set_tris_c(0x94);//94
set_tris_d(0xFF); //02                                     
set_tris_e(0xF0);  //f0   
set_tris_f(0xFF);//ff
set_tris_g(0xFC); //04
output_a(0x00);
output_b(0x00);
output_c(0x00);
output_d(0x00);
output_e(0x00);
output_f(0x00);
output_g(0x00);
}
void main()
{

   setup_adc_ports(NO_ANALOGS|VSS_VDD);
   setup_adc(ADC_OFF|ADC_TAD_MUL_0);
   setup_psp(PSP_DISABLED);
   setup_spi(SPI_SS_DISABLED);
   setup_wdt(WDT_OFF);
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_32|RTCC_8_bit);   //RTCC_DIV_32 -> 122 Hz ou 30 Hz por nivel
   setup_timer_1(T1_INTERNAL|T1_DIV_BY_8);
   setup_timer_2(T2_DISABLED,0,1);
   setup_comparator(NC_NC_NC_NC);
   setup_vref(FALSE);
   enable_interrupts(INT_RTCC);
   enable_interrupts(INT_TIMER1);
   enable_interrupts(INT_EXT);
   enable_interrupts(INT_EXT1);
   enable_interrupts(GLOBAL);

   
   set_tris_a (0b11110000);
   set_tris_c (0b00000000);
   set_tris_d (0b00000000);
   
   
   while(1){
	delay_ms(10);
   }

}
Esempio n. 9
0
void board_init_f(ulong dummy)
{
#ifdef CONFIG_CMD_NAND
	/* Enable NAND */
	setup_gpmi_nand();
#endif

	/* setup clock gating */
	ccgr_init();

	/* setup AIPS and disable watchdog */
	arch_cpu_init();

	/* setup AXI */
	gpr_init();

	board_early_init_f();

	/* setup GP timer */
	timer_init();

	setup_spi();

	/* UART clocks enabled and gd valid - init serial console */
	preloader_console_init();

	/* DDR initialization */
	spl_dram_init();

	/* Clear the BSS. */
	memset(__bss_start, 0, __bss_end - __bss_start);

	/* load/boot image from boot device */
	board_init_r(NULL, 0);
}
Esempio n. 10
0
void main(){
   
   //CHAR letA[]="A";
   //CHAR letB[]="B";
   //CHAR letC[]="C";
   //CHAR espera[]="teste";
   
   setup_adc_ports(NO_ANALOGS);
   setup_adc(ADC_OFF);
   setup_psp(PSP_DISABLED);
   setup_spi(SPI_SS_DISABLED);
   setup_wdt(WDT_OFF);
   setup_timer_0(RTCC_INTERNAL);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_timer_3(T3_DISABLED|T3_DIV_BY_1);

   glcd_init(ON);   //inicializa o display
   glcd_fillScreen(0); //limpa display inteiro
   
   //glcd_text57(34, 55, letA, 1, 1);
   //glcd_rect(46,53,60,63,1,1);
   //glcd_text57(48,  55, letB, 1, 0);

   while(TRUE){
   
   glcd_imagem(1);
   delay_ms(3000);
   glcd_fillScreen(0); //limpa display inteiro
   glcd_imagem(2);
   delay_ms(3000);
   glcd_fillScreen(0); //limpa display inteiro
   
   }
}
Esempio n. 11
0
void main()
{

   setup_adc_ports(ALL_ANALOG);
   setup_adc(ADC_CLOCK_INTERNAL);
   setup_psp(PSP_DISABLED);
   setup_spi(SPI_SS_DISABLED);
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_comparator(NC_NC_NC_NC);
   setup_vref(FALSE);

   // TODO: USER CODE!!
   
      set_adc_channel(0);            // set ref valus
      delay_ms(100);
      ref_0 =read_adc();
      delay_ms(100);
      
      set_adc_channel(3);            // set ref valus
      delay_ms(100);
      ref_3 =read_adc();
      delay_ms(100);
   
   output_b(0b11111111);
   delay_ms(700);
   output_b(0);
   
   while(1){
      set_adc_channel(0);
      delay_ms(20);                        // take readings
      adc_val_0 =read_adc();
      delay_ms(20);
      if(adc_val_0 > ref_0+cons){
         l_0 =1;
         output_high(pin_d7);
         delay_ms(500);
      }
      else{
         l_0=0;
         output_low(pin_d7);
     //    delay_ms(500);
      }
      
      set_adc_channel(3);
      delay_ms(20);                        // take readings
      adc_val_3 =read_adc();
      delay_ms(20);
      if(adc_val_3> ref_3+cons){
         l_3 =1;
         output_high(pin_d6);
         delay_ms(500);
      }
      else{
         l_3=0;
         output_low(pin_d6);
      }
   }
}
Esempio n. 12
0
int main(void) {
	// Initialize serial port for output
	uart_init();
	stdout = &uart_output;
	stdin  = &uart_input;

	// Setting up interrupts
	interrupt_init();

	// Disable unused ports to lower consumption
	disable_ports();

	// Setup SPI
	setup_spi(SPI_MODE_0, SPI_MSB, SPI_NO_INTERRUPT, SPI_MSTR_CLK2);

	fprintf(stdout,"START\n");

	setup_wdt(); // Setup watchdog functions

	sei(); // Enable interrupts

	while (1) {
		enter_sleep();	

	}

//	wdt_disable();

    return 0;
}
void main()
{

   setup_adc_ports(NO_ANALOGS);
   setup_adc(ADC_OFF);
   setup_psp(PSP_DISABLED);
   setup_spi(FALSE);
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);

while (TRUE) {

      printf("\r\nSinyali Baslatmak icin B tusuna basiniz");
      if (getchar() == 'b')         //eðer b tuþuna basarsan
      {
         printf("\n1 hz sinyal aktif edildi\r");
            while (1) {
               output_high(PIN_B0);
               delay_ms(500);
               output_low(PIN_B0);
               delay_ms(500);
            }
      }
   }
}
void init_pic()
{
   setup_adc_ports(AN0);
   setup_adc(ADC_CLOCK_DIV_32);
   setup_psp(PSP_DISABLED);
   setup_spi(FALSE);
   setup_counters( RTCC_INTERNAL, RTCC_DIV_1 | RTCC_8_BIT);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_comparator(NC_NC_NC_NC);
   setup_vref(FALSE);
   enable_interrupts(INT_RTCC);
   enable_interrupts(INT_EXT);
   enable_interrupts(GLOBAL);

   EXT_INT_EDGE(L_TO_H);

   OUTPUT_B(0);
   OUTPUT_C(0);

   SET_TRIS_B(0b01000111);   //pins B0, B1 and B2 are set to give inputs. b0 is the external interuupt pin
   SET_TRIS_C(0b00000000);
   SET_TRIS_D(0b00000000);

   set_adc_channel(0);            //the next read_adc call will read channel 0
}
Esempio n. 15
0
// set alarm to go off every minute
void RTC_minute()
{
   int8 RTC_buffer;
   
   setup_spi(SPI_MASTER|SPI_MODE_0_0|SPI_CLK_DIV_16);
   
   // Do not write alarm seconds last. It will disable the interrupt/flag
   output_bit(RTC_CS, ENABLE);
   RTC_buffer = spi_read(0x8E);        // address - Sec
   RTC_buffer = spi_read(0b00000000);  // data
   output_bit(RTC_CS, DISABLE);
   output_bit(RTC_CS, ENABLE);
   RTC_buffer = spi_read(0x8D);        // address - Min
   RTC_buffer = spi_read(0b10000000);  // data
   output_bit(RTC_CS, DISABLE);
   output_bit(RTC_CS, ENABLE);
   RTC_buffer = spi_read(0x8C);        // address - Hour
   RTC_buffer = spi_read(0b10000000);  // data
   output_bit(RTC_CS, DISABLE);
   output_bit(RTC_CS, ENABLE);
   RTC_buffer = spi_read(0x8B);        // address - DOM
   RTC_buffer = spi_read(0b11000000);  // data
   output_bit(RTC_CS, DISABLE);   
   output_bit(RTC_CS, ENABLE);
   RTC_buffer = spi_read(0x8A);        // address - Month
   RTC_buffer = spi_read(0b10000000);  // data
   output_bit(RTC_CS, DISABLE);
   
   RTC_read_alarm();
}
void main()
{

   setup_adc_ports(NO_ANALOGS|VSS_VDD);
   setup_adc(ADC_OFF|ADC_TAD_MUL_0);
   setup_psp(PSP_DISABLED);
   setup_spi(SPI_SS_DISABLED);
   setup_wdt(WDT_OFF);
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_16|RTCC_8_bit);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_comparator(NC_NC_NC_NC);
   setup_vref(FALSE);
   enable_interrupts(INT_RTCC);
   enable_interrupts(INT_EXT);
   enable_interrupts(INT_EXT1);
   enable_interrupts(GLOBAL);
   
   set_tris_a (0b11110000);
   set_tris_b (0b00000000);
   set_tris_c (0b00000000);
   
   cubeLevelC0 = 0xFF;
   cubeLevelC1 = 0x00;
   cubeLevelC2 = 0xFF;
   cubeLevelC3 = 0x00;
   
   cubeLevelD0 = 0x00;
   cubeLevelD1 = 0xFF;
   cubeLevelD2 = 0x00;
   cubeLevelD3 = 0xFF;

}
Esempio n. 17
0
void RTC_read()
{
   int8 RTC_buffer;
   
   RTC_buffer = 0;
   
   setup_spi(SPI_MASTER|SPI_MODE_0_0|SPI_CLK_DIV_16);
   
   output_bit(RTC_CS, ENABLE);
   RTC_buffer = spi_read(0x00);
   RTC_Tenths_Sec_Reg = spi_read(RTC_buffer);
   RTC_Sec_Reg = spi_read(RTC_buffer);
   RTC_Min_Reg = spi_read(RTC_buffer);
   RTC_Hr_Reg =  spi_read(RTC_buffer);
   RTC_DOW_Reg = spi_read(RTC_buffer);
   RTC_DOM_Reg = spi_read(RTC_buffer);
   RTC_Mon_Reg = spi_read(RTC_buffer);
   RTC_Yr_Reg =  spi_read(RTC_buffer);
   output_bit(RTC_CS, DISABLE);
      
   RTC_Sec_Reg = Bcd2Dec(RTC_Sec_Reg);
   RTC_Min_Reg = Bcd2Dec(RTC_Min_Reg);
   RTC_Hr_Reg = Bcd2Dec(RTC_Hr_Reg);
   RTC_DOM_Reg = Bcd2Dec(RTC_DOM_Reg);
   RTC_Mon_Reg = Bcd2Dec(RTC_Mon_Reg);
   RTC_Yr_Reg = Bcd2Dec(RTC_Yr_Reg);
}
Esempio n. 18
0
void main()
{

   setup_adc_ports(NO_ANALOGS|VSS_VDD);
   setup_adc(ADC_OFF);
   setup_spi(SPI_SS_DISABLED);
   setup_wdt(WDT_OFF);
   setup_timer_0(RTCC_INTERNAL);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_comparator(NC_NC_NC_NC);
   setup_vref(FALSE);
   enable_interrupts(INT_EXT);
   ext_int_edge(L_to_H);
   enable_interrupts(GLOBAL);
   output_low(PIN_B7);
//Setup_Oscillator parameter not selected from Intr Oscillator Config tab

   // TODO: USER CODE!!
   
   while(TRUE)
   {
   }

}
Esempio n. 19
0
void RTC_read_alarm(){

   int8 RTC_buffer;
   
   RTC_buffer = 0;
   
   setup_spi(SPI_MASTER|SPI_MODE_0_0|SPI_CLK_DIV_16);
   
   output_bit(RTC_CS, ENABLE);
   RTC_buffer = spi_read(0x0A);
   RTC_Al_Mon_Reg = spi_read(RTC_buffer);
   RTC_Al_DOM_Reg = spi_read(RTC_buffer);
   RTC_Al_Hr_Reg = spi_read(RTC_buffer);
   RTC_Al_Min_Reg = spi_read(RTC_buffer);
   RTC_Al_Sec_Reg = spi_read(RTC_buffer);
   RTC_Flags_Reg = spi_read(RTC_buffer);
   output_bit(RTC_CS, DISABLE);
   
   RTC_Al_Mon_Reg = RTC_Al_Mon_Reg & 0b00011111;
   RTC_Al_Mon_Reg = Bcd2Dec(RTC_Al_Mon_Reg);
   RTC_Al_DOM_Reg = RTC_Al_DOM_Reg & 0b00111111;
   RTC_Al_DOM_Reg = Bcd2Dec(RTC_Al_DOM_Reg);
   RTC_Al_Hr_Reg = RTC_Al_Hr_Reg & 0b00111111;
   RTC_Al_Hr_Reg = Bcd2Dec(RTC_Al_Hr_Reg);
   RTC_Al_Min_Reg = RTC_Al_Min_Reg & 0b01111111;
   RTC_Al_Min_Reg = Bcd2Dec(RTC_Al_Min_Reg);
   RTC_Al_Sec_Reg = RTC_Al_Sec_Reg & 0b01111111;
   RTC_Al_Sec_Reg = Bcd2Dec(RTC_Al_Sec_Reg);
}
Esempio n. 20
0
void main()
{
   int16 valor;
   float tensao;
   lcd_init();



   setup_adc_ports(AN0|VSS_VDD);
   setup_adc(ADC_CLOCK_DIV_16);
   setup_psp(PSP_DISABLED);
   setup_spi(SPI_SS_DISABLED);
   setup_wdt(WDT_OFF);
   setup_timer_0(RTCC_INTERNAL);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_comparator(NC_NC_NC_NC);
   setup_vref(FALSE);
   set_adc_channel(0);
//Setup_Oscillator parameter not selected from Intr Oscillator Config tab

   // TODO: USER CODE!!

   while(1)
   {
      valor = read_adc();
      tensao = valor*5.0/1024.0;
      printf("ADC = %04ld",valor);
      printf("    Tensao = %.3fV\r", tensao);
      printf(lcd_putc,"\fADC = %ld",valor);
      printf(lcd_putc,"\nTensao = %.3fV",tensao);
      delay_ms(250);
   }
   
}
Esempio n. 21
0
// set alarm to wake up at real-time
void RTC_alarm(){

   int8 time_error;
   int8 RTC_buffer;
   
   RTC_read_alarm();
   
   time_error = get_time();
   
   if (time_error == 0 ){
   
      // RTC does not have a year register - store in EEPROM
      RTC_Al_Yr_Reg = RTC_Yr_Data;
      write8(ADDR_ALARM_YR, RTC_Al_Yr_Reg);
   
      // Masking AFE bit to ensure alarm output is enabled
      RTC_Mon_Data = Dec2Bcd(RTC_Mon_Data);
      RTC_Mon_Data = RTC_Mon_Data | 0b10000000;
      
      // Freq DC to 2 MHz ((10/4)/16) = 625 kHz
      setup_spi(SPI_MASTER|SPI_MODE_0_0|SPI_CLK_DIV_16);
      delay_us(10);
      
      // Do not write alarm seconds last
      // ... it disables the interrupt/flag
   
      output_bit(RTC_CS, ENABLE);
      RTC_buffer = spi_read(0x8E);        // address - Sec
      RTC_buffer = spi_read(Dec2Bcd(RTC_Sec_Data));  // data
      output_bit(RTC_CS, DISABLE);
      delay_us(1);            // Delays added 1.020A
      
      output_bit(RTC_CS, ENABLE);
      RTC_buffer = spi_read(0x8D);        // address - Min
      RTC_buffer = spi_read(Dec2Bcd(RTC_Min_Data));  // data
      output_bit(RTC_CS, DISABLE);
      delay_us(1);
      
      output_bit(RTC_CS, ENABLE);
      RTC_buffer = spi_read(0x8C);        // address - Hour
      RTC_buffer = spi_read(Dec2Bcd(RTC_Hr_Data));  // data
      output_bit(RTC_CS, DISABLE);
      delay_us(1);   
      
      output_bit(RTC_CS, ENABLE);
      RTC_buffer = spi_read(0x8B);        // address - DOM
      RTC_buffer = spi_read(Dec2Bcd(RTC_DOM_Data));  // data
      output_bit(RTC_CS, DISABLE); 
      delay_us(1);
      
      output_bit(RTC_CS, ENABLE);
      RTC_buffer = spi_read(0x8A);        // address - Month
      RTC_buffer = spi_read(RTC_Mon_Data);  // data
      output_bit(RTC_CS, DISABLE);
      delay_us(1);
   
   RTC_read_alarm();
   }
}
Esempio n. 22
0
int board_early_init_f(void)
{

	setup_iomux_uart();
	setup_spi();

	return 0;
}
Esempio n. 23
0
int board_early_init_f(void)
{
	setup_iomux_uart();
#ifdef CONFIG_MXC_SPI
	setup_spi();
#endif
	return 0;
}
int board_init(void)
{
	/* address of boot parameters */
	gd->bd->bi_boot_params = PHYS_SDRAM + 0x100;

#ifdef CONFIG_MXC_SPI
	setup_spi();
#endif

	return 0;
}
Esempio n. 25
0
int main(void)
{
	uint8_t i;

	cli();
	MCUSR = 0;
	wdt_disable();

	//TODO replace by an ana comp polling loop
	_delay_ms(10);

	setup_datastructs();
	setup_led();
	setup_ar_uart();
	setup_adc();
	setup_pulse_input();
	setup_analog_comparator();
	setup_timer0();
	setup_timer1();
	
	// initialize the CTRL buffers
	ctrlInit();
	// initialize the SPI in slave mode
	setup_spi(SPI_MODE_0, SPI_MSB, SPI_INTERRUPT, SPI_SLAVE);

	// initialize the Si4421/RFM12 radio and buffers
	rfm12_init();

	// the clk/8 fuse bit is set
	clock_prescale_set(clock_div_1);
	FLAG_CLR_ICF1();
	sei();


	for(;;) {
		if (spi_status & SPI_NEW_CTRL_MSG) {
			ctrlDecode();
			spi_status &= ~SPI_NEW_CTRL_MSG;
		}

		for (i = 0; i < max_analog_sensors; i++) {
			if (state[i].flags & STATE_POWER_CALC) {
				calculate_power(&state[i]);
				state[i].flags &= ~STATE_POWER_CALC;
				state[i].flags |= STATE_POWER;
			}
		}

		rfm12_tick();
	}

	return 0;
}
Esempio n. 26
0
int board_init(void)
{
	/* address of boot parameters */
	gd->bd->bi_boot_params = PHYS_SDRAM + 0x100;

	setup_i2c(0, CONFIG_SYS_I2C_SPEED, 0x7f, &i2c_pad_info0);
	setup_i2c(1, CONFIG_SYS_I2C_SPEED, 0x7f, &i2c_pad_info1);
	setup_i2c(2, CONFIG_SYS_I2C_SPEED, 0x7f, &i2c_pad_info2);

	setup_spi();

	return 0;
}
Esempio n. 27
0
// RTC IRQ output is cleared & reset by reading the flags
// ... register
void RTC_read_flags()
{
   int8 RTC_buffer;
   
   RTC_buffer = 0;
   
   setup_spi(SPI_MASTER|SPI_MODE_0_0|SPI_CLK_DIV_16);
   
   output_bit(RTC_CS, ENABLE);
   RTC_buffer = spi_read(0x0F);
   RTC_Flags_Reg = spi_read(RTC_buffer);
   output_bit(RTC_CS, DISABLE);
}
Esempio n. 28
0
int board_init(void)
{
    /* address of boot parameters */
    gd->bd->bi_boot_params = PHYS_SDRAM + 0x100;
    /* i2c1 : PMIC, Audio codec on RiOT, Expansion connector on MarS */
    setup_i2c(0, CONFIG_SYS_I2C_SPEED, 0x7f, &i2c_pad_info1);
    /* i2c2 : HDMI EDID */
    setup_i2c(1, CONFIG_SYS_I2C_SPEED, 0x7f, &i2c_pad_info2);
    /* i2c3 : LVDS, Expansion connector */
    setup_i2c(2, CONFIG_SYS_I2C_SPEED, 0x7f, &i2c_pad_info3);
#ifdef CONFIG_MXC_SPI
    setup_spi();
#endif
    return 0;
}
Esempio n. 29
0
int board_init(void)
{
	/* address of boot parameters */
	gd->bd->bi_boot_params = PHYS_SDRAM + 0x100;

#ifdef CONFIG_MXC_SPI
	setup_spi();
#endif
	setup_i2c(1, CONFIG_SYS_I2C_SPEED, 0x7f, &i2c_pad_info1);

#ifdef CONFIG_USB_EHCI_MX6
	setup_usb();
#endif

	return 0;
}
Esempio n. 30
0
void main()
{
   int16 dato = 0;
   lcd_init();
   setup_spi(spi_slave | spi_l_to_h | spi_clk_div_16);     //configurar spi como esclavo
   for(;;)
   {
      if(spi_data_is_in())      //si hay un dato en el spi
      {        
         dato=(spi_read()); 
         lcd_gotoxy(1,1);
         printf(lcd_putc," %Ld   ",dato);
         //delay_ms(200);
      }
   }
}