few small changes according to compiler warning

pull/4/head
Mateusz Lubecki 2021-05-26 22:18:11 +02:00
rodzic 15a110694d
commit 5c7d59584d
5 zmienionych plików z 33 dodań i 38 usunięć

Wyświetl plik

@ -30,7 +30,7 @@ typedef enum ms5611_qf {
int32_t ms5611_reset(ms5611_qf_t *qf);
int32_t ms5611_read_calibration(int32_t* cal_data, ms5611_qf_t* qf);
unsigned char crc4(int n_prom[]);
unsigned char crc4(int32_t* n_prom);
int32_t ms5611_trigger_measure(int param_to_meas, int32_t* out);
int32_t ms5611_get_temperature(float* out, ms5611_qf_t* qf);
int32_t ms5611_get_pressure(float* out, ms5611_qf_t *qf);

Wyświetl plik

@ -24,7 +24,7 @@ void beacon_send_own(void) {
}
void beacon_send_on_startup(void) {
main_own_aprs_msg_len = sprintf(main_own_aprs_msg, "> START boot_cnt %#.2x hf_cnt %#.2x hf_pc %#.8x hf_lr %#.8x", rte_main_boot_cycles, rte_main_hard_faults, rte_main_hardfault_pc, rte_main_hardfault_lr);
main_own_aprs_msg_len = sprintf(main_own_aprs_msg, "> START boot_cnt %#.2x hf_cnt %#.2x", (uint16_t)rte_main_boot_cycles, (uint16_t)rte_main_hard_faults);
main_own_aprs_msg[main_own_aprs_msg_len] = 0;
ax25_sendVia(&main_ax25, main_own_path, main_own_path_ln, main_own_aprs_msg, main_own_aprs_msg_len);
after_tx_lock = 1;

Wyświetl plik

@ -72,7 +72,6 @@ int32_t ms5611_read_calibration(int32_t* cal_data, ms5611_qf_t *out) {
int i,j;
int txbuf[2];
int rxbuf[] = {0x00, 0x00};
j = 0;
// Reading calibration constants one after another. Each constant is uint16_t, so a loop iterator
@ -132,7 +131,6 @@ int32_t ms5611_read_calibration(int32_t* cal_data, ms5611_qf_t *out) {
// This is main function to trigger and receive raw value of measuremenets
int32_t ms5611_trigger_measure(int param_to_meas, int32_t* out) {
int txbuf[] = { 0x00, 0x00};
long int output;
if (ms5611_sensor_avaliable == 0) {
return MS5611_SENSOR_NOT_AVALIABLE;
@ -331,35 +329,35 @@ int32_t ms5611_get_pressure(float* out, ms5611_qf_t *qf) {
}
// funkcja obliczaj<61>ca sum<75> kontroln<6C> CRC4 z wsp<73>czynnik<69>w kalibracyjncyh
unsigned char crc4(int n_prom[])
unsigned char crc4(int32_t* n_prom)
{
int cnt; // simple counter
unsigned int n_rem; // crc reminder
unsigned int crc_read; // original value of the crc
unsigned char n_bit;
n_rem = 0x00;
crc_read=n_prom[7]; //save read CRC
n_prom[7]=(0xFF00 & (n_prom[7])); //CRC byte is replaced by 0
for (cnt = 0; cnt < 16; cnt++) // operation is performed on bytes
{// choose LSB or MSB
if (cnt%2==1) n_rem ^= (unsigned short) ((n_prom[cnt>>1]) & 0x00FF);
else n_rem ^= (unsigned short) (n_prom[cnt>>1]>>8);
for (n_bit = 8; n_bit > 0; n_bit--)
{
if (n_rem & (0x8000))
{
n_rem = (n_rem << 1) ^ 0x3000;
}
else
{
n_rem = (n_rem << 1);
}
}
}
n_rem= (0x000F & (n_rem >> 12)); // final 4-bit reminder is CRC code
n_prom[7]=crc_read; // restore the crc_read to its original place
return (n_rem ^ 0x0);
int cnt; // simple counter
unsigned int n_rem; // crc reminder
unsigned int crc_read; // original value of the crc
unsigned char n_bit;
n_rem = 0x00;
crc_read=n_prom[7]; //save read CRC
n_prom[7]=(0xFF00 & (n_prom[7])); //CRC byte is replaced by 0
for (cnt = 0; cnt < 16; cnt++) // operation is performed on bytes
{// choose LSB or MSB
if (cnt%2 == 1) n_rem ^= (unsigned short) ((n_prom[cnt>>1]) & 0x00FF);
else n_rem ^= (unsigned short) (n_prom[cnt>>1]>>8);
for (n_bit = 8; n_bit > 0; n_bit--)
{
if (n_rem & (0x8000))
{
n_rem = (n_rem << 1) ^ 0x3000;
}
else
{
n_rem = (n_rem << 1);
}
}
}
n_rem= (0x000F & (n_rem >> 12)); // final 4-bit reminder is CRC code
n_prom[7]=crc_read; // restore the crc_read to its original place
return (n_rem ^ 0x0);
}

Wyświetl plik

@ -650,10 +650,11 @@ void srl_irq_handler(srl_context_t *ctx) {
switch (ctx->srl_tx_state) {
case SRL_TXING:
if (ctx->srl_tx_bytes_counter < ctx->srl_tx_bytes_req) {
if (ctx->te_port != 0)
if (ctx->te_port != 0) {
GPIO_SetBits(ctx->te_port, ctx->te_pin);
}
ctx->port->DR = ctx->srl_tx_buf_pointer[ctx->srl_tx_bytes_counter++];
ctx->port->DR = ctx->srl_tx_buf_pointer[ctx->srl_tx_bytes_counter++];
}
else {
while((ctx->port->SR & USART_SR_TC) != USART_SR_TC);

Wyświetl plik

@ -61,7 +61,6 @@ void umb_master_init(umb_context_t* ctx, srl_context_t* serial_ctx, const config
umb_retval_t umb_parse_serial_buffer_to_frame(uint8_t* serial_buffer, uint16_t buffer_ln, umb_frame_t* frame) {
uint16_t crc = 0xFFFFu;
uint16_t crc_from_frame;
if (serial_buffer[0] != SOH && serial_buffer[1] != V10)
return UMB_NOT_VALID_FRAME;
@ -88,9 +87,6 @@ umb_retval_t umb_parse_serial_buffer_to_frame(uint8_t* serial_buffer, uint16_t b
frame->payload[i] = serial_buffer[10 + i];
}
// Retrieving the crc value from frame
crc_from_frame = serial_buffer[frame->lenght + 9] | (serial_buffer[frame->lenght + 10] << 8);
// recalculating crc from frame content
for (int j = 0; j <= frame->lenght + 8 + 2; j++) {
crc = umb_calc_crc(crc, serial_buffer[j]);