Compare commits

...

2 Commits

Author SHA1 Message Date
Jake Goodwin 59086bd28b added another test 2023-09-11 22:44:01 -07:00
Jake Goodwin 6477248e3b cleaned up the defines 2023-09-11 22:43:56 -07:00
3 changed files with 43 additions and 45 deletions

View File

@ -37,51 +37,6 @@ extern void mock_assert(const int result, const char* const expression,
#endif // UNIT_TESTING
/*
* ############################
* Defines and consts
* ############################
*/
#define NUM_ACCEL_REGS 6
#define NUM_GYRO_REGS 6
/*GYRO MIN MAX PARAMETERS(percentage)*/
#define GYRO_MIN_ST -14
#define GYRO_MAX_ST 14
/*GYRO_CONFIG*/
#define XG_ST (1<<7)
#define YG_ST (1<<6)
#define ZG_ST (1<<5)
#define FS_SEL_MSK 0x18//0b00011000
#define FS_SEL_250 0
#define FS_SEL_500 (1<<3)
#define FS_SEL_1000 (1<<4)
#define FS_SEL_2000 (1<<4)|(1<<3)
/*
* ############################
* Structures
* ############################
*/
struct gy521_module{
uint8_t slave_address;
gyro_values_struct gyro;
accel_values_struct accel;
};
struct ft_vals{
float x;
float y;
float z;
};
/*
* ############################

View File

@ -15,6 +15,25 @@
* ############################
*/
#define NUM_ACCEL_REGS 6
#define NUM_GYRO_REGS 6
/*GYRO MIN MAX PARAMETERS(percentage)*/
#define GYRO_MIN_ST -14
#define GYRO_MAX_ST 14
/*GYRO_CONFIG*/
#define XG_ST (1<<7)
#define YG_ST (1<<6)
#define ZG_ST (1<<5)
#define FS_SEL_MSK 0x18//0b00011000
#define FS_SEL_250 0
#define FS_SEL_500 (1<<3)
#define FS_SEL_1000 (1<<4)
#define FS_SEL_2000 (1<<4)|(1<<3)
/*
* ############################
* Types/Structures
@ -33,6 +52,20 @@ typedef struct accel_values{
uint16_t z;
}accel_values_struct;
struct gy521_module{
uint8_t slave_address;
gyro_values_struct gyro;
accel_values_struct accel;
};
struct ft_vals{
float x;
float y;
float z;
};
/*
* ############################
* REGISTER MAP

View File

@ -351,6 +351,15 @@ static void test_gyro_update(void **state)
assert_true(1);
}
static void test_enable_self_test_gyro(void **state)
{
//expect_value(func, param, val);
/*The read register function should be called with */
expect_value(read_register, reg, 27);
enable_self_test_gyro(*state);
}
int main(void)
{
@ -360,6 +369,7 @@ int main(void)
const struct CMUnitTest twi_group[] = {
cmocka_unit_test_setup_teardown(test_gy521_testing, setup_gy521_instance, teardown_gy521_instance),
cmocka_unit_test_setup_teardown(test_gyro_update, setup_gy521_instance, teardown_gy521_instance),
cmocka_unit_test_setup_teardown(test_enable_self_test_gyro, setup_gy521_instance, teardown_gy521_instance),
};
const struct CMUnitTest tests[] = {
cmocka_unit_test(test_gy521_init),