77 lines
1.6 KiB
C
77 lines
1.6 KiB
C
/*
|
|
* helper_impl.c
|
|
* Implementacje funkcji z helper.h (tylko extern, nie inline)
|
|
*/
|
|
|
|
#include "tdefs.h"
|
|
#include "helper.h"
|
|
#include <stdint.h>
|
|
|
|
// Implementacja czy_test_R
|
|
int czy_test_R() {
|
|
return 0;
|
|
}
|
|
|
|
// Implementacja sprawdz_P
|
|
void sprawdz_P(u8 *Wy, u8 P, u8 O, short *lp, short iz, short io) {
|
|
if (O) {
|
|
*Wy = 0;
|
|
*lp = 0;
|
|
} else if (P) {
|
|
if (*lp < iz) (*lp)++;
|
|
if (*lp >= iz) *Wy = 1;
|
|
} else {
|
|
if (*lp > 0) (*lp)--;
|
|
if (*lp == 0) *Wy = 0;
|
|
}
|
|
}
|
|
|
|
// Implementacja sprawdz_P_100 (używana w wielu miejscach)
|
|
void sprawdz_P_100(u8 *Wy, u8 P, u8 O, short *lp, short iz, short io) {
|
|
sprawdz_P(Wy, P, O, lp, iz, io);
|
|
}
|
|
|
|
// Implementacja set_bit_ptr_struct
|
|
int set_bit_ptr_struct(u32 io, struct binary_io *b) {
|
|
if (!b || !b->ptr) return 0;
|
|
if (io) {
|
|
*b->ptr |= b->bit_mask;
|
|
} else {
|
|
*b->ptr &= ~b->bit_mask;
|
|
}
|
|
return 1;
|
|
}
|
|
|
|
int set_float_ptr(u32 io,void *float_ptr)
|
|
{
|
|
float *fptr;
|
|
|
|
// fptr = (float *)(log_manager.nets_data + (io >> 3));
|
|
// if((u8 *)fptr > (log_manager.nets_data + sizeof(log_manager.nets_data) - sizeof(float)))
|
|
// return -1;
|
|
|
|
*(u32 *)float_ptr=(u32)fptr;
|
|
|
|
return 0;
|
|
}
|
|
|
|
int set_pointer_in_ptr(u32 io, u32 *pointer_ptr)
|
|
{
|
|
u32 *f_ptr;
|
|
|
|
f_ptr = (u32 *)(log_manager.nets_data + (io >> 3));
|
|
if((u8 *)f_ptr > (log_manager.nets_data+sizeof(log_manager.nets_data) - sizeof(void *)))
|
|
return -1;
|
|
|
|
if((u32)f_ptr == (u32)&log_manager.nets_data[0]) // if pointer connected to net '0'
|
|
*(u32 *)pointer_ptr=(u32)f_ptr;
|
|
else
|
|
*(u32 *)pointer_ptr=(u32)*f_ptr;
|
|
|
|
if(!*f_ptr)
|
|
return -1;
|
|
|
|
return 0;
|
|
}
|
|
|