46 lines
853 B
C
46 lines
853 B
C
/*
|
|
* app.c
|
|
*
|
|
* Created on: Apr 3, 2021
|
|
* Author: Think
|
|
*/
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <math.h>
|
|
#include "app.h"
|
|
#include "stm32f4xx_hal.h"
|
|
#include "CS43L22.h"
|
|
|
|
#define HEARTBEAT 1000
|
|
|
|
extern I2C_HandleTypeDef hi2c1;
|
|
CS43L22 cs43l22;
|
|
|
|
GPIO_InitTypeDef heartBeatLed = {.Pin = GPIO_PIN_13, .Mode = GPIO_MODE_OUTPUT_PP, .Speed = GPIO_SPEED_LOW};
|
|
uint32_t ts_blink = 0;
|
|
uint8_t chipID = 0, revID = 0;
|
|
|
|
|
|
void setup(void)
|
|
{
|
|
HAL_GPIO_Init(GPIOD, &heartBeatLed);
|
|
CS43L22_Init(&cs43l22, &hi2c1);
|
|
}
|
|
|
|
void loop(void)
|
|
{
|
|
if(HAL_GetTick() - ts_blink > HEARTBEAT)
|
|
{
|
|
HAL_GPIO_TogglePin(GPIOD, GPIO_PIN_13);
|
|
|
|
if(!CS43L22_GetDeviceID(&cs43l22, &chipID, &revID))
|
|
printf("Failed to retrieve CS43L22 ID\r\n");
|
|
else
|
|
printf("Device id : %u, revID : %u\r\n", chipID, revID);
|
|
|
|
ts_blink = HAL_GetTick();
|
|
}
|
|
}
|
|
|