fix pulseIn compile issue #219

use C for countPulseASM
This commit is contained in:
hathach committed 2019-01-23 17:30:40 +07:00
1 parent b9a9453abc
commit cc6366ec06
3 files changed
+28 -4

No files matched your search

+2 -1
View File
@@ -7,7 +7,8 @@
- Remove Gap.connected(), Gap.getRole() in prefer to BLEConnection API - Remove Gap.connected(), Gap.getRole() in prefer to BLEConnection API
- Added setRssiCallback(), monitorRssi(), getRssi(), stopRssi() for tracking rssi of a connection - Added setRssiCallback(), monitorRssi(), getRssi(), stopRssi() for tracking rssi of a connection
- rssi_poll and rssi_callback example sketches are added - rssi_poll and rssi_callback example sketches are added
- Change BLECharacteristic callback signature BLECharacteristic& to BLECharacteristic* - Change BLECharacteristic callback signature BLECharacteristic& to BLECharacteristic*
- Use AdaCallback thread for BLECharacteristic callbacks
# 0.9.3 # 0.9.3
+22
View File
@@ -23,6 +23,28 @@
// See pulse_asm.S // See pulse_asm.S
extern unsigned long countPulseASM(const volatile uint32_t *port, uint32_t bit, uint32_t stateMask, unsigned long maxloops); extern unsigned long countPulseASM(const volatile uint32_t *port, uint32_t bit, uint32_t stateMask, unsigned long maxloops);
unsigned long countPulseASM(const volatile uint32_t *port, uint32_t bit, uint32_t stateMask, unsigned long maxloops)
{
unsigned long width = 0;
// wait for any previous pulse to end
while ((*port & bit) == stateMask)
if (--maxloops == 0)
return 0;
// wait for the pulse to start
while ((*port & bit) != stateMask)
if (--maxloops == 0)
return 0;
// wait for the pulse to stop
while ((*port & bit) == stateMask) {
if (++width == maxloops)
return 0;
}
return width;
}
/* Measures the length (in microseconds) of a pulse on the pin; state is HIGH /* Measures the length (in microseconds) of a pulse on the pin; state is HIGH
* or LOW, the type of pulse to measure. Works on pulses from 2-3 microseconds * or LOW, the type of pulse to measure. Works on pulses from 2-3 microseconds
* to 3 minutes in length, but must be called at least a few dozen microseconds * to 3 minutes in length, but must be called at least a few dozen microseconds
+4 -3
View File
@@ -58,9 +58,9 @@ using the command line:
The result has been slightly edited to increase readability. The result has been slightly edited to increase readability.
*/ */
/*
.cpu cortex-m0plus .cpu cortex-m4
.fpu softvfp .fpu fpv4-sp-d16
.eabi_attribute 20, 1 @ Tag_ABI_FP_denormal .eabi_attribute 20, 1 @ Tag_ABI_FP_denormal
.eabi_attribute 21, 1 @ Tag_ABI_FP_exceptions .eabi_attribute 21, 1 @ Tag_ABI_FP_exceptions
.eabi_attribute 23, 3 @ Tag_ABI_FP_number_model .eabi_attribute 23, 3 @ Tag_ABI_FP_number_model
@@ -173,3 +173,4 @@ countPulseASM:
pop {r4, r5, pc} pop {r4, r5, pc}
.size countPulseASM, .-countPulseASM .size countPulseASM, .-countPulseASM
.ident "GCC: (GNU Tools for ARM Embedded Processors (Arduino build)) 4.8.3 20140228 (release) [ARM/embedded-4_8-branch revision 208322]" .ident "GCC: (GNU Tools for ARM Embedded Processors (Arduino build)) 4.8.3 20140228 (release) [ARM/embedded-4_8-branch revision 208322]"
*/