The BQ40Z80 supports generating interrupts on pins configured as GPIOs. It includes a flag mapping function for these pins, which is a bank of eight control registers, FlagMapSetUp0..7, that enable up to eight separate flags in the device to be mapped to one or more GPIO pins. Flags may be OR'ed or AND'ed together to trigger an interrupt on a particular GPIO pin. For example, up to eight different flags can be OR'ed onto a single GPIO pin or up to seven flags are OR'ed together then AND with the 8th flag to trigger an interrupt. An example is provided below to demonstrated it:
Example: Configure FlagMapSetUp0..2 to trigger the active high interrupt on RC2 (pin 12) only when battery is inserted OperationStatus()[PRES] and either OperationStatus()[XCHG] is set or BatteryMode()[CF] is set.
- Configure the first control register FlagMapSetUp0 to map OperationStatus()[XCHG].
- Set FlagMapSetUp0[FLAG_EN] = 1 to enable the control.
- Set FlagMapSetUp0[FLAG_REG2:0] = 0x02 for OperationStatus().
- Set FlagMapSetUp0[FLAG_BIT4:0] = 0x0E for OperationStatus()[XCHG].
- Set FlagMapSetUp0[FLAG_POL:0] = 0 for no change in the polarity of the flag.
- Set FlagMapSetUp0[FLAG_GPIO2:0] = 0x7 for the RC2 pin.
- Set FlagMapSetUp0[FLAG_OR] = 1 for the OR operation.
- Set FlagMapSetUp0[FLAG_OD] = 0 for driven-high/driven low.
- Configure the second control register FlagMapSetUp1 to map BatteryMode()[CF].
- Set FlagMapSetUp1[FLAG_EN] = 1 to enable the control.
- Set FlagMapSetUp1[FLAG_REG2:0] = 0x00 for BatteryMode().
- Set FlagMapSetUp1[FLAG_BIT4:0] = 0x07 for BatteryMode()[CF].
- Set FlagMapSetUp1[FLAG_POL:0] = 0 for no change in the polarity of the flag.
- Set FlagMapSetUp1[FLAG_GPIO2:0] = 0x7 for the RC2 pin.
- Set FlagMapSetUp1[FLAG_OR] = 1 for the OR operation.
- Set FlagMapSetUp1[FLAG_OD] = 0 for driven-high/driven low.
- Configure the third control register FlagMapSetUp2 to map OperationStatus()[PRES].
- Set FlagMapSetUp2[FLAG_EN] = 1 to enable the control.
- Set FlagMapSetUp2[FLAG_REG2:0] = 0x02 for OperationStatus().
- Set FlagMapSetUp2[FLAG_BIT4:0] = 0x00 for OperationStatus()[PRES].
- Set FlagMapSetUp2[FLAG_POL:0] = 0 for no change in the polarity of the flag.
- Set FlagMapSetUp2[FLAG_GPIO2:0] = 0x7 for the RC2 pin.
- Set FlagMapSetUp2[FLAG_OR] = 0 for the OR operation.
- Set FlagMapSetUp2[FLAG_OD] = 0 for driven-high/driven-low.