コード例 #1
0
ファイル: pca9548a.c プロジェクト: Sean3Don/OSSI-1Firmware
void PCA9548A_Reset(void)
{
    IO_SET(PCA9548A_RESET, LOW);
    __delay_cycles(100000);
    IO_SET(PCA9548A_RESET, HIGH);
    __delay_cycles(100000);
}
コード例 #2
0
ファイル: pressure.c プロジェクト: TLoebner/apbteam
void
pressure_update (void)
{
    if (pressure.wait)
      {
	pressure.wait--;
      }
    else
      {
	switch (pressure.state)
	  {
	  case PRESSURE_INITIAL:
	    if (pressure.low)
	      {
		/* Open circuit. */
		IO_SET (OUTPUT_PNEUM_OPEN);
		pressure.state++;
		pressure.wait = PRESSURE_OPEN_WAIT;
	      }
	    break;
	  case PRESSURE_IDLE:
	    if (pressure_get () < pressure.low)
	      {
		/* Start pump. */
		mimot_motor_output_set (1, 0x3ff);
		pressure.state++;
		pressure.wait = PRESSURE_START_WAIT;
	      }
	    else
		pressure.wait = PRESSURE_INTERVAL;
	    break;
	  case PRESSURE_STARTING:
	    /* Started, close circuit. */
	    IO_CLR (OUTPUT_PNEUM_OPEN);
	    pressure.state++;
	    break;
	  case PRESSURE_PUMPING:
	    /* Pump until high. */
	    if (pressure_get () > pressure.high)
	      {
		/* Done. Stop. Open circuit. */
		mimot_motor_free (1, 0);
		IO_SET (OUTPUT_PNEUM_OPEN);
		pressure.state = PRESSURE_IDLE;
		pressure.wait = PRESSURE_REST;
	      }
	    else
		pressure.wait = PRESSURE_INTERVAL;
	    break;
	  }
      }
}
コード例 #3
0
ファイル: spi.c プロジェクト: BastilleResearch/killerbee
/*========================= IMPLEMENTATION           =========================*/
int spi_init(SpiMaster_t SpiMasterEnable, SpiMode_t SpiMode, SpiDataOrder_t DataOrder, SpiSpeed_t SpiSpeed)
{
    // enable SPI module
    PRR &= ~(1 << PRSPI);

    // I/O interface
    IO_INPUT_NO_PULLUP(SPI, 1, MISO);
    IO_OUTPUT(SPI, 3, MOSI, SCK, SS);

    // set default value SS pin
    IO_SET(SPI,1,SS);

    // Clear interrupt flag (and write SPI2X)
    IO_PUT(SPSR,(1<<SPIF) | (SpiSpeed & (1<<(SPI2X+MAGIC_OFFSET)))>>MAGIC_OFFSET);

    // init buffer
    sgSpi.buffer.in_ptr = NULL;
    sgSpi.buffer.out_ptr = NULL;
    sgSpi.buffer.end = NULL;
    sgSpi.buffer.size = 0;
    sgSpi.busy = false;

    // Configure SPI and enable the SPI interface
    SPCR = (uint8_t)SpiMasterEnable
        | (uint8_t)SpiMode
        | (uint8_t)DataOrder
        | ((uint8_t)(SpiSpeed & ((1<<SPR1) | (1<<SPR0))))
        | (1<<SPE);
    
    return 0;
}