|
|
|
#include "main.h"
|
|
|
|
#include "system_func.h"
|
|
|
|
#include "struct.h"
|
|
|
|
#include "sw_timer.h"
|
|
|
|
|
|
|
|
#include "app_gpio_led.h"
|
|
|
|
#include "app_gpio_i2c.h"
|
|
|
|
#include "app_i2c_master.h"
|
|
|
|
#include "app_uart.h"
|
|
|
|
#include "ssd1306.h"
|
|
|
|
#include "ak9757w.h"
|
|
|
|
|
|
|
|
|
|
|
|
#include "app_log.h"
|
|
|
|
#include "app_cli.h"
|
|
|
|
|
|
|
|
|
|
|
|
void Test_Process(void)
|
|
|
|
{
|
|
|
|
//AK9757_Check_ChipID();
|
|
|
|
//dbg_printf(LOG_LEVEL_DEBUG, "timer test\r\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
void App_Gpio_I2C_Initialization(uint32_t Frequency);
|
|
|
|
void App_Gpio_I2C_Start(void);
|
|
|
|
bool App_Gpio_I2C_WriteData(uint8_t TxData);
|
|
|
|
bool App_Gpio_I2C_ReadData(uint8_t* pRxData, bool isAck);
|
|
|
|
void App_Gpio_I2C_Stop(void);
|
|
|
|
bool App_Gpio_I2C_Write(uint8_t Address, uint8_t* pWriteData, uint32_t TxSize);
|
|
|
|
bool App_Gpio_I2C_Read(uint8_t Address, uint8_t* pReadData, uint32_t RxSize);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
int main(void)
|
|
|
|
{
|
|
|
|
uint8_t i;
|
|
|
|
bool isAck;
|
|
|
|
ICC_Enable();
|
|
|
|
SystemCoreClockSet(HIRC_96MHZ);
|
|
|
|
|
|
|
|
App_Uart_Initialization();
|
|
|
|
App_Gpio_I2C_Initialization(100000);
|
|
|
|
I2C_Master_Initialization(TEMP_I2C_INSTANCE, I2C_FAST_MODE);
|
|
|
|
App_Led_Initialization();
|
|
|
|
App_CLI_Initialization();
|
|
|
|
|
|
|
|
__enable_irq();
|
|
|
|
App_Led_OutputSet(APP_LED_1, APP_LED_MODE_TOGGLE, 100, 900);
|
|
|
|
SW_Timer_Callback_Register(SW_TIMER_RUN_CONTINUE, 1000,Test_Process );
|
|
|
|
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
|
|
|
|
if(SSD1306_Init(SSD1306_ADDR) != SSD1306_SUCCESS)
|
|
|
|
{
|
|
|
|
printf("ssd1306 init fail\r\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
uint8_t i;
|
|
|
|
SSD1306_NormalScreen (SSD1306_ADDR);
|
|
|
|
SSD1306_ClearScreen ();
|
|
|
|
SSD1306_DrawBackGround_Log();
|
|
|
|
SSD1306_UpdateScreen (SSD1306_ADDR);
|
|
|
|
Delay_ms(1500);
|
|
|
|
SSD1306_InverseScreen (SSD1306_ADDR);
|
|
|
|
Delay_ms(1500);
|
|
|
|
SSD1306_NormalScreen (SSD1306_ADDR);
|
|
|
|
|
|
|
|
for(i = 0 ; i < 128 ; i++)
|
|
|
|
{
|
|
|
|
SSD1306_DrawBackGround_LeftShift(1);
|
|
|
|
if(i % 2 == 0)
|
|
|
|
{
|
|
|
|
SSD1306_UpdateScreen (SSD1306_ADDR);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//Delay_ms(10);
|
|
|
|
}
|
|
|
|
SSD1306_DrawBackGround();
|
|
|
|
SSD1306_UpdateScreen (SSD1306_ADDR);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
SSD1306_NormalScreen (SSD1306_ADDR);
|
|
|
|
SSD1306_ClearScreen (); // clear screen
|
|
|
|
SSD1306_DrawLine (0, MAX_X, 4, 4); // draw line
|
|
|
|
SSD1306_SetPosition (7, 1); // set position
|
|
|
|
SSD1306_DrawString ("SSD1306 OLED DRIVER"); // draw string
|
|
|
|
SSD1306_DrawLine (0, MAX_X, 18, 18); // draw line
|
|
|
|
SSD1306_SetPosition (40, 3); // set position
|
|
|
|
SSD1306_DrawString ("MATIASUS"); // draw string
|
|
|
|
//SSD1306_SetPosition (53, 5); // set position
|
|
|
|
//SSD1306_DrawString ("2021"); // draw string
|
|
|
|
SSD1306_UpdateScreen (SSD1306_ADDR); // update
|
|
|
|
|
|
|
|
|
|
|
|
Delay_ms (1000);
|
|
|
|
SSD1306_InverseScreen (SSD1306_ADDR);
|
|
|
|
|
|
|
|
Delay_ms (1000);
|
|
|
|
|
|
|
|
SSD1306_NormalScreen (SSD1306_ADDR);
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
Delay_ms (1000);
|
|
|
|
SSD1306_InverseScreen (SSD1306_ADDR);
|
|
|
|
|
|
|
|
Delay_ms (1000);
|
|
|
|
|
|
|
|
SSD1306_NormalScreen (SSD1306_ADDR);
|
|
|
|
|
|
|
|
Delay_ms (1000);
|
|
|
|
SSD1306_InverseScreen (SSD1306_ADDR);
|
|
|
|
|
|
|
|
Delay_ms (1000);
|
|
|
|
|
|
|
|
SSD1306_NormalScreen (SSD1306_ADDR);
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
COMPLETE:
|
|
|
|
|
|
|
|
AK9757W_Initialization();
|
|
|
|
|
|
|
|
while(1)
|
|
|
|
{
|
|
|
|
SW_Timer_Callback_Process();
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|