Still not having any luck with this

Could anyone provide pointers?
I'm trying something like this (adding to g2100.c by just hacking around)
- Code: Select all
void zg_sleep_toggle()
{
U8 loop_cnt = 0;
do {
// write reset register addr
hdr[0] = ZG_INDEX_ADDR_REG;
hdr[1] = 0x00;
hdr[2] = ZG_PWR_CTRL_REG;
spi_transfer(hdr, 3, 1);
hdr[0] = ZG_INDEX_DATA_REG;
hdr[1] = (loop_cnt == 0)?(0x80):(0x0f);
hdr[2] = 0xff;
spi_transfer(hdr, 3, 1);
} while(loop_cnt++ < 1);
// write sleep register data
hdr[0] = ZG_INDEX_ADDR_REG;
hdr[1] = 0x00;
hdr[2] = ZG_PWR_STATUS_REG;
spi_transfer(hdr, 3, 1);
do {
hdr[0] = 0x40 | ZG_INDEX_DATA_REG;
hdr[1] = 0x00;
hdr[2] = 0x00;
spi_transfer(hdr, 3, 1);
} while((hdr[1] & ZG_ENABLE_LOW_PWR_MASK) == 0);
do {
hdr[0] = 0x40 | ZG_PWR_CTRL_REG_LEN;
hdr[1] = 0x00;
hdr[2] = 0x00;
spi_transfer(hdr, 3, 1);
} while((hdr[1] == 0) && (hdr[2] == 0));
}
But as I know nothing of the SPI protocol, or the registers on the chip, I have no idea if this will work.