Some minor changes in delay functions

This commit is contained in:
Andy CA6JAU 2017-02-02 01:31:33 -03:00
parent 587fe63a47
commit 66fe701251
5 changed files with 22 additions and 12 deletions

View file

@ -1,6 +1,9 @@
/* /*
* Copyright (C) 2016 by Jim McLaughlin KI6ZUM * Copyright (C) 2016 by Jim McLaughlin KI6ZUM
* Copyright (C) 2016, 2017 by Andy Uribe CA6JAU * Copyright (C) 2016, 2017 by Andy Uribe CA6JAU
*
* Some of the code is based on work of Guus Van Dooren PE1PLM:
* https://github.com/ki6zum/gmsk-dstar/blob/master/firmware/dvmega/dvmega.ino
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -29,12 +32,6 @@
volatile uint32_t AD7021_control_byte; volatile uint32_t AD7021_control_byte;
volatile int AD7021_counter; volatile int AD7021_counter;
void dlybit(void)
{
volatile unsigned int delay;
for(delay = 0;delay<5;delay++);
}
void Send_AD7021_control() void Send_AD7021_control()
{ {
for(AD7021_counter = 31; AD7021_counter >= 0; AD7021_counter--) { for(AD7021_counter = 31; AD7021_counter >= 0; AD7021_counter--) {
@ -43,14 +40,14 @@ void Send_AD7021_control()
else else
io.SDATA_pin(LOW); io.SDATA_pin(LOW);
io.dlybit();
io.SCLK_pin(HIGH); io.SCLK_pin(HIGH);
dlybit(); io.dlybit();
io.SCLK_pin(LOW); io.SCLK_pin(LOW);
dlybit();
} }
io.SLE_pin(HIGH); io.SLE_pin(HIGH);
dlybit(); io.dlybit();
io.SLE_pin(LOW); io.SLE_pin(LOW);
io.SDATA_pin(LOW); io.SDATA_pin(LOW);
} }

View file

@ -28,7 +28,6 @@
#define bitRead(value, bit) (((value) >> (bit)) & 0x01) #define bitRead(value, bit) (((value) >> (bit)) & 0x01)
void dlybit(void);
void Send_AD7021_control(void); void Send_AD7021_control(void);
void Send_REG0_RX(void); void Send_REG0_RX(void);
void Send_REG0_TX(void); void Send_REG0_TX(void);

6
IO.h
View file

@ -73,13 +73,15 @@ public:
void ifConf(); void ifConf();
void ifInit(); void ifInit();
// Misc functions
void dlybit(void);
void delay_rx(void);
private: private:
bool m_started; bool m_started;
CBitRB m_rxBuffer; CBitRB m_rxBuffer;
CBitRB m_txBuffer; CBitRB m_txBuffer;
void delay_rx(void);
}; };
#endif #endif

View file

@ -73,6 +73,12 @@ void CIO::delay_rx() {
delayMicroseconds(1); delayMicroseconds(1);
} }
void CIO::dlybit(void)
{
volatile unsigned int delay;
delayMicroseconds(1);
}
void CIO::Init() void CIO::Init()
{ {
#if defined (__STM32F1__) #if defined (__STM32F1__)

View file

@ -85,6 +85,12 @@ void CIO::delay_rx() {
for(delay = 0;delay<512;delay++); for(delay = 0;delay<512;delay++);
} }
void CIO::dlybit(void)
{
volatile unsigned int delay;
for(delay = 0;delay<5;delay++);
}
void CIO::Init() void CIO::Init()
{ {
// USB Conf IO: // USB Conf IO: