テスト用のあれこれ共用フォルダ
リビジョン | 8b9bd70e86849e63e4eeb749363a3993d782405d (tree) |
---|---|
日時 | 2019-01-04 21:51:44 |
作者 | takemasa <suikan@user...> |
コミッター | takemasa |
Added transfered count
@@ -6,7 +6,7 @@ | ||
6 | 6 | <provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/> |
7 | 7 | <provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/> |
8 | 8 | <provider copy-of="extension" id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser"/> |
9 | - <provider class="fr.ac6.mcu.ide.build.CrossBuiltinSpecsDetector" console="false" env-hash="-931017912165882417" id="fr.ac6.mcu.ide.build.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="Ac6 SW4 STM32 MCU Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true"> | |
9 | + <provider class="fr.ac6.mcu.ide.build.CrossBuiltinSpecsDetector" console="false" env-hash="1318604374853316739" id="fr.ac6.mcu.ide.build.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="Ac6 SW4 STM32 MCU Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true"> | |
10 | 10 | <language-scope id="org.eclipse.cdt.core.gcc"/> |
11 | 11 | <language-scope id="org.eclipse.cdt.core.g++"/> |
12 | 12 | </provider> |
@@ -18,7 +18,7 @@ | ||
18 | 18 | <provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/> |
19 | 19 | <provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/> |
20 | 20 | <provider copy-of="extension" id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser"/> |
21 | - <provider class="fr.ac6.mcu.ide.build.CrossBuiltinSpecsDetector" console="false" env-hash="-931017912165882417" id="fr.ac6.mcu.ide.build.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="Ac6 SW4 STM32 MCU Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true"> | |
21 | + <provider class="fr.ac6.mcu.ide.build.CrossBuiltinSpecsDetector" console="false" env-hash="1318604374853316739" id="fr.ac6.mcu.ide.build.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="Ac6 SW4 STM32 MCU Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true"> | |
22 | 22 | <language-scope id="org.eclipse.cdt.core.gcc"/> |
23 | 23 | <language-scope id="org.eclipse.cdt.core.g++"/> |
24 | 24 | </provider> |
@@ -12,8 +12,8 @@ | ||
12 | 12 | <targetDefinitions> |
13 | 13 | <board id="nucleo-f746zg"> |
14 | 14 | <name>NUCLEO-F746ZG</name> |
15 | - <dbgIF>JTAG</dbgIF> | |
16 | 15 | <dbgIF>SWD</dbgIF> |
16 | + <dbgIF>JTAG</dbgIF> | |
17 | 17 | <dbgDEV>ST-Link</dbgDEV> |
18 | 18 | <mcuId>stm32f746zgtx</mcuId> |
19 | 19 | </board> |
@@ -44,16 +44,17 @@ class AbstractI2CMaster : murasaki::AbstractPeripheral | ||
44 | 44 | * exclusive between multiple task access. In other word, it should be thread save. |
45 | 45 | */ |
46 | 46 | virtual murasaki::I2cStatus Transmit( |
47 | - uint addrs, | |
48 | - const uint8_t * tx_data, | |
49 | - unsigned int tx_size, | |
47 | + uint addrs, | |
48 | + const uint8_t * tx_data, | |
49 | + unsigned int tx_size, | |
50 | 50 | uint * transfered_count = nullptr, |
51 | - WaitMilliSeconds timeout_ms = murasaki::kwmsIndefinitely) = 0; | |
51 | + WaitMilliSeconds timeout_ms = murasaki::kwmsIndefinitely) = 0; | |
52 | 52 | /** |
53 | 53 | * @brief Thread safe, blocking receiving over I2C. |
54 | 54 | * @param addrs 7bit address of the I2C device. |
55 | 55 | * @param rx_data Data array to transmit. |
56 | 56 | * @param rx_size Data counts[bytes] to transmit. |
57 | + * @param transfered_count the count of the bytes transfered during the API execution. | |
57 | 58 | * @param timeout_ms Time ou [mS]. By default, there is not timeout. |
58 | 59 | * @return Result of the processing |
59 | 60 | * @details |
@@ -61,10 +62,11 @@ class AbstractI2CMaster : murasaki::AbstractPeripheral | ||
61 | 62 | * exclusive between multiple task access. In other word, it should be thread save. |
62 | 63 | */ |
63 | 64 | virtual murasaki::I2cStatus Receive( |
64 | - uint addrs, | |
65 | - uint8_t * rx_data, | |
66 | - unsigned int rx_size, | |
67 | - WaitMilliSeconds timeout_ms = murasaki::kwmsIndefinitely) = 0; | |
65 | + uint addrs, | |
66 | + uint8_t * rx_data, | |
67 | + unsigned int rx_size, | |
68 | + uint * transfered_count = nullptr, | |
69 | + WaitMilliSeconds timeout_ms = murasaki::kwmsIndefinitely) = 0; | |
68 | 70 | /** |
69 | 71 | * @brief Thread safe, blocking transmission and then receiving over I2C. |
70 | 72 | * @param addrs 7bit address of the I2C device. |
@@ -72,6 +74,8 @@ class AbstractI2CMaster : murasaki::AbstractPeripheral | ||
72 | 74 | * @param tx_size Data counts[bytes] to transmit. |
73 | 75 | * @param rx_data Data array to transmit. |
74 | 76 | * @param rx_size Data counts[bytes] to transmit. |
77 | + * @param tx_transfered_count the count of the bytes transmitted during the API execution. | |
78 | + * @param tx_transfered_count the count of the bytes received during the API execution. | |
75 | 79 | * @param timeout_ms Time ou [mS]. By default, there is not timeout. |
76 | 80 | * @return Result of the processing |
77 | 81 | * @details |
@@ -83,12 +87,14 @@ class AbstractI2CMaster : murasaki::AbstractPeripheral | ||
83 | 87 | * |
84 | 88 | */ |
85 | 89 | virtual murasaki::I2cStatus TransmitThenReceive( |
86 | - uint addrs, | |
87 | - const uint8_t * tx_data, | |
88 | - unsigned int tx_size, | |
89 | - uint8_t * rx_data, | |
90 | - unsigned int rx_size, | |
91 | - WaitMilliSeconds timeout_ms = murasaki::kwmsIndefinitely) =0; | |
90 | + uint addrs, | |
91 | + const uint8_t * tx_data, | |
92 | + unsigned int tx_size, | |
93 | + uint8_t * rx_data, | |
94 | + unsigned int rx_size, | |
95 | + uint * tx_transfered_count = nullptr, | |
96 | + uint * rx_transfered_count = nullptr, | |
97 | + WaitMilliSeconds timeout_ms = murasaki::kwmsIndefinitely) =0; | |
92 | 98 | /** |
93 | 99 | * \brief Call back to be called notify the transfer is complete. |
94 | 100 | * \param ptr Pointer for generic use. Usually, points a struct of a peripheral control |
@@ -31,6 +31,7 @@ class AbstractI2cSlave : public murasaki::AbstractPeripheral { | ||
31 | 31 | * @brief Thread safe, blocking transmission over I2C. |
32 | 32 | * @param tx_data Data array to transmit. |
33 | 33 | * @param tx_size Data counts[bytes] to transmit. |
34 | + * @param transfered_count the count of the bytes transfered during the API execution. | |
34 | 35 | * @param timeout_ms Time ou [mS]. By default, there is not timeout. |
35 | 36 | * @return Result of the processing |
36 | 37 | * @details |
@@ -40,11 +41,13 @@ class AbstractI2cSlave : public murasaki::AbstractPeripheral { | ||
40 | 41 | virtual murasaki::I2cStatus Transmit( |
41 | 42 | const uint8_t * tx_data, |
42 | 43 | unsigned int tx_size, |
44 | + uint * transfered_count = nullptr, | |
43 | 45 | murasaki::WaitMilliSeconds timeout_ms = murasaki::kwmsIndefinitely) = 0; |
44 | 46 | /** |
45 | 47 | * @brief Thread safe, blocking receiving over I2C. |
46 | 48 | * @param rx_data Data array to transmit. |
47 | 49 | * @param rx_size Data counts[bytes] to transmit. |
50 | + * @param transfered_count the count of the bytes transfered during the API execution. | |
48 | 51 | * @param timeout_ms Time ou [mS]. By default, there is not timeout. |
49 | 52 | * @return Result of the processing |
50 | 53 | * @details |
@@ -54,6 +57,7 @@ class AbstractI2cSlave : public murasaki::AbstractPeripheral { | ||
54 | 57 | virtual murasaki::I2cStatus Receive( |
55 | 58 | uint8_t * rx_data, |
56 | 59 | unsigned int rx_size, |
60 | + uint * transfered_count = nullptr, | |
57 | 61 | murasaki::WaitMilliSeconds timeout_ms = murasaki::kwmsIndefinitely) = 0; |
58 | 62 | |
59 | 63 | /** |
@@ -117,6 +117,7 @@ murasaki::I2cStatus I2cMaster::Receive( | ||
117 | 117 | uint addrs, |
118 | 118 | uint8_t* rx_data, |
119 | 119 | unsigned int rx_size, |
120 | + uint * transfered_count, | |
120 | 121 | WaitMilliSeconds timeout_ms) { |
121 | 122 | |
122 | 123 | I2C_SYSLOG("Enter"); |
@@ -145,6 +146,12 @@ murasaki::I2cStatus I2cMaster::Receive( | ||
145 | 146 | sync_->Wait(timeout_ms); |
146 | 147 | I2C_SYSLOG("Sync released.") |
147 | 148 | |
149 | + // retrieve the count of transfer | |
150 | + // XfereCount is initialized in HAL. The initial value is XferSize which is tx_size in this function. | |
151 | + // And then XferCunt is decremented for each interrupt. | |
152 | + if (transfered_count != nullptr) | |
153 | + *transfered_count = rx_size - peripheral_->XferCount; | |
154 | + | |
148 | 155 | // check the status from interrupt |
149 | 156 | switch (interrupt_status_) |
150 | 157 | { |
@@ -181,11 +188,13 @@ murasaki::I2cStatus I2cMaster::Receive( | ||
181 | 188 | } |
182 | 189 | |
183 | 190 | murasaki::I2cStatus I2cMaster::TransmitThenReceive( |
184 | - uint addrs, | |
185 | - const uint8_t* tx_data, | |
186 | - unsigned int tx_size, | |
187 | - uint8_t* rx_data, | |
188 | - unsigned int rx_size, | |
191 | + uint addrs, | |
192 | + const uint8_t* tx_data, | |
193 | + unsigned int tx_size, | |
194 | + uint8_t* rx_data, | |
195 | + unsigned int rx_size, | |
196 | + uint * tx_transfered_count, | |
197 | + uint * rx_transfered_count, | |
189 | 198 | WaitMilliSeconds timeout_ms) { |
190 | 199 | |
191 | 200 | I2C_SYSLOG("Enter"); |
@@ -206,17 +215,26 @@ murasaki::I2cStatus I2cMaster::TransmitThenReceive( | ||
206 | 215 | interrupt_status_ = murasaki::ki2csTimeOut; |
207 | 216 | |
208 | 217 | status = HAL_I2C_Master_Sequential_Transmit_IT( |
209 | - peripheral_, | |
210 | - addrs << 1, | |
211 | - const_cast<uint8_t *>(tx_data), | |
212 | - tx_size, | |
213 | - I2C_FIRST_FRAME); | |
218 | + peripheral_, | |
219 | + addrs << 1, | |
220 | + const_cast<uint8_t *>(tx_data), | |
221 | + tx_size, | |
222 | + I2C_FIRST_FRAME); | |
214 | 223 | MURASAKI_ASSERT(HAL_OK == status); |
215 | 224 | |
216 | 225 | // wait for the completion |
217 | 226 | sync_->Wait(timeout_ms); |
218 | 227 | I2C_SYSLOG("Sync released.") |
219 | 228 | |
229 | + // retrieve the count of transfer | |
230 | + // XfereCount is initialized in HAL. The initial value is XferSize which is tx_size in this function. | |
231 | + // And then XferCunt is decremented for each interrupt. | |
232 | + if (tx_transfered_count != nullptr) | |
233 | + *tx_transfered_count = tx_size - peripheral_->XferCount; | |
234 | + | |
235 | + // In case of the TX problem, the RX may be skipped. | |
236 | + // To save that situation, initialize the value. | |
237 | + *rx_transfered_count = 0; | |
220 | 238 | // check the status from interrupt |
221 | 239 | switch (interrupt_status_) |
222 | 240 | { |
@@ -241,6 +259,12 @@ murasaki::I2cStatus I2cMaster::TransmitThenReceive( | ||
241 | 259 | sync_->Wait(timeout_ms); |
242 | 260 | I2C_SYSLOG("Sync released.") |
243 | 261 | |
262 | + // retrieve the count of transfer | |
263 | + // XfereCount is initialized in HAL. The initial value is XferSize which is tx_size in this function. | |
264 | + // And then XferCunt is decremented for each interrupt. | |
265 | + if (rx_transfered_count != nullptr) | |
266 | + *rx_transfered_count = rx_size - peripheral_->XferCount; | |
267 | + | |
244 | 268 | // check the status from interrupt |
245 | 269 | switch (interrupt_status_) |
246 | 270 | { |
@@ -95,6 +95,7 @@ class I2cMaster : public AbstractI2CMaster | ||
95 | 95 | * @param addrs 7bit address of the I2C device. |
96 | 96 | * @param tx_data Data array to transmit. |
97 | 97 | * @param tx_size Data counts[bytes] to transmit. Must be smaller than 65536 |
98 | + * @param transfered_count the count of the bytes transfered during the API execution. | |
98 | 99 | * @param timeout_ms Time ou [mS]. By default, there is not timeout. |
99 | 100 | * @return Result of the processing |
100 | 101 | * @details |
@@ -121,6 +122,7 @@ class I2cMaster : public AbstractI2CMaster | ||
121 | 122 | * @param addrs 7bit address of the I2C device. |
122 | 123 | * @param rx_data Data array to transmit. |
123 | 124 | * @param rx_size Data counts[bytes] to transmit. Must be smaller than 65536 |
125 | + * @param transfered_count the count of the bytes transfered during the API execution. | |
124 | 126 | * @param timeout_ms Time ou [mS]. By default, there is not timeout. |
125 | 127 | * @return Result of the processing |
126 | 128 | * @details |
@@ -139,6 +141,7 @@ class I2cMaster : public AbstractI2CMaster | ||
139 | 141 | uint addrs, |
140 | 142 | uint8_t * rx_data, |
141 | 143 | unsigned int rx_size, |
144 | + uint * transfered_count, | |
142 | 145 | WaitMilliSeconds timeout_ms); |
143 | 146 | /** |
144 | 147 | * @brief Thread safe, blocking transmission and then receiving over I2C. |
@@ -147,6 +150,8 @@ class I2cMaster : public AbstractI2CMaster | ||
147 | 150 | * @param tx_size Data counts[bytes] to transmit. Must be smaller than 65536 |
148 | 151 | * @param rx_data Data array to transmit. |
149 | 152 | * @param rx_size Data counts[bytes] to transmit. Must be smaller than 65536 |
153 | + * @param tx_transfered_count the count of the bytes transmitted during the API execution. | |
154 | + * @param tx_transfered_count the count of the bytes received during the API execution. | |
150 | 155 | * @param timeout_ms Time ou [mS]. By default, there is not timeout. |
151 | 156 | * @return Result of the processing |
152 | 157 | * @details |
@@ -165,12 +170,14 @@ class I2cMaster : public AbstractI2CMaster | ||
165 | 170 | * @li other value : Unhandled error. I2C device are re-initialized. |
166 | 171 | */ |
167 | 172 | virtual murasaki::I2cStatus TransmitThenReceive( |
168 | - uint addrs, | |
169 | - const uint8_t * tx_data, | |
170 | - unsigned int tx_size, | |
171 | - uint8_t * rx_data, | |
172 | - unsigned int rx_size, | |
173 | - WaitMilliSeconds timeout_ms = murasaki::kwmsIndefinitely); | |
173 | + uint addrs, | |
174 | + const uint8_t * tx_data, | |
175 | + unsigned int tx_size, | |
176 | + uint8_t * rx_data, | |
177 | + unsigned int rx_size, | |
178 | + uint * tx_transfered_count, | |
179 | + uint * rx_transfered_count, | |
180 | + WaitMilliSeconds timeout_ms); | |
174 | 181 | /** |
175 | 182 | * \brief Call back to be called notify the transfer is complete. |
176 | 183 | * \param ptr Pointer for generic use. Usually, points a struct of a peripheral control |
@@ -45,6 +45,7 @@ I2cSlave::~I2cSlave() | ||
45 | 45 | murasaki::I2cStatus I2cSlave::Transmit( |
46 | 46 | const uint8_t* tx_data, |
47 | 47 | unsigned int tx_size, |
48 | + uint * transfered_count, | |
48 | 49 | WaitMilliSeconds timeout_ms) |
49 | 50 | { |
50 | 51 | I2C_SYSLOG("Enter"); |
@@ -70,6 +71,13 @@ murasaki::I2cStatus I2cSlave::Transmit( | ||
70 | 71 | sync_->Wait(timeout_ms); |
71 | 72 | I2C_SYSLOG("Sync released.") |
72 | 73 | |
74 | + // retrieve the count of transfer | |
75 | + // XfereCount is initialized in HAL. The initial value is XferSize which is tx_size in this function. | |
76 | + // And then XferCunt is decremented for each interrupt. | |
77 | + if (transfered_count != nullptr) | |
78 | + *transfered_count = tx_size - peripheral_->XferCount; | |
79 | + | |
80 | + | |
73 | 81 | switch (interrupt_status_) |
74 | 82 | { |
75 | 83 | case murasaki::ki2csOK: |
@@ -107,6 +115,7 @@ murasaki::I2cStatus I2cSlave::Transmit( | ||
107 | 115 | murasaki::I2cStatus I2cSlave::Receive( |
108 | 116 | uint8_t* rx_data, |
109 | 117 | unsigned int rx_size, |
118 | + uint * transfered_count, | |
110 | 119 | WaitMilliSeconds timeout_ms) |
111 | 120 | { |
112 | 121 | I2C_SYSLOG("Enter"); |
@@ -133,6 +142,12 @@ murasaki::I2cStatus I2cSlave::Receive( | ||
133 | 142 | sync_->Wait(timeout_ms); |
134 | 143 | I2C_SYSLOG("Sync released.") |
135 | 144 | |
145 | + // retrieve the count of transfer | |
146 | + // XfereCount is initialized in HAL. The initial value is XferSize which is tx_size in this function. | |
147 | + // And then XferCunt is decremented for each interrupt. | |
148 | + if (transfered_count != nullptr) | |
149 | + *transfered_count = rx_size - peripheral_->XferCount; | |
150 | + | |
136 | 151 | // check the status from interrupt |
137 | 152 | switch (interrupt_status_) |
138 | 153 | { |
@@ -88,6 +88,7 @@ class I2cSlave : public AbstractI2cSlave { | ||
88 | 88 | * @brief Thread safe, blocking transmission over I2C. |
89 | 89 | * @param tx_data Data array to transmit. |
90 | 90 | * @param tx_size Data counts[bytes] to transmit. Must be smaller than 65536 |
91 | + * @param transfered_count the count of the bytes transfered during the API execution. | |
91 | 92 | * @param timeout_ms Time ou [mS]. By default, there is not timeout. |
92 | 93 | * @return Result of the processing |
93 | 94 | * @details |
@@ -105,11 +106,13 @@ class I2cSlave : public AbstractI2cSlave { | ||
105 | 106 | virtual murasaki::I2cStatus Transmit( |
106 | 107 | const uint8_t * tx_data, |
107 | 108 | unsigned int tx_size, |
108 | - WaitMilliSeconds timeout_ms = murasaki::kwmsIndefinitely); | |
109 | + uint * transfered_count, | |
110 | + WaitMilliSeconds timeout_ms); | |
109 | 111 | /** |
110 | 112 | * @brief Thread safe, blocking receiving over I2C. |
111 | 113 | * @param rx_data Data array to transmit. |
112 | 114 | * @param rx_size Data counts[bytes] to transmit. Must be smaller than 65536 |
115 | + * @param transfered_count the count of the bytes transfered during the API execution. | |
113 | 116 | * @param timeout_ms Time ou [mS]. By default, there is not timeout. |
114 | 117 | * @return Result of the processing |
115 | 118 | * @details |
@@ -127,7 +130,8 @@ class I2cSlave : public AbstractI2cSlave { | ||
127 | 130 | virtual murasaki::I2cStatus Receive( |
128 | 131 | uint8_t * rx_data, |
129 | 132 | unsigned int rx_size, |
130 | - WaitMilliSeconds timeout_ms = murasaki::kwmsIndefinitely); | |
133 | + uint * transfered_count, | |
134 | + WaitMilliSeconds timeout_ms); | |
131 | 135 | |
132 | 136 | /** |
133 | 137 | * \brief Call back to be called notify the transfer is complete. |
@@ -89,8 +89,10 @@ void Uart::SetHardwareFlowControl(UartHardwareFlowControl control) | ||
89 | 89 | UART_SYSLOG("Return"); |
90 | 90 | } |
91 | 91 | |
92 | -murasaki::UartStatus Uart::Transmit(const uint8_t * data, unsigned int size, | |
93 | - WaitMilliSeconds timeout_ms) | |
92 | +murasaki::UartStatus Uart::Transmit( | |
93 | + const uint8_t * data, | |
94 | + unsigned int size, | |
95 | + WaitMilliSeconds timeout_ms) | |
94 | 96 | { |
95 | 97 | UART_SYSLOG("Enter"); |
96 | 98 |
@@ -160,7 +162,10 @@ UART_SYSLOG("Enter"); | ||
160 | 162 | } |
161 | 163 | } |
162 | 164 | |
163 | -murasaki::UartStatus Uart::Receive(uint8_t * data, unsigned int size, WaitMilliSeconds timeout_ms) | |
165 | +murasaki::UartStatus Uart::Receive( | |
166 | + uint8_t * data, | |
167 | + unsigned int size, | |
168 | + WaitMilliSeconds timeout_ms) | |
164 | 169 | { |
165 | 170 | UART_SYSLOG("Enter"); |
166 | 171 |
@@ -12,8 +12,8 @@ | ||
12 | 12 | <targetDefinitions> |
13 | 13 | <board id="nucleo-f722ze"> |
14 | 14 | <name>NUCLEO-F722ZE</name> |
15 | - <dbgIF>JTAG</dbgIF> | |
16 | 15 | <dbgIF>SWD</dbgIF> |
16 | + <dbgIF>JTAG</dbgIF> | |
17 | 17 | <dbgDEV>ST-Link</dbgDEV> |
18 | 18 | <mcuId>stm32f722zetx</mcuId> |
19 | 19 | </board> |