Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //write to the device wiper0
- void mcp41xxx_write0(uint8_t dat) {
- spi_write(MCP41XXX_P0 | MCP41XXX_CMD_WRITE); //send the command byte
- spi_write(dat); //send the data byte
- }
- //write to the device wiper1
- void mcp41xxx_write1(uint8_t dat) {
- spi_write(MCP41XXX_P1 | MCP41XXX_CMD_WRITE); //send the command byte
- spi_write(dat); //send the data byte
- }
- //first pot
- spi_select(MCP41XXX_CS1); //deselect cs1 -> idles high
- mcp41xxx_write0(i + i); //send the data
- spi_deselect(MCP41XXX_CS1); //select hte device
- //second pot
- spi_select(MCP41XXX_CS2); //deselect cs1 -> idles high
- mcp41xxx_write0(i++); //send the data
- spi_deselect(MCP41XXX_CS2); //select the device
- //send data on wiper0 of mcp4141
- void mcp41xx_write0(uint16_t dat) {
- dat = dat & 0x03ff; //10-bit data
- spi_write(MCP41XX_CMD_WRITE | MCP41XX_WIPER0 | (dat >> 8)); //write the msb
- spi_write(dat); //write the lsb
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement