Select Git revision
Forked from
card10 / firmware
Source project has a limited visibility.
card10.c 5.72 KiB
#include "pmic.h"
#include "bosch.h"
#include "display.h"
#include "portexpander.h"
#include "bhy_uc_driver.h"
#include "Bosch_PCB_7183_di03_BMI160_BMM150-7183_di03.2.1.11696_170103.h"
#include "bme680.h"
#include "bma400.h"
#include "bhy.h"
#include "leds.h"
#include "mxc_config.h"
#include "board.h"
#include "pb.h"
#include "tmr_utils.h"
#include "i2c.h"
#include "rtc.h"
#include "spi.h"
#include "gpio.h"
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#define SPI_SPEED (15 * 1000 * 1000) // Bit Rate
const gpio_cfg_t bhi_interrupt_pin = {
PORT_0, PIN_13, GPIO_FUNC_IN, GPIO_PAD_PULL_UP
};
void card10_init(void)
{
printf("card10 init...\n");
//Setup the I2CM
I2C_Shutdown(MXC_I2C0_BUS0);
I2C_Init(MXC_I2C0_BUS0, I2C_FAST_MODE, NULL);
I2C_Shutdown(MXC_I2C1_BUS0);
I2C_Init(MXC_I2C1_BUS0, I2C_FAST_MODE, NULL);
portexpander_init();
GPIO_Init();
PB_Init();
pmic_init();
pmic_set_led(0, 0);
pmic_set_led(1, 0);
pmic_set_led(2, 0);
TMR_Delay(MXC_TMR0, MSEC(1000), 0);
while (RTC_EnableRTCE(MXC_RTC) == E_BUSY)
;
// Enable 32 kHz output
while (RTC_SquareWave(
MXC_RTC,
SQUARE_WAVE_ENABLED,
F_32KHZ,
NOISE_IMMUNE_MODE,
NULL) == E_BUSY
)
;
/* If we don't have a valid time yet, set it to 2019-01-01 */
if (RTC_GetSecond() < 1546300800UL) {
while (RTC_Init(MXC_RTC, 1546300800UL, 0, NULL) == E_BUSY)