Ejemplo n.º 1
0
void SPI1_Init() {
  MapleSPIFrequency freq;
  uint32 spi_num, endian, prescale, mode;

  serialUsbPrintlnWaitForInput("***In SPI1_Init()");
  //serialUsbPrintln("***In SPI1_Init()");

  // set up CS pin
  ZG2100_CSInit();
  ZG2100_CSon();

  pinMode(D2, INPUT);

  // init SPI
  spi_num = 1;
  endian = SPI_MSBFIRST;
  //freq = MAPLE_SPI_4_5MHZ;
  freq = MAPLE_SPI_9MHZ;
  prescale = prescaleFactors[freq]; // only valid for SPI1
  mode = 0;
  spi_init(spi_num, prescale, endian, mode);

  //serialUsbPrintlnWaitForInput("*** Done with spi_init.");
  serialUsbPrintln("*** Done with spi_init.");
}
Ejemplo n.º 2
0
void zg_init()
{
    U8 clr;

    ZG2100_SpiInit();
    ZG2100_CSInit();
    ZG2100_CSon();
    clr = SPSR;
    clr = SPDR;

    intr_occured = 0;
    intr_valid = 0;
    zg_drv_state = DRV_STATE_INIT;
    zg_conn_status = 0;
    tx_ready = 0;
    rx_ready = 0;
    cnf_pending = 0;
    zg_buf = uip_buf;
    zg_buf_len = UIP_BUFSIZE;

    zg_chip_reset();
    zg_interrupt2_reg();
    zg_interrupt_reg(0xff, 0);
    zg_interrupt_reg(0x80|0x40, 1);

    ssid_len = (U8)strlen_P(ssid);
    security_passphrase_len = (U8)strlen_P(security_passphrase);
}
Ejemplo n.º 3
0
void spi_transfer(volatile unsigned char* buf, unsigned int len, unsigned char toggle_cs)
{
    unsigned int i;

    ZG2100_CSoff();

    for (i = 0; i < len; i++) {
        buf[i] = spiSendByte(buf[i]);
    }

    if (toggle_cs)
        ZG2100_CSon();

    return;
}
Ejemplo n.º 4
0
void spi_transfer(volatile U8* buf, U16 len, U8 toggle_cs)
{
	U16 i;

	ZG2100_CSoff();

	for (i = 0; i < len; i++) {
		ZG2100_SpiSendData(buf[i]);		// Start the transmission
		buf[i] = ZG2100_SpiRecvData();
	}

	if (toggle_cs)
		ZG2100_CSon();

	return;
}