-
Notifications
You must be signed in to change notification settings - Fork 3k
Fix NXP LPCxxxx i2c_start() handling of repeated start #1776
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
In repeating start scenarios, there was a bug in the I2C driver for various NXP LPCxxxx parts which could allow an extra I/O from the previous operation to leak through. The scenario I encountered which triggered this bug went like so: * The higher level application code would first do an I2C write that doesn't send a stop bit (use repeating start instead.) * The higher level application code would then issues an I2C read operation which begin with a call to i2c_start(). * i2c_start() would clear the SI bit (interrupt flag) at the top of its implementation. * i2C_start() would then get interrupted right after clearing the SI bit. * While the CPU is off running the ISR code, the I2C peripheral repeats the last byte written to I2CDAT and then sets the SI bit to indicate that the write has completed. * The ISR returns to allow the i2c_start() to continue execution. * i2c_start() would then set the STA bit but it is too late. * i2c_start() waits for the SI bit to be set but it is already set because of the completed byte write and not because of the repeated start as expected. For me this bug would cause strange interactions between my ISRs and the code using I2C to read from the MPU-6050 IMU. I would be getting valid orientation data and then all of a sudden I would start receiving what looked like random values but I think it was just reading from the incorrect offset in the device's FIFO. It appears that atleast one other person has seen this before but it was never root caused since it required specific timing to reproduce: https://developer.mbed.org/forum/bugs-suggestions/topic/4254/ This bug can be found in most of the NXP I2C drivers and this commit contains a fix for them all. I however only have the LPC1768 and LPC11U24 for testing. My fix does the following: * No longer clears the SI bit in the i2c_conclr() call near the beginning of the i2c_start() function. It was this clear that previously caused the problem as described above. * The second part of the fix was to instead clear the SI bit after the STA (start) bit has been set with the i2c_conset() call. * The clearing of the SI bit should be skipped if there isn't an active interrupt when first entering i2c_start(). If you clear the SI bit when there isn't an active interrupt then the code is likely to skip over the interrupt for the start bit which was just sent and then allow the I2C peripheral to start sending the slave address before it has even been loaded into the I2CDAT register.
@0xc0170 I don't recall contributing to the NXP I2C implementations so I can't help you there, but I believe I've encountered the bug @adamgreen is referring to. |
@0xc0170 I will have a look. |
I only tested this with LPC1768 target and the following test cases are failed.
[ 19] MBED_A19: I2C EEPROM read/write test
[ 25] MBED_A25: I2C EEPROM line read/write test
[ 13] MBED_A13: I2C MMA7660 accelerometer
Does this PR require to change whole existing application/test code? |
Thanks for looking at it. It should have required no changes to existing code. It looks like the repeated start is failing for those test cases...the thing I was actually trying to fix by removing a timing hole that would sometimes cause it to fail. It must be a bug introduced by my change since the only thing I could think of that would cause that problem if not my code is that the wrong I2C device was connected to the p28/p27 pins. If there were missing pull-ups or no I2C device there at all, different errors would be generated. I guess I will have to order an I2C EEPROM to repro locally so that I can see what is going on under the debugger. It's strange that I would have broken repeated start for the EEPROM and accelerometer as I did test the change with the MPU-6050 IMU and it worked on that device. |
I didn't fully apply your patch in my test last time. I picked some of them, but not all. Sorry my bad. |
@toyowata As long as you pulled the whole change for hal/targets/hal/TARGET_NXP/TARGET_LPC176X/i2c_api.c from this PR then that should have been enough to test on the LPC1768. Just pulling part of the changes to that file would likely cause problems. I have ordered the EEPROM so that I can reproduce the problem here locally. I suspect it will arrive by the end of the week. |
Last time, I only picked a part of code by manually and it was a problem. Sorry my bad.
I could not find any problem of this PR. BTW, there are some missing targets such as LPC812, LPC824 and LPC1549. Didn't find any issue on these platforms? |
@toyowata Thanks for rerunning the tests. I appreciate it.
I haven't read the user manuals for those parts but from what I see in the code, their I2C peripherals are different and their drivers don't share code or this particular bug. |
OK. Thank you very much for your answer. |
…..4a188ea 4a188ea Merge branch 'release_internal' into release_external 27ba18e removed ws resources from nanostack. b693eae Merge pull request ARMmbed#1778 from ARMmbed/ws_bbr_update 543dd1e Renamed symbol to micro seconds. ab5d98a Added ND proxy support to ws border router f7c71c0 Remove new unittests from release external. ac55c15 Merge branch 'release_internal' into release_external f9b9e47 Fix GCC_ARM/ARM compiler warnings (ARMmbed#1777) 40efd39 Coverity tool reported error fix (ARMmbed#1776) b063457 Merge pull request ARMmbed#1775 from ARMmbed/mac_header_trace_fix b1fd538 Removed Debug trace support from common mac header class 90a36a6 coverity reported error fixes. (ARMmbed#1770) 9644114 Merge pull request ARMmbed#1774 from ARMmbed/debug_trace_fix 1e490f0 Removed debug trace which could be called at interrupt routine 1373a5f Clarify parameter name in phy_csma_params_t (ARMmbed#1773) 4a32a6c fixes for coverity tool reported issues. (ARMmbed#1772) 545d262 Update copyright year (ARMmbed#1771) 5ae07da address error handling fix. (ARMmbed#1769) 13c1ceb Clean multicast address when interface is shutdown 88bb7cc correct interface passed to address compare. (ARMmbed#1768) 53949a4 Thread device registers new address upon receipt of error notification. (ARMmbed#1767) 1653b06 replace ETX calculation for Wi-SUN 745c1dd refactor RPL dis sending 6e1cc58 Merge pull request ARMmbed#1764 from ARMmbed/mle_purge_fix 0b920d8 Fixed broken neighbor purge from list a6f3a0d Thread network data handling refactored (ARMmbed#1762) 87cc2c9 Merge pull request ARMmbed#1763 from ARMmbed/mle_fixs 944f9ca Fix broken MLE neigbor list write operation. 833e740 updated address error payload (ARMmbed#1761) 2565170 Add CBOR parsing to simpleenrolment message e38c70f fix duplicate address detection (ARMmbed#1760) 7648c1c Scope updated to three and prefix added to destination address. (ARMmbed#1758) 5612e08 DUA.ntf updates (ARMmbed#1752) 708bb3b pbbr stop removed to fix failing tests. (ARMmbed#1757) 1444c2f Add POC code for storing multicast address 684efef Fix MLR message handling b691b78 context id update (ARMmbed#1753) 5635089 fix key sequence issues when keys are rotated 74db027 fix for sleepy node poll. (ARMmbed#1750) 49adf2e Link entry for neighbour (ARMmbed#1749) 5bad8ee Correct MAC neighbour table sizes for Thread (ARMmbed#1748) 3858eb0 valgrind reported error: fixed uninitialised variables. (ARMmbed#1747) 24ef520 Update licenses in new WS files (ARMmbed#1745) 77dccdf valgrind tool reported error fix: (ARMmbed#1746) 9ac47a8 Adjust WS build configurations (ARMmbed#1744) c593e2b DUA.ntf to MTD child implemented (ARMmbed#1735) 3f5c6c1 Update missing SPDX identifiers to test files (ARMmbed#1743) 130fec4 Fix GCC_ARM linker error with some Thread builds (ARMmbed#1742) 65574a4 Merge pull request ARMmbed#1741 from ARMmbed/merge_koli_to_master 2dc41c0 Merge remote-tracking branch 'origin/koli' 2fc10b5 Put smarter dag max rank increment 2048. 0 affect a lot of troubles. d311040 RPL print update, nud and aneighbour update f9b23d4 Fix compiler warnings (ARMmbed#1740) 5a1f295 Merge pull request ARMmbed#1738 from ARMmbed/master_merge_to_koli abee481 Fix merge compile problems 2c77c37 Merge branch 'master' into koli 32fe4b8 Increase too small maximum root path length (ARMmbed#1737) 03bc696 Fix LLC unit test's 3702f57 LLC data indication and fhss channel set update 45905fa Update DHCP service memory allocation (ARMmbed#1734) 9c9b9e3 Fix crash which will happen if address registration fail and operation is triggered again by NULL pointer. cb83216 Enabled proper wi-sun security level 6. 7990fa9 Fix data for 6lowpan when mle is disabled. 501a612 Wi-sun trigle timer update: 47619c4 Function name code conventions fix. 1350bc5 mac_neighbor_info() macro defned for simplify code 41b84e4 Added check when weighting rule update must do network scan. 0215058 Fix ns_dyn_mem_init stub 33398ef Added Neighbor connected and trusted state update for wisun 24aa802 Integrate Mac neighbour table to Thread and 6Lowpan code 37c6342 Mac neighbour table update 7bb978e Thread Neighbor class update 26dd252 Removed almost duplicate mle entry discover for ll64 7a0aaa5 Rename some parameters which will help integration to new neighbor table. 3f905a1 Update nsdynmemLIB unit test stub (ARMmbed#1730) 2bd3e91 Return 0 instead of -1 on null pointer (ARMmbed#1728) fde5104 Function parameter and name refactor. e0f7dcf Updates to thread extension bootstrap (ARMmbed#1714) 13b3b05 Thread Neighbor and MLE API update 49ccb9d Removed threadNeighbour flag from mle_table_entry_t. e142eec Removed unused holdTime parameter from mle_table_entry. c8a99cb MLE service Update and integrate new features 726b08b Adjust NULL string tracing (ARMmbed#1726) 66636b8 Merge pull request ARMmbed#1724 from ARMmbed/IOTTHD-2537 2710836 Enable security to wi-sun with test security key. 8994bb2 MAC Security update c56886f MAC: Fixed frame length when calling FHSS TX conditions 4eb5567 CCM & AES update for support multiple user and context. 7544ef3 added response to confirmable unicast. (ARMmbed#1722) a8a5a90 duplicate address detection fix (ARMmbed#1720) 721c0b0 MLE service releases CCM library in error case (ARMmbed#1719) d0467a0 Fix stack overflow (ARMmbed#1718) 7ea9001 Added support for multiple registrations in one message 0a36af3 WS IE library update and LLC data confirmation update 4352709 MAC enhanced ACK RX and TX support 0b7f9fe Update Thread child id request timeout handling (ARMmbed#1715) 3e8df0a added neighbor advertisement sending after dad complete. (ARMmbed#1713) a46a363 updated multicast address registration timer (ARMmbed#1711) 7c6c482 Added target EID tlv to Dua response 2d3aff9 Delete parent mle-entry in case of parent lost or updated (ARMmbed#1707) b43db5f duplicate address handling (ARMmbed#1709) cb54705 Address generation changed to slaac based generation (ARMmbed#1708) ee0306b changed coap message type to non-confirmable. (ARMmbed#1706) 776e0e5 Merge pull request ARMmbed#1705 from ARMmbed/IOTTHD-2531 d92b2f9 Thread advertisement adjustment (ARMmbed#1703) f8d3d67 WS: Learn parent unicast dwell time bd88fa0 WS Lib: Fixed byte order of fixed channel 1f9162d Merge pull request ARMmbed#1704 from ARMmbed/IOTTHD-2484 2e15944 FHSS unit tests: Datarate storage removed e64bd19 FHSS: Implemented checking TX time 0ba4b9a Merge pull request ARMmbed#1700 from ARMmbed/IOTTHD-2483 1adb52b coap message type decided based on destination (ARMmbed#1702) d1cf42d multicast handling updated(ARMmbed#1701) 44110a1 Thread bootstrap improvements (ARMmbed#1699) 34c0df9 FHSS unit tests: fixed tests after TX slot update ddd7e92 FHSS: Calculate number of TX slots using defined slot length eaf35d2 Lowered Thread advertisement speedup threshold values (ARMmbed#1691) b67f2d8 Reset children when no response from parent (ARMmbed#1698) 3569c8a Mleid bbr fix (ARMmbed#1697) 1fc81fc Thread device learns weighting from advertisement (ARMmbed#1696) ba98835 Merge pull request ARMmbed#1689 from ARMmbed/IOTTHD-2475 28307de Randomize channel used in fixed channel 3412f4a WS bootstrap: Moved calculating and setting FHSS hop to own function 51a498b reset Dodag if global address is lost. c0e8cae Merge branch 'koli' into IOTTHD-2475 0ec37a6 Count the amount of configuration solicits c8f5c8d FHSS unit tests: Updated FHSS config tests. 490384f FHSS unit tests: Test TX/RX slots 4fdbc09 FHSS: Calculate hop count using RPL rank 8f194f8 FHSS: Implemented TX slot calculation b06b58a FHSS: Implemented setting hop count API d73d210 FHSS: Moved own hop to common FHSS structure caafff0 FHSS: Check TX slot for unicast frames 7406149 Merge pull request ARMmbed#1684 from ARMmbed/IOTTHD-2476 cc5f6d8 FHSS: validate received synch info. c48f0ef Merge pull request ARMmbed#1687 from ARMmbed/disable_channel_traces d5d1a13 Fixed trickle configuration for Discovery eef3bd7 FHSS: Disable FHSS channel debugs for WS fc74a31 Fixed unit test for support extensions. e803974 FHSS and Mac extension enable update. 4859f16 MAC RF extension enable e73e9b2 Merge pull request ARMmbed#1682 from ARMmbed/IOTTHD-2460 03f7105 fixed EAPOL parent selection cbdd2a9 Fixed set channel unit test ce1ab34 FHSS: Do not change channel during asynch transmissions c0456a3 Defined own structure to give CSMA backoff symbol time and cca mode. dff1e7d Merge pull request ARMmbed#1677 from ARMmbed/merge_MtoK 34dcbb6 Merge pull request ARMmbed#1674 from ARMmbed/IOTTHD-2443 3f9b34d Merge branch 'master' into koli f578c26 Updated border router configuration 1ce2385 RF PHY extension update 32db0cd FHSS: Learn FHSS configuration from parent PA config 5974344 Merge pull request ARMmbed#1670 from ARMmbed/IOTTHD-2449 82a8bca FHSS: support FHSS created by application 67f578a Calculated RSL from neighbours 4aa6890 Merge pull request ARMmbed#1664 from ARMmbed/IOTTHD-2442 65e2fad Fixed uninitialized parameter use at rpl instance allocate. 4767dd5 Merge pull request ARMmbed#1666 from ARMmbed/fhss_is_bc_flag_fix 6ffc81a FHSS unit tests: Fixed tests 14e1597 Fixed missing TX ime calculation for pre-builded MAC packet send. 03f447a FHSS: Do not use broadcast queue when fixed channel 40f3685 FHSS: do not push asynch messages in broadcast queue 45daec9 FHSS: FHSS is on BC channel by default 2dbc92c FHSS: Remove failed handle after successful transmission a152f45 Merge branch 'koli' into IOTTHD-2442 ea583c6 FHSS: Fixed updating broadcast synch c3aa7d1 Select correct parent based on network size and route cost 7bf3994 Fixed Code style warning. 2e1f32f Fixed WS_NESTED_IE information discover return length check. 445745a LLC Neighbor, Mac packet rebuild, mac timer update and phy Extension. 6cb78ff Distribute and learn network size bc4f46f Merge pull request ARMmbed#1656 from ARMmbed/IOTTHD-2441 7f94971 FHSS: Added random timeout before polling TX queue after channel change b6e40af Merge pull request ARMmbed#1653 from ARMmbed/IOTTHD-2366 b28fcaa FHSS unit tests: Test failed TX allocation fbe7795 Modified neighbour processing b2cff91 FHSS: Use channel retries with WS 9b11201 FHSS: Moved TX fail handler in FHSS common 9fff108 Merge pull request ARMmbed#1650 from ARMmbed/merge_MtoK2 04797c2 Detect border router connection lost 5227398 Merge branch 'master' into koli c0e8673 Merge pull request ARMmbed#1647 from ARMmbed/IOTTHD-2405 b7428e0 Merge pull request ARMmbed#1646 from ARMmbed/IOTTHD-2404 04449e8 FHSS unit tests: Test tx conditions and tx done callbacks baaec35 Merge pull request ARMmbed#1644 from ARMmbed/ws_start_bc 69c1483 FHSS: Added excluded channels in neighbor table 92acbd2 WS: fixed merge conflicts 4e01969 Merge branch 'koli' into ws_start_bc 97200b3 Added version number increase in border router 27c8b65 FHSS: unit test update 6eb1255 FHSS: WS bootstrap to start broadcast schedule 659a1c4 FHSS: Write BT-IE 64f31b1 Merge pull request ARMmbed#1635 from ARMmbed/IOTTHD-2217 7706f2e FHSS: Do not return to RX channel when configured fixed channel 908eb17 Change RPL dis destination address to RPL address 666dbbf FHSS: Start broadcast schedule only if device is border router 98f9991 FHSS: Set neighbor info get function 126275b Merge pull request ARMmbed#1632 from ARMmbed/IOTTHD-2402 7fa2c2b WS: Learn channel function from parent 3980870 WS: Enable FHSS in bootstrap ff72d95 Merge pull request ARMmbed#1629 from ARMmbed/cppcheck_fixes 85f1345 MAC: Check length pointer in ie vector length validate 672c4ef FHSS: Removed unnecessary fhss_api NULL e5637fd FHSS: Initialize next_channel in broadcast channel calculation cab9849 Send address registration to all PC parents (ARMmbed#1618) 5417936 Merge pull request ARMmbed#1623 from ARMmbed/mergeMtoK3 ad41972 Wait RPL to be ready before bootstrap is ready a314db0 Merge branch 'master' into koli f6ac06f Fhss ut improvements (ARMmbed#1622) 60a3b0f Fixed ETX update at LLC layer. bb152ce Merge pull request ARMmbed#1617 from ARMmbed/IOTTHD-2321 49c213a FHSS unit tests: Added more tx handle tests d5cc85a FHSS unit tests: Test removing parent info and get neighbor info 2d01008 FHSS unit tests: test setting parent BC info 681dedd Merge pull request ARMmbed#1613 from ARMmbed/IOTTHD-2320 7e59035 Fix broken unit test build. 6be455f WS ETX update 0efc062 ETX service update e5aba03 WS PAN advert validation update 802ce3e WS bootstrap update be296cd WS IE lib update cfa5fd9 FHSS: Store parent broadcast info pointer d0171be FHSS: Implemented get neighbor info and set/remove parent info callbacks 686ad9c Fix acynch --> asynch b4059b8 WS neighbor class integrated to use new FHSS structures c1b0d96 Merge pull request ARMmbed#1610 from ARMmbed/IOTTHD-2313 3d98860 FHSS: Implemented WS timing/schedule info structure f96db0c Merge pull request ARMmbed#1607 from ARMmbed/merge_MtoK 72bb71f Fixed missing params after merging master to koli d119df9 Merge branch 'master' into koli 8166585 Merge pull request ARMmbed#1602 from ARMmbed/IOTTHD-2311 90fbb45 Fixed LLC data unit test and add new functions to test 94e516f Integrated new WS IE header and payload API's c553e8c WS ie library read update 7db0938 fixed mac_mlme valgrind errors. 4e2a743 Fixed thread test some of. 2680dd6 Fixed unstable unit test verified by valgrind. 18eda56 Merge pull request ARMmbed#1605 from ARMmbed/fhss_ut_valgrind_fix eb96eae FHSS unit tests: fixed uninitialized varnings 27b7864 Fixed mac helper stub issues. a88590f FHSS unit tests: Test tr51cf with excluded channels 3c9356a FHSS unit tests: Updated channel function tests 3a562d3 FHSS: Added excluded channels in channel function interface b9606c9 FHSS: Static channel functions added 695e64c Merge pull request ARMmbed#1601 from ARMmbed/IOTTHD-2214 f973986 FHSS unit tests: Implemented FHSS common unit tests 2188af4 FHSS unit tests: Removed FHSS common functions from FHSS e6bac6a Rename and refactor structures and function names. b037628 Fixed unit test and stubs 8153fe3 Fixed Asynch request missing msdu_handle set at LLC. 1af46d8 WS bootstrap update c771df0 LLC update UTT / BT information to ws neighbor and refresh mac neighbor a43f6ad Mac helper API update: 14792db Ws neighbor hoping storage init integrated to interface init. ae7945d Wi-sun neighbor hopping infor storage API definition 8f5c0bf FHSS: Removed fhss_beacon, fhss_beacon_tasklet and fhss_mac_interface 1e94358 Fixed unitest build. 3b9a4b0 Base Integration for Mac neighbor table to WS 7729e20 Mac neighbor table integrate to interface structure 2c6f30a Addede NULL check some of mac neighbor table check. ed45fda Mac neighbor table unit test's. 0f85841 Added mac_neighbor_table stub's fc4c97b Generic mesh neighbor table class. 4b81978 Process advertisement solicit and process response (ARMmbed#1592) 73c6bc1 Merge pull request ARMmbed#1589 from ARMmbed/IOTTHD-2218 057b6ec Omit NA sending in ARO success cases. Use ACK instead. (ARMmbed#1587) 4686668 ws_management_api unit tests (ARMmbed#1591) 9ae6511 FHSS unit tests: Implemented FHSS WS tests 8147217 Added trickle for Advertisement and processing of response (ARMmbed#1586) c52b039 Merge pull request ARMmbed#1584 from ARMmbed/IOTTHD-2055 ac58048 FHSS: WS FHSS to use pre-set TX time feeee0f FHSS: Synch callback to write ufsi 3e8112b Merge pull request ARMmbed#1578 from ARMmbed/IOTTHD-2286 4cd6c49 Merge pull request ARMmbed#1579 from ARMmbed/fhss_bug_fix 296a2f1 FHSS: Fixed scramble table bug 80e4270 FHSS: Added vendor defined CF support 24f418c Merge pull request ARMmbed#1575 from ARMmbed/IOTTHD-2288 a849c8d FHSS unit tests: Update FHSS tests 83bd90e FHSS: fhss_struct defined static 04ae3c3 FHSS: separated is_bc_callback to FHSS and WS 59fe586 FHSS: removed allocation of scramble table 1ca1d0b FHSS: Continued fhss_structure cleaning 036e19c Api Updates to LLC, ws_ie_lib and ws_info 192007b Fixed MAC Asynch message send and header build bug. e0494b7 WS address registration callback for SLAAC (ARMmbed#1568) 93b7e32 FHSS: superframe handlers separated ff66ae9 FHSS: Separate FHSS and WS parameters - Configuration structs moved 6ace69b Merge pull request ARMmbed#1573 from ARMmbed/fhss_cleaning1 07d4089 FHSS: Cleaning. Static functions. Separated tx fail and retry callbacks 8b9d39b Merge pull request ARMmbed#1571 from ARMmbed/fhss_callback_update 316b007 FHSS: removed unnecessary state set handler db1ded0 WS LLC data service enabled to WS bootstrap. c326e4a Fixed MPX header size calculation to MPX data request. fa2d7d0 Removed Adaptation interface depency from LLC away. 4356ae8 separated BBR to own file (ARMmbed#1567) 75d93f8 Merge pull request ARMmbed#1564 from ARMmbed/IOTTHD-2213 19c4be6 FHSS: Separated tx done cb for FHSS and WS 3e326d1 FHSS: separated synch info write for FHSS and WS 15d4465 Function and parameter rename. 5af7992 Unit test for llc data service. ffb3639 Fixed stubs. 3f66f6a LLC delete added for test purpose b48cda0 Impelement LLC reset 47458c8 WS IE Lib unit test and fixed mac ie lib stub 6b6e509 MPX header module unit test. 55309e8 ws_llc_asynch_request() API update 5d9a379 Wisun spesific IE elemts write operation library. c718985 FHSS: Calculate destination slot and ufsi b4e1616 Merge pull request ARMmbed#1561 from ARMmbed/IOTTHD-2172 096aeef ws create interface and start rpl for poc (ARMmbed#1562) 77c851a FHSS: Added BSI in ws configuration 7d4a2f8 FHSS: Start broadcast schedule when bc intervals are known e55ec8a FHSS: Prevent changing unicast channel when broadcast is active b60b113 FHSS: Broadcast handler implemented 9bf1d1f WS Bootstrap skeleton (ARMmbed#1559) 3fb6390 Merge pull request ARMmbed#1560 from ARMmbed/mergeMtoK2 b78a370 Merge branch 'master' into koli 8b43c6e Merge pull request ARMmbed#1555 from ARMmbed/IOTTHD-2215 78314e8 FHSS: WS FHSS enable implemented d04b818 FHSS: Compensation callback to return timeout value 472becb FHSS: FHSS configuration to union b5f9e01 FHSS unit tests: Fixed after FHSS enable/down updates 2cbe6dc FHSS: Moved FHSS reset and down to FHSS module 4719187 FHSS: Separated FHSS enable functions for FHSS and WS FHSS f4548d8 FHSS: Implemented WS configuration structure 7ace04b Initial commit for ws_bootstrap (ARMmbed#1556) 9e46cf9 Added malformed message check to nested IE discovery. 7f4c184 Added support for write and discover Nested IE elements. e3d8150 SW MAC Asynch data request support 9a98177 Merge pull request ARMmbed#1552 from ARMmbed/cf_update 30075dd FHSS: TR51 channel function updated (bug in the spec?) 6b04d5a Merge pull request ARMmbed#1548 from ARMmbed/IOTTHD-2093 4249fad Integrated ws llc and mpx features. a49bf11 Fix Const pointer wrong use. 3e1972f WS LLC module implementation base 957f270 MPX frame support 93f0ed7 MAC ie library update: b2198b3 MPX support Integrate 2531c49 WS LLC and MAC MPX API definition and IE types definition. a5493d2 FHSS: Do not send TX failure if TX in progress in channel change 958991a FHSS: Few FHSS functions to static 7237796 Merge pull request ARMmbed#1545 from ARMmbed/IOTTHD-2097 f794990 FHSS: Implemented destination channel change in TX handle callback d2957a1 FHSS: fhss tx conditions callbacks added c1e7300 FHSS: hard coded channel function 1d54c7d FHSS: fhss tx handle callbacks added 0cc1889 FHSS: Moved external API set to fhss and fhss_ws c6cfb6c Merge pull request ARMmbed#1544 from ARMmbed/fhss_headers_refactored 1b4e203 FHSS: refactoring FHSS header files e047723 Merge pull request ARMmbed#1541 from ARMmbed/IOTTHD-2171 5d98e3e FHSS: Added support for TR51 channel function c8a9c7c FHSS: function to calculate nearest (larger or equal) prime number 5e70ec1 FHSS: ws struct to hold ws specific parameters f2d7558 FHSS unit tests: Fixed tests 149f17b FHSS: Own create api for WS e19de33 FHSS: WS to use Direct Hash channel function fb99776 FHSS: Some cleaning 7a21ca1 FHSS: Added common superframe handler a881580 FHSS: Added ws handler for FHSS state set f7ab36c FHSS: Created FHSS state set handler f6c61fc Added Copyrights c445590 MAC IE element library 6e94b08 MCPS-Data-REQ API update 38aedc5 Remove commented code away. 663fd3e Fixed missing doxygen tags. b9f7bf4 MAC functional updates and fix's: 2cef8ac Merge pull request ARMmbed#1538 from ARMmbed/mergeMtoK 321f700 Merge pull request ARMmbed#1534 from ARMmbed/IOTTHD-2047 146d7c4 Merge branch 'master' into koli 100db21 FHSS unit test: Added FHSS common to unit test makefile 37425ca FHSS: Separated common FHSS functions to own module 59b7b76 FHSS: Removed massive trace flags 60dfccb FHSS: Removed unnecessary channel functions e456662 FHSS: Removed scramble table generation from fhss enable b643622 Merge pull request ARMmbed#1532 from ARMmbed/IOTTHD-2049 b741f98 MCPS Data request API update. c329f61 MAC API update and internal update 55861f3 FHSS unit tests: Fixed tests after API change f9a31e9 FHSS API: Added callback to read synch info f94b2ab FHSS: FHSS to use synch info callback 6830fd3 FHSS API: Added synch info write callback ad5a1e1 Merge pull request ARMmbed#1527 from ARMmbed/IOTTHD-2095 3ed145f FHSS API: Added new configurations 0f9f0bb FHSS: Platform API to support multiple simultaneous timeouts bf65e9c Unit tests: Added PHY extension stub 322167e MAC: RX time get function implemented 23d3a58 MAC: Created a function to set TX time 2384c33 PHY API: extension to support timestamp 209e49a Merge pull request ARMmbed#1528 from ARMmbed/IOTTHD-2046 89a85a8 FHSS: Added copyright headers, comments etc. 5d0f44e Unit tests: DH1CF channel function tests implemented fbd5568 FHSS: DH1CF channel functions implemented cf03db2 FHSS: Implemented tr51 channel functions 00af7f1 Unit tests: Created channel function unit tests git-subtree-dir: features/nanostack/sal-stack-nanostack git-subtree-split: 4a188ea
In repeating start scenarios, there was a bug in the I2C driver for
various NXP LPCxxxx parts which could allow an extra I/O from the
previous operation to leak through. The scenario I encountered which
triggered this bug went like so:
doesn't send a stop bit (use repeating start instead.)
operation which begins with a call to i2c_start().
its implementation.
bit.
repeats the last byte written to I2CDAT and then sets the SI bit to
indicate that the write has completed.
because of the completed byte write and not because of the repeated
start as expected.
For me this bug would cause strange interactions between my ISRs and
the code using I2C to read from the MPU-6050 IMU. I would be getting
valid orientation data and then all of a sudden I would start receiving
what looked like random values but I think it was just reading from the
incorrect offset in the device's FIFO.
It appears that atleast one other person has seen this before but it
was never root caused since it required specific timing to reproduce:
https://developer.mbed.org/forum/bugs-suggestions/topic/4254/
This bug can be found in most of the NXP I2C drivers and this commit
contains a fix for them all. I however only have the LPC1768 and
LPC11U24 for testing.
My fix does the following:
beginning of the i2c_start() function. It was this clear that
previously caused the problem as described above.
the STA (start) bit has been set with the i2c_conset() call.
active interrupt when first entering i2c_start(). If you clear
the SI bit when there isn't an active interrupt then the code
is likely to skip over the interrupt for the start bit which was
just sent and then allow the I2C peripheral to start sending the
slave address before it has even been loaded into the I2CDAT
register.
My Repro Case
I wrote two samples to reproduce this bug and verify that it was fixed by this change. The master sample is expected to be connected to a device which is running the slave sample.
Master test code which is a modified version of what I found in https://github.com/mbedmicro/mbed/blob/master/libraries/tests/mbed/i2c_master/main.cpp I modified it to read registers using repeated starts like I was doing with the MPU-6050 sensor. I then schedule an ISR to trigger at a random time in the range of when I expect the repeated start to occur:
Slave test code which is a modified version of what I found in https://github.com/mbedmicro/mbed/blob/master/libraries/tests/mbed/i2c_slave/main.cpp I modified it to support a register read/write protocol similar to MPU-6059 sensor. A write to the register sets an 8-bit counter and a read returns an auto-incremented version of the counter.
I couldn't get the slave code to work without a small modification to the i2c_slave_read() function as well. I am not that confident in this change so I just list the diff here for anyone trying to run this repro case.