Chameleon-AVR Nurve Networks, Chameleon-AVR Datasheet - Page 162

MCU, MPU & DSP Development Tools AVR8 & PROPELLER DEV SYSTEM (SBC)

Chameleon-AVR

Manufacturer Part Number
Chameleon-AVR
Description
MCU, MPU & DSP Development Tools AVR8 & PROPELLER DEV SYSTEM (SBC)
Manufacturer
Nurve Networks
Datasheet

Specifications of Chameleon-AVR

Processor To Be Evaluated
AVR 328P
Data Bus Width
8 bit
Interface Type
USB, VGA, PS/2, I2C, ISP, SPI
Operating Supply Voltage
3.3 V, 5 V
Lead Free Status / RoHS Status
Lead free / RoHS Compliant
Example(s):
As you can see, using the TWI_Action(…) function must be interleaved with the protocol of the target device. The low
level I
and control of the target device (a digital pot in this case) is a completely other issue. Reviewing the code, you can see
that the first step is to send the START and address to the device, then start writing data to control the pot. Also, notice
the testing of the return value from each call to TWI_Action(…). Depending on the results you can take what action you
must. In this case, the empty function TWI_Error() are called, which you can insert any code you wish.
________________________________________________________________________________________________
Function Prototype(s):
Description(s):
Example(s):
_______________________________________________________________________________________________
Function Prototype:
2
C protocol is handled by each call to TWI_Action(…) via the hardware, but the actual communication bytes, setup,
void TWI_Error();
void TWI_Status();
void TWI_Success(int code);
int SPI_Init(unsigned char spi_rate);
The complete listing of the digital potentiometer function excerpted from the Mechatronics library.
None.
parameter to the TWI hardware “control register” (listed as TWCR in the datasheet). Then the function
waits for the operation to complete by blocking on the TWINT flag. Normally, you use the TWI_Action(…)
function to perform any and all operations by logically OR’ing various TWI flags together. The flags can
be found in the AVR 328P datasheet. Returns the TWI hardware module’s status register TWSR, this can
be tested against common TWI status and success values to determine the results of any action.
These functions are not implemented and are simply place holders or wrappers for future
expansion. As noted in the primer on I2C, the protocol has a lot of state and you might want to
add these functions to the API and fill them out. Currently, a much simpler approach is taken
where the single “action” function (listed above) performs both any action as well as returns
status and errors.
© 2009 NURVE NETWORKS LLC “Exploring the Chameleon AVR 8-Bit”
162

Related parts for Chameleon-AVR