Esempio n. 1
0
void
hasp_mpc5xxx_i2c_init()
{
    initReset();										// initialise the reset pin
    resetHigh();

    cyg_drv_mutex_init(&i2c_lock);
    cyg_drv_cond_init(&i2c_wait, &i2c_lock);
    cyg_drv_interrupt_create(i2c_intr_vector,
                             0,
                             (cyg_addrword_t) 0,
                             &mpc5xxx_i2c_isr,
                             &mpc5xxx_i2c_dsr,
                             &(i2c_interrupt_handle),
                             &(i2c_interrupt_data));
    cyg_drv_interrupt_attach(i2c_interrupt_handle);

    HAL_WRITE_UINT32(I2C_0_FDR_REG, 0x89000000);		// Set clock to 100MHz / 352

    HAL_WRITE_UINT32(I2C_0_ADDRESS_REG, 0x00000000);	// Set MPC5xxx slave address, not useful to us

    HAL_WRITE_UINT32(I2C_0_CONTROL_REG, I2C_ENABLE);	// Enable the I2C device but do not start any transfers and leave interrupts disabled.

    HAL_WRITE_UINT32(I2C_0_STATUS_REG, 0x00000000);		// Clear any pending conditions including interrupts.

    HAL_INTERRUPT_UNMASK(i2c_intr_vector);				// Interrupts can now be safely unmasked

    i2c_flag = 0;

    resetLow();

}
Esempio n. 2
0
File: comp.c Progetto: enyone/cvavr
void main(void)
{
  initd();
       
  LED1 = 0;
  LED2 = 0;
  initIdle();
  
  initTimers();
  
  while (1)
  {
    readInputs();
    
    if(timerflag)
    {
      bcount ++;
      if(bcount >= blinkspeed)
      {
        if(blink == 0) blink = 1; else blink = 0;
        LED1 = blink;
        bcount = 0;
      }
      
      if(scount <= 1) { scount ++; LED2 = 0; }
      else LED2 = 1;
      
      sendcount ++;
      
      if(serial0_null <= 4) serial0_null ++;
      else u0 = 0;
      
      if(wakecheck > 0) wakecheck --;
      else initReset();
      
      timerflag = 0;
    }
    
    if(sendcount >= 25)
    {
      if(tied.onoff)
      {
        sendLcdChar(kmh);
        sendLcdChar(rpm);
        sendLcdChar(20);
        sendLcdChar(20);
        sendLcdChar(1);
        sendLcdChar(1);
        sendLcdChar(matka>>8);
        sendLcdChar(matka);
        sendcount = 0;
        matka = 0;
      }
    }    
  }
Esempio n. 3
0
File: comp.c Progetto: enyone/cvavr
void syncAset(void)
{
  reset = u_lcd_string[0];
  tied.onoff = u_lcd_string[1];
  tied.rele1 = u_lcd_string[2];
  tied.rele2 = u_lcd_string[3];
  ring = u_lcd_string[4];
  ring = (ring<<8) + u_lcd_string[5];
  
  if(reset) initReset();
}