Skip to content

Commit

Permalink
Merge pull request #563 from Paciente8159/prevent-jitter-with-emulate…
Browse files Browse the repository at this point in the history
…d-coms

added calls to main loop in soft emulated coms
  • Loading branch information
Paciente8159 committed Nov 14, 2023
2 parents f1e974b + 362ba4b commit 7cecd5d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion uCNC/src/modules/softi2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
Also without the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
*/
#include "../cnc.h"
#include "softi2c.h"

void softi2c_delay(uint8_t loops_100ns)
Expand Down Expand Up @@ -60,7 +61,7 @@ static uint8_t softi2c_clock_stretch(softi2c_port_t *port)
static uint8_t softi2c_write(softi2c_port_t *port, uint8_t c, bool send_start, bool send_stop)
{
uint8_t ack = 0;

cnc_dotasks();
if (send_start)
{
// init
Expand Down Expand Up @@ -125,6 +126,7 @@ static uint8_t softi2c_read(softi2c_port_t *port, bool with_ack, bool send_stop)
{
uint8_t c = 0xFF;
uint8_t i = 8;
cnc_dotasks();
do
{
softi2c_delay(port->i2cdelay);
Expand Down
1 change: 1 addition & 0 deletions uCNC/src/modules/softspi.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ void softspi_config(softspi_port_t *port, uint8_t mode, uint32_t frequency)

uint8_t softspi_xmit(softspi_port_t *port, uint8_t c)
{
cnc_dotasks();
if (!port)
{
#ifdef MCU_HAS_SPI
Expand Down
3 changes: 2 additions & 1 deletion uCNC/src/modules/softuart.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

void softuart_putc(softuart_port_t *port, char c)
{
cnc_dotasks();
if (!port)
{
#if (defined(MCU_HAS_UART2) && defined(DETACH_UART2_FROM_MAIN_PROTOCOL))
Expand Down Expand Up @@ -61,11 +62,11 @@ int16_t softuart_getc(softuart_port_t *port, uint32_t ms_timeout)
ms_timeout *= 1000;
while (port->rx())
{
mcu_delay_us(1);
if (!ms_timeout--)
{
return -1;
}
cnc_dotasks();
}
port->waithalf();

Expand Down

0 comments on commit 7cecd5d

Please sign in to comment.