// ============================================================================ signed char fDetectHiLoTransition(void) { // nTimer breaks out of the while loops if the wait in the two loops totals // more than 100 msec. Making this static makes the loop run a faster. // This is really a processor/compiler dependency and it not needed. unsigned long int iTimer=0; // NOTE: // These loops look unconventional, but it is necessary to check SDATA_PIN // as shown because the transition can be missed otherwise, due to the // length of the SDATA Low-High-Low after certain commands. // Generate clocks for the target to pull SDATA High iTimer = TRANSITION_TIMEOUT; // gpio_tlmm_config(GPIO_CFG(TSP_SDA, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, // GPIO_CFG_2MA), GPIO_CFG_ENABLE); gpio_direction_input(TSP_SDA); while(1) { SCLKLow(); if (fSDATACheck()) // exit once SDATA goes HI { break; } SCLKHigh(); // If the wait is too long then timeout if (iTimer-- == 0) { printk(KERN_INFO "[TSP] %s, %d : Error\n", __func__, __LINE__); return (ERROR); } } // Generate Clocks and wait for Target to pull SDATA Low again iTimer = TRANSITION_TIMEOUT; // reset the timeout counter while(1) { SCLKLow(); if (!fSDATACheck()) // exit once SDATA returns LOW { break; } SCLKHigh(); // If the wait is too long then timeout if (iTimer-- == 0) { printk(KERN_INFO "[TSP] %s, %d : Error\n", __func__, __LINE__); return (ERROR); } } return (PASS); }
// ============================================================================ // fDetectHiLoTransition() // Waits for transition from SDATA = 1 to SDATA = 0. Has a 100 msec timeout. // TRANSITION_TIMEOUT is a loop counter for a 100msec timeout when waiting for // a high-to-low transition. This is used in the polling loop of // fDetectHiLoTransition(). The timing of the while(1) loops can be calculated // and the number of loops is counted, using iTimer, to determine when 100 // msec has passed. // //// SCLK cannot run faster than the specified maximum frequency of 8MHz. Some // processors may need to have delays added after setting SCLK low and setting // SCLK high in order to not exceed this specification. The maximum frequency // of SCLK should be measured as part of validation of the final program // // Returns: // 0 if successful // -1 if timed out. // ============================================================================ signed char fDetectHiLoTransition(void) { // nTimer breaks out of the while loops if the wait in the two loops totals // more than 100 msec. Making this static makes the loop run a faster. // This is really a processor/compiler dependency and it not needed. static unsigned int iTimer; // NOTE: // These loops look unconventional, but it is necessary to check SDATA_PIN // as shown because the transition can be missed otherwise, due to the // length of the SDATA Low-High-Low after certain commands. // Generate clocks for the target to pull SDATA High //dog_kick(); iTimer = TRANSITION_TIMEOUT; #if !defined(CONFIG_TARGET_LOCALE_NAATT) printk(KERN_DEBUG "Generate clocks for the target to pull SDATA High\n"); #endif while (1) { SCLKLow(); if (fSDATACheck()) // exit once SDATA goes HI break; SCLKHigh(); // If the wait is too long then timeout if (iTimer-- == 0) { return (ERROR); } } //dog_kick(); // Generate Clocks and wait for Target to pull SDATA Low again iTimer = TRANSITION_TIMEOUT; // reset the timeout counter #if !defined(CONFIG_TARGET_LOCALE_NAATT) printk(KERN_DEBUG "Generate Clocks and wait for Target to pull SDATA Low again\n"); #endif while (1) { SCLKLow(); //issp_test_20100709 unblock if (!fSDATACheck()) { // exit once SDATA returns LOW break; } SCLKHigh(); //issp_test_20100709 unblock // If the wait is too long then timeout if (iTimer-- == 0) { return (ERROR); } } #if !defined(CONFIG_TARGET_LOCALE_NAATT) printk(KERN_ERR"fDetectHiLoTransition OUT!!!!\n"); #endif return (PASS); }
/* ============================================================================ fDetectHiLoTransition() Waits for transition from SDATA = 1 to SDATA = 0. Has a 100 msec timeout. TRANSITION_TIMEOUT is a loop counter for a 100msec timeout when waiting for a high-to-low transition. This is used in the polling loop of fDetectHiLoTransition(). The timing of the while(1) loops can be calculated and the number of loops is counted, using iTimer, to determine when 100 msec has passed. SCLK cannot run faster than the specified maximum frequency of 8MHz. Some processors may need to have delays added after setting SCLK low and setting SCLK high in order to not exceed this specification. The maximum frequency of SCLK should be measured as part of validation of the final program Returns: 0 if successful -1 if timed out. ============================================================================ */ signed char fDetectHiLoTransition(void) { /* nTimer breaks out of the while loops if the wait in the two loops totals more than 100 msec. Making this static makes the loop run a faster. This is really a processor/compiler dependency and it not needed. */ unsigned long int iTimer = 0; /* NOTE: These loops look unconventional, but it is necessary to check SDATA_PIN as shown because the transition can be missed otherwise, due to the length of the SDATA Low-High-Low after certain commands. Generate clocks for the target to pull SDATA High */ iTimer = TRANSITION_TIMEOUT; SetSCLKStrong(); while (1) { SCLKLow(); /* Delay(CLK_DELAY); */ if (fSDATACheck()) /* exit once SDATA goes HI */ break; SCLKHigh(); /*Delay(CLK_DELAY);*/ /*If the wait is too long then timeout*/ if (iTimer-- == 0){ printk(KERN_ERR "%s: %d - error\n", __func__, __LINE__); return ERROR; } } /* Generate Clocks and wait for Target to pull SDATA Low again */ iTimer = TRANSITION_TIMEOUT; while (1) { SCLKLow(); /* Delay(CLK_DELAY); */ if (!fSDATACheck()) /* exit once SDATA returns LOW */ break; /*SCLKHigh();*/ /* Delay(CLK_DELAY); */ /* If the wait is too long then timeout */ if (iTimer-- == 0){ printk(KERN_ERR "%s: %d - error\n", __func__, __LINE__); return ERROR; } } return PASS; }
/*============================================================================ bReceiveBit() Clocks the SCLK pin (high-low-high) and reads the status of the SDATA pin after the rising edge. SCLK cannot run faster than the specified maximum frequency of 8MHz. Some processors may need to have delays added after setting SCLK low and setting SCLK high in order to not exceed this specification. The maximum frequency of SCLK should be measured as part of validation of the final program Returns: 0 if SDATA was low 1 if SDATA was high ============================================================================ */ unsigned char bReceiveBit(void) { SCLKLow(); SCLKHigh(); if (fSDATACheck()) return 1; else return 0; }
// ============================================================================ // bReceiveBit() // Clocks the SCLK pin (high-low-high) and reads the status of the SDATA pin // after the rising edge. // // SCLK cannot run faster than the specified maximum frequency of 8MHz. Some // processors may need to have delays added after setting SCLK low and setting // SCLK high in order to not exceed this specification. The maximum frequency // of SCLK should be measured as part of validation of the final program // // Returns: // 0 if SDATA was low // 1 if SDATA was high // ============================================================================ unsigned char bReceiveBit(void) { SCLKLow(); SCLKHigh(); if (fSDATACheck()) { return (1); } else { return (0); } }
// ============================================================================ // fDetectHiLoTransition() // Waits for transition from SDATA = 1 to SDATA = 0. Has a 100 msec timeout. // TRANSITION_TIMEOUT is a loop counter for a 100msec timeout when waiting for // a high-to-low transition. This is used in the polling loop of // fDetectHiLoTransition(). The timing of the while(1) loops can be calculated // and the number of loops is counted, using iTimer, to determine when 100 // msec has passed. // // SCLK cannot run faster than the specified maximum frequency of 8MHz. Some // processors may need to have delays added after setting SCLK low and setting // SCLK high in order to not exceed this specification. The maximum frequency // of SCLK should be measured as part of validation of the final program // // Returns: // 0 if successful // -1 if timed out. // ============================================================================ signed char fDetectHiLoTransition(void) { // nTimer breaks out of the while loops if the wait in the two loops totals // more than 100 msec. Making this static makes the loop run a faster. // This is really a processor/compiler dependency and it not needed. unsigned long int iTimer=0; // NOTE: // These loops look unconventional, but it is necessary to check SDATA_PIN // as shown because the transition can be missed otherwise, due to the // length of the SDATA Low-High-Low after certain commands. // Generate clocks for the target to pull SDATA High iTimer = TRANSITION_TIMEOUT; while(1) { SCLKLow(); if (fSDATACheck()) // exit once SDATA goes HI break; SCLKHigh(); // If the wait is too long then timeout if (iTimer-- == 0) { return (ERROR); } } // Generate Clocks and wait for Target to pull SDATA Low again iTimer = TRANSITION_TIMEOUT; // reset the timeout counter while(1) { SCLKLow(); if (!fSDATACheck()) { // exit once SDATA returns LOW break; } SCLKHigh(); // If the wait is too long then timeout if (iTimer-- == 0) { return (ERROR); } } return (PASS); }
/* ============================================================================ // fDetectHiLoTransition() // Waits for transition from SDATA = 1 to SDATA = 0. Has a 100 msec timeout. // TRANSITION_TIMEOUT is a loop counter for a 100msec timeout when waiting for // a high-to-low transition. This is used in the polling loop of // fDetectHiLoTransition(). The timing of the while(1) loops can be calculated // and the number of loops is counted, using iTimer, to determine when 100 // msec has passed. // // SCLK cannot run faster than the specified maximum frequency of 8MHz. Some // processors may need to have delays added after setting SCLK low and setting // SCLK high in order to not exceed this specification. The maximum frequency // of SCLK should be measured as part of validation of the final program // // Returns: // 0 if successful // -1 if timed out. ============================================================================*/ signed char fDetectHiLoTransition(void) { /* nTimer breaks out of the while loops if the wait in the two loops totals // more than 100 msec. Making this static makes the loop run a faster. // This is really a processor/compiler dependency and it not needed. */ static unsigned int iTimer; /* NOTE: // These loops look unconventional, but it is necessary to check SDATA_PIN // as shown because the transition can be missed otherwise, due to the // length of the SDATA Low-High-Low after certain commands. */ /* Generate clocks for the target to pull SDATA High */ iTimer = 40000; /*TRANSITION_TIMEOUT; */ while (1) { int ret; SCLKLow(); ret = fSDATACheck(); if (ret) /* exit once SDATA goes HI */ break; SCLKHigh(); /* If the wait is too long then timeout */ if (iTimer-- == 0) return ERROR; } /* Generate Clocks and wait for Target to pull SDATA Low again */ #if 0 /* wly */ iTimer = 40000;/* TRANSITION_TIMEOUT; */ while (1) { int ret; SCLKLow(); ret = fSDATACheck(); /* pr_info("wly while 2, ret=%d\n", ret); */ if (!ret) { /* exit once SDATA returns LOW */ break; } /* SCLKHigh(); // If the wait is too long then timeout */ if (iTimer-- == 0) { #ifdef USE_TP SetTPHigh(); /* Only used of Test Points are enabled */ #endif return ERROR; } } #else SCLKHigh(); SetSDATALow(); SCLKLow(); if (!fSDATACheck()) /* exit once SDATA returns LOW */ SetSDATAHiZ(); mdelay(20); #endif #ifdef USE_TP SetTPHigh(); /* Only used of Test Points are enabled */ #endif return PASS; }