void imu_init(void) { /* initialises neutrals */ RATES_ASSIGN(booz_imu.gyro_neutral, IMU_NEUTRAL_GYRO_P, IMU_NEUTRAL_GYRO_Q, IMU_NEUTRAL_GYRO_R); VECT3_ASSIGN(booz_imu.accel_neutral, IMU_NEUTRAL_ACCEL_X, IMU_NEUTRAL_ACCEL_Y, IMU_NEUTRAL_ACCEL_Z); VECT3_ASSIGN(booz_imu.mag_neutral, IMU_NEUTRAL_MAG_X, IMU_NEUTRAL_MAG_Y, IMU_NEUTRAL_MAG_Z); /* initialise IMU alignment */ imu_adjust_alignment(IMU_ALIGNMENT_BODY_TO_IMU_PHI, IMU_ALIGNMENT_BODY_TO_IMU_THETA, IMU_ALIGNMENT_BODY_TO_IMU_PSI); imu_spi_selected = SPI_NONE; do_max1168_read = FALSE; /* setup pins for SSP (SCK, MISO, MOSI) */ PINSEL1 |= SSP_PINSEL1_SCK | SSP_PINSEL1_MISO | SSP_PINSEL1_MOSI; /* setup SSP */ SSPCR0 = SSPCR0_VAL;; SSPCR1 = SSPCR1_VAL; SSPCPSR = 0x02; /* initialize interrupt vector */ VICIntSelect &= ~VIC_BIT( VIC_SPI1 ); /* SPI1 selected as IRQ */ VICIntEnable = VIC_BIT( VIC_SPI1 ); /* enable it */ _VIC_CNTL(SSP_VIC_SLOT) = VIC_ENABLE | VIC_SPI1; _VIC_ADDR(SSP_VIC_SLOT) = (uint32_t)SSP_ISR; /* address of the ISR */ max1168_init(); micromag_init(); }
uint16_t max1168_read_adc(uint8_t reg, enum max1168_clk clk, enum max1168_mode mode) { #define CH2 0x20 uint16_t raw_data; max1168_init(); if (mode == MODE_8BIT) PORTB &= ~(1<<DSEL); else PORTB |= (1<<DSEL); CS_LOW(); /* TODO: remove hardcoded channel */ max1168_xfer_byte(CH2 | clk); if (mode == MODE_16BIT) max1168_xfer_byte(SPI_DUMMY_BYTE); if (clk == CLK_INTERNAL) while ((PINB & (1<<EOC))); raw_data = max1168_xfer_byte(SPI_DUMMY_BYTE) << 8; raw_data |= max1168_xfer_byte(SPI_DUMMY_BYTE); CS_HIGH(); return raw_data; }
void imu_impl_init(void) { max1168_init(); ///////////////////////////////////////////////////////////////////// // HMC58XX hmc58xx_init(&imu_hbmini.hmc, &(IMU_HBMINI_I2C_DEV), HMC58XX_ADDR); }
void imu_impl_init(void) { imu_b2_arch_init(); max1168_init(); #if defined IMU_B2_MAG_TYPE && IMU_B2_MAG_TYPE == IMU_B2_MAG_MS2001 ms2001_init(); #elif defined IMU_B2_MAG_TYPE && IMU_B2_MAG_TYPE == IMU_B2_MAG_AMI601 ami601_init(); #elif defined IMU_B2_MAG_TYPE && IMU_B2_MAG_TYPE == IMU_B2_MAG_HMC5843 hmc5843_init(); #endif }
void imu_impl_init(void) { max1168_init(); ///////////////////////////////////////////////////////////////////// // HMC58XX hmc58xx_init(&imu_hbmini.hmc, &(IMU_HBMINI_I2C_DEV), HMC58XX_ADDR); imu_hbmini.gyr_valid = FALSE; imu_hbmini.acc_valid = FALSE; imu_hbmini.mag_valid = FALSE; }
void imu_impl_init(void) { max1168_init(); #if defined IMU_B2_MAG_TYPE && IMU_B2_MAG_TYPE == IMU_B2_MAG_MS2100 ms2100_init(&ms2100, &(MS2100_SPI_DEV), MS2100_SLAVE_IDX); #elif defined IMU_B2_MAG_TYPE && IMU_B2_MAG_TYPE == IMU_B2_MAG_AMI601 ami601_init(); #elif defined IMU_B2_MAG_TYPE && IMU_B2_MAG_TYPE == IMU_B2_MAG_HMC5843 hmc5843_init(); #elif defined IMU_B2_MAG_TYPE && IMU_B2_MAG_TYPE == IMU_B2_MAG_HMC58XX hmc58xx_init(&imu_b2.mag_hmc, &(IMU_B2_I2C_DEV), HMC58XX_ADDR); #endif }
static inline void main_init( void ) { mcu_init(); sys_time_register_timer((1./PERIODIC_FREQUENCY), NULL); max1168_init(); main_spi2_init(); }
static inline void main_init( void ) { mcu_init(); sys_time_init(); max1168_init(); main_spi2_init(); }