1
1
/* mbed Microcontroller Library
2
- * Copyright (c) 2006-2013 ARM Limited
2
+ * Copyright (c) 2006-2020 ARM Limited
3
3
* SPDX-License-Identifier: Apache-2.0
4
4
*
5
5
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -50,10 +50,19 @@ volatile struct st_riic *RIIC[] = RIIC_ADDRESS_LIST;
50
50
51
51
/* RIICnSER */
52
52
#define SER_SAR0E (1 << 0)
53
+ #define SER_SAR1E (1 << 1)
54
+ #define SER_SAR2E (1 << 2)
55
+ #define SER_GCE (1 << 3)
56
+ #define SER_DIDE (1 << 5)
57
+ #define SER_HOAE (1 << 7)
53
58
54
59
/* RIICnSR1 */
55
60
#define SR1_AAS0 (1 << 0)
61
+ #define SR1_AAS1 (1 << 1)
62
+ #define SR1_AAS2 (1 << 2)
56
63
#define SR1_GCA (1 << 3)
64
+ #define SR1_DID (1 << 5)
65
+ #define SR1_HOA (1 << 7)
57
66
58
67
/* RIICnSR2 */
59
68
#define SR2_START (1 << 2)
@@ -689,6 +698,12 @@ int i2c_slave_receive(i2c_t *obj)
689
698
retval = 0 ;
690
699
}
691
700
701
+ /* to detect restart-condition */
702
+ if (0 != retval ) {
703
+ /* SR2.START = 0 */
704
+ REG (SR2 .UINT32 ) &= ~SR2_START ;
705
+ }
706
+
692
707
return retval ;
693
708
}
694
709
@@ -704,6 +719,7 @@ int i2c_slave_read(i2c_t *obj, char *data, int length)
704
719
for (count = 0 ; ((count < (length + 1 )) && (break_flg == 0 )); count ++ ) {
705
720
/* There is no timeout, but the upper limit value is set to avoid an infinite loop. */
706
721
while (((i2c_status (obj ) & (SR2_STOP | SR2_START )) != 0 ) || ((i2c_status (obj ) & SR2_RDRF ) == 0 )) {
722
+ /* received stop-condition or restart-condition */
707
723
if ((i2c_status (obj ) & (SR2_STOP | SR2_START )) != 0 ) {
708
724
break_flg = 1 ;
709
725
break ;
0 commit comments