mirror of
https://github.com/juribeparada/MMDVM_HS.git
synced 2026-04-07 15:23:43 +00:00
Working baseline, works with -O0 -- -O3 AND -O0 with gcc 4.9.3 Ubuntu. TX to RX switch timing is the challenge. IOArduino.cpp may not work
This commit is contained in:
parent
3a4451684f
commit
aefe492f9b
5 changed files with 102 additions and 69 deletions
83
IOSTM.cpp
83
IOSTM.cpp
|
|
@ -17,6 +17,7 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#if defined(STM32F10X_MD)
|
||||
|
|
@ -239,39 +240,6 @@ extern "C" {
|
|||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* Function delay_us() from stm32duino project
|
||||
*
|
||||
* @brief Delay the given number of microseconds.
|
||||
*
|
||||
* @param us Number of microseconds to delay.
|
||||
*/
|
||||
static inline void delay_us(uint32_t us) {
|
||||
us *= 12;
|
||||
|
||||
/* fudge for function call overhead */
|
||||
us--;
|
||||
asm volatile(" mov r0, %[us] \n\t"
|
||||
"1: subs r0, #1 \n\t"
|
||||
" bhi 1b \n\t"
|
||||
:
|
||||
: [us] "r" (us)
|
||||
: "r0");
|
||||
}
|
||||
|
||||
void CIO::delay_rx() {
|
||||
#if defined(BIDIR_DATA_PIN)
|
||||
delay_us(290);
|
||||
#else
|
||||
delay_us(340);
|
||||
#endif
|
||||
}
|
||||
|
||||
void CIO::dlybit(void)
|
||||
{
|
||||
delay_us(1);
|
||||
}
|
||||
|
||||
void CIO::Init()
|
||||
{
|
||||
// USB Conf IO:
|
||||
|
|
@ -532,6 +500,8 @@ bool CIO::CLK_pin()
|
|||
void CIO::RXD_pin_write(bool on)
|
||||
{
|
||||
GPIO_WriteBit(PORT_RXD, PIN_RXD, on ? Bit_SET : Bit_RESET);
|
||||
GPIO_WriteBit(PORT_YSF_LED, PIN_YSF_LED, on ? Bit_SET : Bit_RESET);
|
||||
GPIO_WriteBit(PORT_YSF_LED, PIN_YSF_LED, on ? Bit_SET : Bit_RESET);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -580,4 +550,51 @@ void CIO::COS_pin(bool on)
|
|||
GPIO_WriteBit(PORT_COS_LED, PIN_COS_LED, on ? Bit_SET : Bit_RESET);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function delay_us() from stm32duino project
|
||||
*
|
||||
* @brief Delay the given number of microseconds.
|
||||
*
|
||||
* @param us Number of microseconds to delay.
|
||||
*/
|
||||
static inline void delay_us(uint32_t us) {
|
||||
us *= 12;
|
||||
|
||||
/* fudge for function call overhead */
|
||||
us--;
|
||||
asm volatile(" mov r0, %[us] \n\t"
|
||||
"1: subs r0, #1 \n\t"
|
||||
" bhi 1b \n\t"
|
||||
:
|
||||
: [us] "r" (us)
|
||||
: "r0");
|
||||
}
|
||||
|
||||
void CIO::delay_rx() {
|
||||
#if defined(BIDIR_DATA_PIN)
|
||||
delay_us(290);
|
||||
#else
|
||||
delay_us(340);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
// TODO: Investigate why. In fact there is just a single place where this is being use
|
||||
// during normal operation
|
||||
// it seems that optimizing this code breaks some timings
|
||||
#pragma GCC optimize ("O0")
|
||||
static inline void delay_ns() {
|
||||
|
||||
asm volatile("mov r8, r8 \n\t"
|
||||
"mov r8, r8 \n\t"
|
||||
"mov r8, r8 \n\t"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
void CIO::dlybit(void)
|
||||
{
|
||||
delay_ns();
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue