- diff --git a/ptxdist/local_src/common/hw/tle82353sa.cpp b/ptxdist/local_src/common/hw/tle82353sa.cpp
- index 08d2537..e3c5dc0 100644
- --- a/ptxdist/local_src/common/hw/tle82353sa.cpp
- +++ b/ptxdist/local_src/common/hw/tle82353sa.cpp
- @@ -29,6 +29,7 @@
- #include <sys/ioctl.h>
- #include <linux/spi/spidev.h>
- #include <string.h>
- +#include <stdio.h>
- #include <unistd.h>
- #include "pca9505.h"
- #include "tle82353sa.h"
- @@ -82,8 +83,8 @@ bool TLE82353SA::writeRegister(int hdl, unsigned char adr, unsigned long value)
- bRet = false;
- }
- else{
- - /* on error the chip responses with TLE82353SA_ICVID_CONTENT */
- - if( value == TLE82353SA_ICVID_CONTENT ){
- + /* on error the chip responses with its "Reset Value" */
- + if(TLE82353SA_RESET_VALUE_OK(value)){
- bRet = false;
- }
- else{
- @@ -127,7 +128,7 @@ bool TLE82353SA::readRegister(int hdl, unsigned char adr, unsigned long &value)
- * and Manufacturer ID register (ICVID).
- */
- if( adr == REGISTER_ICVID ){
- - if( value == TLE82353SA_ICVID_CONTENT ){
- + if(TLE82353SA_RESET_VALUE_OK(value)){
- bRet = true;
- }
- else{
- @@ -136,8 +137,8 @@ bool TLE82353SA::readRegister(int hdl, unsigned char adr, unsigned long &value)
- }
- }
- else{
- - /* on error the chip responses with TLE82353SA_ICVID_CONTENT */
- - if( value == TLE82353SA_ICVID_CONTENT ){
- + /* on error the chip responses with its "Reset Value" */
- + if(TLE82353SA_RESET_VALUE_OK(value)){
- bRet = false;
- }
- else{
- @@ -153,29 +154,42 @@ bool TLE82353SA::readRegister(int hdl, unsigned char adr, unsigned long &value)
- bool TLE82353SA::initTLE( int hdl, unsigned long clkDividervalue, bool includeClkDivider, bool resetDiagRegister )
- {
- -
- - bool bRet(false);
- - unsigned long registerValue(0);
- +
- + bool bRet;
- + unsigned long registerValue;
- /* try to read a register from the chip
- * Use the ICVID register here
- */
- + registerValue = 0UL;
- bRet = TLE82353SA::readRegister( hdl, REGISTER_ICVID, registerValue );
- - if( !bRet || registerValue != TLE82353SA_ICVID_CONTENT ){
- +(void)fprintf(stderr, "TLE82353SA::initTLE() try1, bRet=%d, registerValue=%lx\n",
- + (int)bRet, (unsigned long)registerValue);
- + if( !bRet || TLE82353SA_RESET_VALUE_OK(registerValue) ){
- //I2CFeature
- /* the chip did not respond, maybe its in reset state.
- * release the reset pin */
- PCA9505::getInst().setOutput(PCA9505::RESET_HS_PWM, true, true);
- +
- /* wait 3ms */
- //TODO: minimal granularity of system timers, CONFIG_HZ=200Hz => 5ms
- - usleep( 3000) ;
- + (void)usleep(3000) ;
- +
- /* try again reading register */
- + registerValue = 0UL;
- bRet = TLE82353SA::readRegister( hdl, REGISTER_ICVID, registerValue );
- - if( bRet && registerValue == TLE82353SA_ICVID_CONTENT ){
- +(void)fprintf(stderr, "TLE82353SA::initTLE() try2, bRet=%d, registerValue=%lx\n",
- + (int)bRet, (unsigned long)registerValue);
- +
- + if( bRet && TLE82353SA_RESET_VALUE_OK(registerValue) ){
- /* chip alive and responding! */
- bRet = true;
- }
- + else
- + {
- + bRet = false;
- + }
- }
- if( resetDiagRegister ){
- diff --git a/ptxdist/local_src/common/hw/tle82353sa.h b/ptxdist/local_src/common/hw/tle82353sa.h
- index db1e950..1c09f78 100644
- --- a/ptxdist/local_src/common/hw/tle82353sa.h
- +++ b/ptxdist/local_src/common/hw/tle82353sa.h
- @@ -49,7 +49,19 @@ TLE82353SA
- #define CHANNEL_LOAD1 0x01
- #define CHANNEL_LOAD2 0x02
- -#define TLE82353SA_ICVID_CONTENT 0x00C10400
- +/*
- + * TLE82453 Data Sheet (Rev 1.0, 2015-03-27) defines a "Reset Value" on
- + * page 53 as hex 00C1xx00) where "xx" is the version field.
- + * If you read the chip register use |TLE82353SA_IC_VERSION_MASK| to remove
- + * the IC version bit (15:8) contents from the value and then compare this
- + * to |TLE82353SA_MASKED_RESET_VALUE| to see whether the chip reset has been
- + * successful.
- + */
- +#define TLE82353SA_MASKED_RESET_VALUE 0x00C10000
- +#define TLE82353SA_IC_VERSION_MASK 0x0000FF00
- +#define TLE82353SA_RESET_VALUE_OK(regval) \
- + (((regval) & ~TLE82353SA_IC_VERSION_MASK) == TLE82353SA_MASKED_RESET_VALUE)
- +
- /* global registers */
- #define REGISTER_ICVID 0x00
MAARAUCH-53 patch #001
Posted by Anonymous on Thu 27th Sep 2018 10:29
raw | new post
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.