22.4 Initialization and Configuration
The whole block may be enabled or disabled using the system control registers. The following example shows how to enable, force a reset and send a command.
- Enable the 1-Wire Module by writing a value of 0x0000.0001 to the 1-Wire Run Mode Clock Gating Control (RCGCOWIRE) register in the System Control Module, see Section 4.2.104.
- Enable the clock to the appropriate GPIO port that is used for the 1-Wire signals using the General-Purpose Input/Output Run Mode Clock gating Control (RCGCGPIO) in the System Control Module; see Section 4.2.87. To find out which GPIO port to enable, see and the device-specific data sheet.
- In the GPIO module, enable the appropriate pin for its alternate function using the GPIO Alternate Function Select (GPIOAFSEL) register (see Section 17.5.10).
- Configure the PMCn fields in the GPIOPCTL register to assign the 1-Wire signals to the appropriate pins. See Section 17.5.22 and the device-specific data sheet.
- Optionally enable interrupts to be notified when the transactions completes.
- Write to the ONEWIREDATW register with the data to write (1, 2, 3, or 4 bytes).
- Write to the ONEWIRECS register to set the RST bit and configure the OP (operation) and SZ fields. When configuring all three bit fields, the reset is performed first, followed by the operation (unless an error occurs) and then any interrupt triggers.
- If normal interrupts are generated (for example, OPC and RST), clear these interrupts and read the ONEWIREDATR register if a read or read/write transaction occurred.
- If the 1-Wire master has more data to write and/or read for the same command, repeat the previous two steps but without setting the RST bit. If a new command is required, repeat the previous two steps including the reset enable.