Hello,
Below is a code example for changing FT5x06 touch controllers PMODE to deep sleep, the methodology would be the same for other touch controllers:
/* API to download custom capacitive touch firmware */ ft_void_t SAMAPP_InitCustomTouch(ft_uint32_t num_regs, ft_uint8_t *reg_value) {
ft_uint16_t patch,i_set,i_eol;
/* Reset the touch engine and download firmware into ROMSUB */ #ifdef FT_80X_ENABLE
Ft_Gpu_Hal_Wr8(phost, REG_CPURESET, 1);
Ft_Gpu_Hal_Wr8(phost, REG_ROMSUB_ENABLE_ACCESS, 1);
Ft_Gpu_Hal_Wr8(phost, REG_ROMSUB_SEL, 0);
/* Download the firmware into ROMSUB memory*/
Ft_Gpu_Hal_WrMem(phost,ROMSUB_ADDR, CTouchFirmware, sizeof(CTouchFirmware));
#else
Ft_Gpu_Hal_Wr8(phost, REG_CPURESET, 2);
#endif
#ifdef FT_80X_ENABLE
/* Construction of commands to the touch engine for register write at the reset */
patch = PATCH_START;
i_set = FW_RD(patch + 2);
i_eol = FW_RD(patch + 3);
#else
ft_uint16_t main = FW_RD(0) & 0xfff;
i_set = 0x4000 | (main - 4);
patch = main + 1;
i_eol = FW_RD(patch);
#endif
while (num_regs--) {
ft_uint8_t reg = *reg_value++;
ft_uint8_t val = *reg_value++;
/* construction of register and values */
FW_WR(patch++, 0x8000 | val);
FW_WR(patch++, 0x8000 | reg);
FW_WR(patch++, i_set);
}
/* constuction of end of line command to touch engine */
FW_WR(patch, i_eol);
#ifdef FT_80X_ENABLE
/* Assign the ROMSUB to touch engine and release from reset */
Ft_Gpu_Hal_Wr8(phost, REG_ROMSUB_ENABLE_ACCESS, 0);
Ft_Gpu_Hal_Wr8(phost, REG_ROMSUB_SEL, 1); #endif
Ft_Gpu_Hal_Wr8(phost, REG_CPURESET, 0);
Ft_Gpu_Hal_Sleep(300);//startup time required by touch engine to initialized touch controller }
The memory is ROMSUB which is at 3190784UL.
The structure is copied into ROMSUB with <address,value> and at the end “EOL” constants to indicate the end of structure.
Note that some settings in the CTP may require factory mode (such as setting gain) which can’t be done using this method. You may require firmware from the CTP manufacturer for some settings.
Alternatively, If you wanted to perform full direct firmware programming of the CTP, you can set the FT813 touch engine reset bit(or hold FT813 in power-down state), and talk directly between the MCU’s I2C master and the CTP.
Best Regards,
BRT Community