From d22277f4a52c8eec67f30a5628d234ed0e905630 Mon Sep 17 00:00:00 2001 From: Andreas Karlsson Date: Thu, 16 Mar 2023 16:37:58 +0100 Subject: [PATCH] Add typecast for bitwise operations of ESC Add explicit typecasts for bitwise operations and bitfields opeations of ESC. --- soes/esc.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/soes/esc.c b/soes/esc.c index 5f3f57f..bd23a57 100644 --- a/soes/esc.c +++ b/soes/esc.c @@ -62,7 +62,7 @@ void ESC_ALstatusgotoerror (uint8_t status, uint16_t errornumber) as = ESCvar.ALstatus & ESCREG_AL_ERRACKMASK; an = as; /* Set the state transition, new state in high bits and old in bits */ - as = ((status & ESCREG_AL_ERRACKMASK) << 4) | (as & 0x0f); + as = (uint8_t)(((status & ESCREG_AL_ERRACKMASK) << 4) | (as & 0x0f)); /* Call post state change hook case it have been configured */ if (ESCvar.pre_state_change_hook != NULL) { @@ -170,7 +170,7 @@ void ESC_SMenable (uint8_t n) { _ESCsm2 *sm; sm = (_ESCsm2 *)&ESCvar.SM[n]; - sm->ActPDI &= ~ESCREG_SMENABLE_BIT; + sm->ActPDI &= (uint8_t)~ESCREG_SMENABLE_BIT; ESC_SMwritepdi (n); } /** Write 1 to Bit0 in SM PDI control register 0x807(+ offset to SyncManager n) to De-activte the Sync Manager n. @@ -487,7 +487,7 @@ uint8_t ESC_claimbuffer (void) MBh->address = htoes (0x0000); // destination is master MBh->channel = 0; MBh->priority = 0; - MBh->mbxcnt = ESCvar.mbxcnt; + MBh->mbxcnt = ESCvar.mbxcnt & 0xFU; ESCvar.txcue++; } return n; @@ -601,7 +601,7 @@ uint8_t ESC_mbxprocess (void) ESC_writembx (ESCvar.mbxbackup); } ESCvar.toggle = ESCvar.SM[1].ECrep; - ESCvar.SM[1].PDIrep = ESCvar.toggle; + ESCvar.SM[1].PDIrep = ESCvar.toggle & 0x1U; ESC_SMwritepdi (1); } return 0; @@ -1100,7 +1100,7 @@ void ESC_state (void) } /* Mask high bits ALcommand, low bits ALstatus */ - as = (ac << 4) | (as & 0x0f); + as = (uint8_t)((ac << 4) | (as & 0x0f)); /* Call post state change hook case it have been configured */ if (ESCvar.pre_state_change_hook != NULL)