该设计采用灵动EVB-L0136/MM32L0136C7P为主控芯片,最高工作频率可达 48MHz,内置高速存储器,丰富的增强型 I/O 端口和多种外设。
收音机采用SI4730,是Silicon Labs公司推出的高集成度AM/FM收音机芯片Si4730的外围电路非常简单, Si4730提供了3种控制方式:2线模式(兼容I2C总线)、SPI模式、3线模式。芯片通过RST引脚上升沿时GP01与GP02的引脚状态来决定采用哪种方式,当GP01与GP02悬空时Si4730为2线模式。SEN引脚接高电平时,器件地址为0xC6H;接低电平时,地址为0x22H。
#include"board_init.h"
//*******************************
voidDelay(uint32_t t);
//*******************************
//12832接口定义
#defineF_IIC8_SDA_H() GPIO_WriteBit(FM_SDA_GPIO_PORT, FM_SDA_GPIO_PIN,1u)
#defineF_IIC8_SDA_L() GPIO_WriteBit(FM_SDA_GPIO_PORT, FM_SDA_GPIO_PIN,0u)
#defineF_IIC8_SCL_H() GPIO_WriteBit(FM_SCL_GPIO_PORT, FM_SCL_GPIO_PIN,1u)
#defineF_IIC8_SCL_L() GPIO_WriteBit(FM_SCL_GPIO_PORT, FM_SCL_GPIO_PIN,0u)
#defineF_RST_H() GPIO_WriteBit(FM_RST_GPIO_PORT, FM_RST_GPIO_PIN,1u)
#defineF_RST_L() GPIO_WriteBit(FM_RST_GPIO_PORT, FM_RST_GPIO_PIN,0u)
//*******************************
//发送接收缓冲区定义
#defineF_DeviceAddress 0XC6   //地址
uint8_tF_IIC8_WRITE_DATA[5];//写数据
uint8_tF_IIC8_READ_DATA[5];//读数据
//*******************************
voidF_Delay(void)
{
   Delay(10);
}
//****************************************
voidF_IIC8_Start()
{
   F_IIC8_SDA_H();F_Delay();//数据线保持高
   F_IIC8_SCL_H();F_Delay();
   F_IIC8_SDA_L();F_Delay();//数据线保持低,时钟线从高到低一次跳变,I2C通信开始
   F_IIC8_SCL_L();F_Delay();
}
//*******************************
voidF_IIC8_Stop()
{
   F_IIC8_SCL_L();F_Delay();
   F_IIC8_SDA_L();F_Delay();
   F_IIC8_SCL_H();F_Delay();//数据线保持低,时钟线从低到高一次跳变,I2C通信停止
   F_IIC8_SDA_H();F_Delay();
}
//*******************************
//等待从器件接收方的应答
voidF_IIC8_WaitAck()
{
   F_IIC8_SDA_H();F_Delay();
   F_IIC8_SCL_H();F_Delay();
   F_IIC8_SCL_L();F_Delay();
}
//*******************************
voidF_IIC8_SendByte(uint8_t Ch)
{
uint8_ti=0;
   for(i=0;i<8;i++)
   {
      F_IIC8_SCL_L();F_Delay();
      if(Ch&0x80)
      {
         F_IIC8_SDA_H();F_Delay();
      }
      else
      {
         F_IIC8_SDA_L();F_Delay();
      }
      F_IIC8_SCL_H();F_Delay();
      Ch=Ch<<1;
   }
   F_IIC8_SCL_L();F_Delay();
}
//*******************************
//写数据
voidF_IIC8_Write(uint8_t RomAddress,uint8_t *Wdata,uint8_t Num)
{
uint8_ti=0;
   F_IIC8_Start();
   F_IIC8_SendByte(F_DeviceAddress);//地址
   F_IIC8_WaitAck();
   F_IIC8_SendByte(RomAddress);//地址1
   F_IIC8_WaitAck();
   for(i=0;i<Num;i++)
   {
      F_IIC8_SendByte(Wdata);
      F_IIC8_WaitAck();
   }
   F_IIC8_Stop();
}
//***************************************
voidFM_Init(void)
{
   F_RST_L();
   Delay(5000);
   F_IIC8_SDA_H();
   F_IIC8_SCL_H();
   Delay(5000);
   F_RST_H();
   Delay(5000);
}
//***************************************
voidWrite_Freq(uint16_t freq)
{
uint8_ti=0;
F_IIC8_WRITE_DATA[0]=0xD0;F_IIC8_WRITE_DATA[1]=0x05;F_IIC8_Write(0x01,F_IIC8_WRITE_DATA,2);for(i=0;i<20;i++){Delay(50000);}
   F_IIC8_WRITE_DATA[0]=0;
   F_IIC8_WRITE_DATA[1]=((uint8_t)((freq>>8)&0x00ff));
   F_IIC8_WRITE_DATA[2]=((uint8_t)(freq&0x00ff));
   F_IIC8_WRITE_DATA[3]=0;F_IIC8_Write(0x20,F_IIC8_WRITE_DATA,4);Delay(50);
}
显示单元采用0.91寸OLED显示屏DIS12832,程序如下:
#include"board_init.h"
//*******************************
voidDelay(uint32_t t);
//*******************************
//12832接口定义
#defineIIC8_SDA_H() GPIO_WriteBit(DIS_SDA_GPIO_PORT, DIS_SDA_GPIO_PIN,1u)
#defineIIC8_SDA_L() GPIO_WriteBit(DIS_SDA_GPIO_PORT, DIS_SDA_GPIO_PIN,0u)
#defineIIC8_SCL_H() GPIO_WriteBit(DIS_SCL_GPIO_PORT, DIS_SCL_GPIO_PIN,1u)
#defineIIC8_SCL_L() GPIO_WriteBit(DIS_SCL_GPIO_PORT, DIS_SCL_GPIO_PIN,0u)
//*******************************
//发送接收缓冲区定义
#defineDeviceAddress 0x78   //地址
uint8_tIIC8_WRITE_DATA;//写数据
uint8_tIIC8_READ_DATA;//读数据
//*******************************
constuint8_t F8X16[]=     
{
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//0
0x00,0x00,0x00,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x33,0x30,0x00,0x00,0x00,//!1
0x00,0x10,0x0C,0x06,0x10,0x0C,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//"2
0x40,0xC0,0x78,0x40,0xC0,0x78,0x40,0x00,0x04,0x3F,0x04,0x04,0x3F,0x04,0x04,0x00,//#3
0x00,0x70,0x88,0xFC,0x08,0x30,0x00,0x00,0x00,0x18,0x20,0xFF,0x21,0x1E,0x00,0x00,//$4
0xF0,0x08,0xF0,0x00,0xE0,0x18,0x00,0x00,0x00,0x21,0x1C,0x03,0x1E,0x21,0x1E,0x00,//%5
0x00,0xF0,0x08,0x88,0x70,0x00,0x00,0x00,0x1E,0x21,0x23,0x24,0x19,0x27,0x21,0x10,//&6
0x10,0x16,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//'7
0x00,0x00,0x00,0xE0,0x18,0x04,0x02,0x00,0x00,0x00,0x00,0x07,0x18,0x20,0x40,0x00,//(8
0x00,0x02,0x04,0x18,0xE0,0x00,0x00,0x00,0x00,0x40,0x20,0x18,0x07,0x00,0x00,0x00,//)9
0x40,0x40,0x80,0xF0,0x80,0x40,0x40,0x00,0x02,0x02,0x01,0x0F,0x01,0x02,0x02,0x00,//*10
0x00,0x00,0x00,0xF0,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x1F,0x01,0x01,0x01,0x00,//+11
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xB0,0x70,0x00,0x00,0x00,0x00,0x00,//,12
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,//-13
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,0x00,0x00,//.14
0x00,0x00,0x00,0x00,0x80,0x60,0x18,0x04,0x00,0x60,0x18,0x06,0x01,0x00,0x00,0x00,///15
0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00,//016
  0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//117
0x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00,//218
0x00,0x30,0x08,0x88,0x88,0x48,0x30,0x00,0x00,0x18,0x20,0x20,0x20,0x11,0x0E,0x00,//319
  0x00,0x00,0xC0,0x20,0x10,0xF8,0x00,0x00,0x00,0x07,0x04,0x24,0x24,0x3F,0x24,0x00,//420
0x00,0xF8,0x08,0x88,0x88,0x08,0x08,0x00,0x00,0x19,0x21,0x20,0x20,0x11,0x0E,0x00,//521
0x00,0xE0,0x10,0x88,0x88,0x18,0x00,0x00,0x00,0x0F,0x11,0x20,0x20,0x11,0x0E,0x00,//622
0x00,0x38,0x08,0x08,0xC8,0x38,0x08,0x00,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00,//723
0x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,0x00,0x1C,0x22,0x21,0x21,0x22,0x1C,0x00,//824
0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x00,0x31,0x22,0x22,0x11,0x0F,0x00,//925
0x00,0x00,0x00,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,//:26
0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x60,0x00,0x00,0x00,0x00,//;27
0x00,0x00,0x80,0x40,0x20,0x10,0x08,0x00,0x00,0x01,0x02,0x04,0x08,0x10,0x20,0x00,//<28
0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x00,//=29
0x00,0x08,0x10,0x20,0x40,0x80,0x00,0x00,0x00,0x20,0x10,0x08,0x04,0x02,0x01,0x00,//>30
0x00,0x70,0x48,0x08,0x08,0x08,0xF0,0x00,0x00,0x00,0x00,0x30,0x36,0x01,0x00,0x00,//?31
0xC0,0x30,0xC8,0x28,0xE8,0x10,0xE0,0x00,0x07,0x18,0x27,0x24,0x23,0x14,0x0B,0x00,//@32
0x00,0x00,0xC0,0x38,0xE0,0x00,0x00,0x00,0x20,0x3C,0x23,0x02,0x02,0x27,0x38,0x20,//A33
  0x08,0xF8,0x88,0x88,0x88,0x70,0x00,0x00,0x20,0x3F,0x20,0x20,0x20,0x11,0x0E,0x00,//B34
0xC0,0x30,0x08,0x08,0x08,0x08,0x38,0x00,0x07,0x18,0x20,0x20,0x20,0x10,0x08,0x00,//C35
0x08,0xF8,0x08,0x08,0x08,0x10,0xE0,0x00,0x20,0x3F,0x20,0x20,0x20,0x10,0x0F,0x00,//D36
  0x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,0x20,0x3F,0x20,0x20,0x23,0x20,0x18,0x00,//E37
0x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,0x20,0x3F,0x20,0x00,0x03,0x00,0x00,0x00,//F38
0xC0,0x30,0x08,0x08,0x08,0x38,0x00,0x00,0x07,0x18,0x20,0x20,0x22,0x1E,0x02,0x00,//G39
  0x08,0xF8,0x08,0x00,0x00,0x08,0xF8,0x08,0x20,0x3F,0x21,0x01,0x01,0x21,0x3F,0x20,//H40
0x00,0x08,0x08,0xF8,0x08,0x08,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//I41
0x00,0x00,0x08,0x08,0xF8,0x08,0x08,0x00,0xC0,0x80,0x80,0x80,0x7F,0x00,0x00,0x00,//J42
  0x08,0xF8,0x88,0xC0,0x28,0x18,0x08,0x00,0x20,0x3F,0x20,0x01,0x26,0x38,0x20,0x00,//K43
0x08,0xF8,0x08,0x00,0x00,0x00,0x00,0x00,0x20,0x3F,0x20,0x20,0x20,0x20,0x30,0x00,//L44
0x08,0xF8,0xF8,0x00,0xF8,0xF8,0x08,0x00,0x20,0x3F,0x00,0x3F,0x00,0x3F,0x20,0x00,//M45
  0x08,0xF8,0x30,0xC0,0x00,0x08,0xF8,0x08,0x20,0x3F,0x20,0x00,0x07,0x18,0x3F,0x00,//N46
0xE0,0x10,0x08,0x08,0x08,0x10,0xE0,0x00,0x0F,0x10,0x20,0x20,0x20,0x10,0x0F,0x00,//O47
0x08,0xF8,0x08,0x08,0x08,0x08,0xF0,0x00,0x20,0x3F,0x21,0x01,0x01,0x01,0x00,0x00,//P48
0xE0,0x10,0x08,0x08,0x08,0x10,0xE0,0x00,0x0F,0x18,0x24,0x24,0x38,0x50,0x4F,0x00,//Q49
0x08,0xF8,0x88,0x88,0x88,0x88,0x70,0x00,0x20,0x3F,0x20,0x00,0x03,0x0C,0x30,0x20,//R50
0x00,0x70,0x88,0x08,0x08,0x08,0x38,0x00,0x00,0x38,0x20,0x21,0x21,0x22,0x1C,0x00,//S51
0x18,0x08,0x08,0xF8,0x08,0x08,0x18,0x00,0x00,0x00,0x20,0x3F,0x20,0x00,0x00,0x00,//T52
0x08,0xF8,0x08,0x00,0x00,0x08,0xF8,0x08,0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00,//U53
0x08,0x78,0x88,0x00,0x00,0xC8,0x38,0x08,0x00,0x00,0x07,0x38,0x0E,0x01,0x00,0x00,//V54
0xF8,0x08,0x00,0xF8,0x00,0x08,0xF8,0x00,0x03,0x3C,0x07,0x00,0x07,0x3C,0x03,0x00,//W55
0x08,0x18,0x68,0x80,0x80,0x68,0x18,0x08,0x20,0x30,0x2C,0x03,0x03,0x2C,0x30,0x20,//X56
0x08,0x38,0xC8,0x00,0xC8,0x38,0x08,0x00,0x00,0x00,0x20,0x3F,0x20,0x00,0x00,0x00,//Y57
0x10,0x08,0x08,0x08,0xC8,0x38,0x08,0x00,0x20,0x38,0x26,0x21,0x20,0x20,0x18,0x00,//Z58
0x00,0x00,0x00,0xFE,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x7F,0x40,0x40,0x40,0x00,//[59
0x00,0x0C,0x30,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x06,0x38,0xC0,0x00,//\60
0x00,0x02,0x02,0x02,0xFE,0x00,0x00,0x00,0x00,0x40,0x40,0x40,0x7F,0x00,0x00,0x00,//]61
  0x00,0x00,0x04,0x02,0x02,0x02,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//^62
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,//_63
0x00,0x02,0x02,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//`64
  0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x19,0x24,0x22,0x22,0x22,0x3F,0x20,//a65
0x08,0xF8,0x00,0x80,0x80,0x00,0x00,0x00,0x00,0x3F,0x11,0x20,0x20,0x11,0x0E,0x00,//b66
0x00,0x00,0x00,0x80,0x80,0x80,0x00,0x00,0x00,0x0E,0x11,0x20,0x20,0x20,0x11,0x00,//c67
  0x00,0x00,0x00,0x80,0x80,0x88,0xF8,0x00,0x00,0x0E,0x11,0x20,0x20,0x10,0x3F,0x20,//d68
0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x1F,0x22,0x22,0x22,0x22,0x13,0x00,//e69
0x00,0x80,0x80,0xF0,0x88,0x88,0x88,0x18,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//f70
  0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x6B,0x94,0x94,0x94,0x93,0x60,0x00,//g71
0x08,0xF8,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x3F,0x21,0x00,0x00,0x20,0x3F,0x20,//h72
0x00,0x80,0x98,0x98,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//i73
  0x00,0x00,0x00,0x80,0x98,0x98,0x00,0x00,0x00,0xC0,0x80,0x80,0x80,0x7F,0x00,0x00,//j74
0x08,0xF8,0x00,0x00,0x80,0x80,0x80,0x00,0x20,0x3F,0x24,0x02,0x2D,0x30,0x20,0x00,//k75
0x00,0x08,0x08,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//l76
0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x20,0x3F,0x20,0x00,0x3F,0x20,0x00,0x3F,//m77
0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x3F,0x21,0x00,0x00,0x20,0x3F,0x20,//n78
0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00,//o79
0x80,0x80,0x00,0x80,0x80,0x00,0x00,0x00,0x80,0xFF,0xA1,0x20,0x20,0x11,0x0E,0x00,//p80
0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x0E,0x11,0x20,0x20,0xA0,0xFF,0x80,//q81
0x80,0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x20,0x20,0x3F,0x21,0x20,0x00,0x01,0x00,//r82
0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x33,0x24,0x24,0x24,0x24,0x19,0x00,//s83
0x00,0x80,0x80,0xE0,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x1F,0x20,0x20,0x00,0x00,//t84
0x80,0x80,0x00,0x00,0x00,0x80,0x80,0x00,0x00,0x1F,0x20,0x20,0x20,0x10,0x3F,0x20,//u85
0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,0x00,0x01,0x0E,0x30,0x08,0x06,0x01,0x00,//v86
0x80,0x80,0x00,0x80,0x00,0x80,0x80,0x80,0x0F,0x30,0x0C,0x03,0x0C,0x30,0x0F,0x00,//w87
0x00,0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x31,0x2E,0x0E,0x31,0x20,0x00,//x88
0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,0x80,0x81,0x8E,0x70,0x18,0x06,0x01,0x00,//y89
  0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x21,0x30,0x2C,0x22,0x21,0x30,0x00,//z90
0x00,0x00,0x00,0x00,0x80,0x7C,0x02,0x02,0x00,0x00,0x00,0x00,0x00,0x3F,0x40,0x40,//{91
0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,//|92
  0x00,0x02,0x02,0x7C,0x80,0x00,0x00,0x00,0x00,0x40,0x40,0x3F,0x00,0x00,0x00,0x00,//}93
0x00,0x06,0x01,0x01,0x02,0x02,0x04,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//~94
};
//****************************************
constuint8_t Number_16_32[][32]=
{
{0x00,0x00,0x80,0x40,0x40,0x80,0x00,0x00,0x00,0xFC,0x03,0x00,0x00,0x03,0xFC,0x00},
{0x00,0x7F,0x80,0x00,0x00,0x80,0x7F,0x00,0x00,0x00,0x03,0x04,0x04,0x03,0x00,0x00},/*"0",0*/
/* (8X 32 , 宋体 )*/
{0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0xFF,0x00,0x00,0x00,0x00},
{0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x04,0x04,0x07,0x04,0x04,0x00,0x00},/*"1",1*/
/* (8X 32 , 宋体 )*/
{0x00,0x80,0x80,0x40,0x40,0xC0,0x00,0x00,0x00,0x1F,0x00,0x00,0x00,0x80,0x7F,0x00},
{0x00,0x00,0xE0,0x18,0x06,0x01,0xC0,0x00,0x00,0x07,0x06,0x06,0x06,0x06,0x07,0x00},/*"2",2*/
/* (8X 32 , 宋体 )*/
{0x00,0x80,0x80,0x40,0x40,0x80,0x00,0x00,0x00,0x0F,0x00,0x80,0x80,0x60,0x1F,0x00},
{0x00,0xE0,0x00,0x00,0x00,0x03,0xFC,0x00,0x00,0x03,0x04,0x04,0x04,0x03,0x00,0x00},/*"3",3*/
/* (8X 32 , 宋体 )*/
{0x00,0x00,0x00,0x00,0x00,0xC0,0x00,0x00,0x00,0x00,0xE0,0x1C,0x03,0xFF,0x00,0x00},
{0x00,0x1F,0x10,0x10,0x10,0xFF,0x10,0x00,0x00,0x00,0x00,0x08,0x0C,0x0F,0x08,0x00},/*"4",4*/
/* (8X 32 , 宋体 )*/
{0x00,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0x00,0x00,0xFF,0x40,0x20,0x20,0xC0,0x00,0x00},
{0x00,0xE1,0x00,0x00,0x00,0x80,0x7F,0x00,0x00,0x03,0x04,0x04,0x04,0x03,0x00,0x00},/*"5",5*/
/* (8X 32 , 宋体 )*/
{0x00,0x00,0x80,0x40,0x40,0x80,0x00,0x00,0x00,0xFE,0x81,0x40,0x40,0x83,0x00,0x00},
{0x00,0xFF,0x01,0x00,0x00,0x01,0xFE,0x00,0x00,0x00,0x03,0x04,0x06,0x01,0x00,0x00},/*"6",6*/
/* (8X 32 , 宋体 )*/
{0x00,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0x00,0x00,0x07,0x00,0x00,0xF0,0x0F,0x00,0x00},
{0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x00},/*"7",7*/
/* (8X 32 , 宋体 )*/
{0x00,0x00,0x80,0x40,0x40,0x80,0x00,0x00,0x00,0x3F,0xE0,0x80,0x80,0x40,0x3F,0x00},
{0x00,0xF8,0x06,0x01,0x03,0x06,0xF8,0x00,0x00,0x01,0x02,0x04,0x04,0x02,0x01,0x00},/*"8",8*/
/* (8X 32 , 宋体 )*/
{0x00,0x00,0x80,0x40,0xC0,0x00,0x00,0x00,0x00,0xFE,0x01,0x00,0x00,0x03,0xFC,0x00},
{0x00,0x01,0x82,0x04,0x06,0xC1,0x3F,0x00,0x00,0x00,0x03,0x04,0x04,0x03,0x00,0x00},/*"9",9*/
/* (8X 32 , 宋体 )*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
{0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"-",10*/
/* (8X 32 , 宋体 )*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
{0x00,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x07,0x00,0x00,0x00,0x00,0x00},/*".",11*/
/* (8X 32 , 宋体 )*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"",12*/
/* (8X 32 , 宋体 )*/
};
//****************************************
voidIIC8_Start()
{
   IIC8_SDA_H();Delay(1);//数据线保持高
   IIC8_SCL_H();Delay(1);
   IIC8_SDA_L();Delay(1);//数据线保持低,时钟线从高到低一次跳变,I2C通信开始
   IIC8_SCL_L();Delay(1);
}
//*******************************
voidIIC8_Stop()
{
   IIC8_SCL_L();Delay(1);
   IIC8_SDA_L();Delay(1);
   IIC8_SCL_H();Delay(1);//数据线保持低,时钟线从低到高一次跳变,I2C通信停止
   IIC8_SDA_H();Delay(1);
}
//*******************************
//等待从器件接收方的应答
voidIIC8_WaitAck()
{
   IIC8_SDA_H();Delay(1);
   IIC8_SCL_H();Delay(1);
   IIC8_SCL_L();Delay(1);
}
//*******************************
voidIIC8_SendByte(uint8_t Ch)
{
uint8_ti=0;
   for(i=0;i<8;i++)
   {
      IIC8_SCL_L();Delay(1);
      if(Ch&0x80)
      {
         IIC8_SDA_H();Delay(1);
      }
      else
      {
         IIC8_SDA_L();Delay(1);
      }
      IIC8_SCL_H();Delay(1);
      Ch=Ch<<1;
   }
   IIC8_SCL_L();Delay(1);
}
//*******************************
//写数据
voidIIC8_Write(uint8_t RomAddress,uint8_t Wdata)
{
uint8_ti=0;
   IIC8_Start();
   IIC8_SendByte(DeviceAddress);//命令
   IIC8_WaitAck();
   IIC8_SendByte(RomAddress);//地址
   IIC8_WaitAck();
   IIC8_SendByte(Wdata);
   IIC8_WaitAck();
   IIC8_Stop();
}
//***************************************
voidOLED_Clear(void)  
{  
uint8_ti,n;      
   for(i=0;i<8;i++)  
   {  
      IIC8_WRITE_DATA=0xb0+i;IIC8_Write(0x00,IIC8_WRITE_DATA);
      IIC8_WRITE_DATA=0x00;IIC8_Write(0x00,IIC8_WRITE_DATA);
      IIC8_WRITE_DATA=0x10;IIC8_Write(0x00,IIC8_WRITE_DATA);
      for(n=0;n<128;n++)
      {
         IIC8_WRITE_DATA=0x00;IIC8_Write(0x40,IIC8_WRITE_DATA);
      }
   } //更新显示
}
//***********************************************
voidOLED_Set_Pos(unsigned char x, unsigned char y)
{  
   IIC8_WRITE_DATA=0xb0+y;IIC8_Write(0x00,IIC8_WRITE_DATA);
   IIC8_WRITE_DATA=((x&0xf0)>>4)|0x10;IIC8_Write(0x00,IIC8_WRITE_DATA);
   IIC8_WRITE_DATA=(x&0x0f);IIC8_Write(0x00,IIC8_WRITE_DATA);
}
//***********************************************
//开启OLED显示   
voidOLED_Display_On(void)
{
   IIC8_WRITE_DATA=0X8D;IIC8_Write(0x00,IIC8_WRITE_DATA);  //SET DCDC命令
   IIC8_WRITE_DATA=0X14;IIC8_Write(0x00,IIC8_WRITE_DATA);  //DCDC ON
   IIC8_WRITE_DATA=0XAF;IIC8_Write(0x00,IIC8_WRITE_DATA);//打开显示
}
//***********************************************
//关闭OLED显示     
voidOLED_Display_Off(void)
{
   IIC8_WRITE_DATA=0X8D;IIC8_Write(0x00,IIC8_WRITE_DATA);  //SET DCDC命令
   IIC8_WRITE_DATA=0X10;IIC8_Write(0x00,IIC8_WRITE_DATA);  //DCDC OFF
   IIC8_WRITE_DATA=0XAE;IIC8_Write(0x00,IIC8_WRITE_DATA);//关闭显示
}     
//***********************************************
//在指定位置显示一个字符,包括部分字符
//x:0~127
//y:0~63或0-32
voidOLED_ShowChar(uint8_t x,uint8_t y,uint8_t chr)
{        
uint8_tc=0,i=0;   
   c=chr-' ';//得到偏移后的值        
   if(x>128-1){x=0;y=y+2;}
   OLED_Set_Pos(x,y);
   for(i=0;i<8;i++)
   {
      IIC8_WRITE_DATA=F8X16[c*16+i];IIC8_Write(0x40,IIC8_WRITE_DATA);
   }
   OLED_Set_Pos(x,y+1);
   for(i=0;i<8;i++)
   {
      IIC8_WRITE_DATA=F8X16[c*16+i+8];IIC8_Write(0x40,IIC8_WRITE_DATA);
   }
}
//***********************************************
voidOLED_Show_Num(uint8_t x,uint8_t y,uint8_t No)
{                  
uint8_tt;
   OLED_Set_Pos(x,y);
   for(t=0;t<8;t++)
   {
      IIC8_WRITE_DATA=Number_16_32[2*No][t];IIC8_Write(0x40,IIC8_WRITE_DATA);
   }  
   OLED_Set_Pos(x,y+1);  
   for(t=8;t<16;t++)
   {  
      IIC8_WRITE_DATA=Number_16_32[2*No][t];IIC8_Write(0x40,IIC8_WRITE_DATA);
   }     
   OLED_Set_Pos(x,y+2);  
   for(t=0;t<8;t++)
   {  
      IIC8_WRITE_DATA=Number_16_32[2*No+1][t];IIC8_Write(0x40,IIC8_WRITE_DATA);
   }  
   OLED_Set_Pos(x,y+3);  
   for(t=8;t<16;t++)
   {  
      IIC8_WRITE_DATA=Number_16_32[2*No+1][t];IIC8_Write(0x40,IIC8_WRITE_DATA);
   }        
      
}
//***********************************************
voidOLED_Show(uint16_t Temp)
{
uint8_tNum_Temp=0;      
   Num_Temp=(uint8_t)((Temp/10000)%10);
   if(Num_Temp==0){OLED_Show_Num(40,0,12);}else{OLED_Show_Num(40,0,Num_Temp);}
   
   Num_Temp=(uint8_t)((Temp/1000)%10);OLED_Show_Num(48,0,Num_Temp);
   Num_Temp=(uint8_t)((Temp/100)%10);OLED_Show_Num(56,0,Num_Temp);
   OLED_Show_Num(64,0,11);
   Num_Temp=(uint8_t)((Temp/10)%10);OLED_Show_Num(72,0,Num_Temp);
}
//***********************************************
voidOLED_Init(void)
{  
   //地址0x00:是command,0x40:是data
   IIC8_WRITE_DATA=0xAE;IIC8_Write(0x00,IIC8_WRITE_DATA);//0xAE:关闭显示,0XAF,打开显示
   IIC8_WRITE_DATA=0x00;IIC8_Write(0x00,IIC8_WRITE_DATA);//---setlow column address
   IIC8_WRITE_DATA=0x10;IIC8_Write(0x00,IIC8_WRITE_DATA);//---sethigh column address
   IIC8_WRITE_DATA=0X40;IIC8_Write(0x00,IIC8_WRITE_DATA);//--setstart line address  Set Mapping RAMDisplay Start Line (0x00~0x3F)
   IIC8_WRITE_DATA=0X81;IIC8_Write(0x00,IIC8_WRITE_DATA);   IIC8_WRITE_DATA=0X7f;IIC8_Write(0x00,IIC8_WRITE_DATA);//对比度设置0x00-0xff
   IIC8_WRITE_DATA=0XA6;IIC8_Write(0x00,IIC8_WRITE_DATA);//0XA6:正常显示,0XA7,反相显示
  IIC8_WRITE_DATA=0xB0;IIC8_Write(0x00,IIC8_WRITE_DATA);//设置行地址从0开始,12832:范围0xb0-0xb3;12832:范围0xb0-0xb7
   IIC8_WRITE_DATA=0XA1;IIC8_Write(0x00,IIC8_WRITE_DATA);//--SetSEG/Column Mapping     0xa0左右反置 0xa1正常
   IIC8_WRITE_DATA=0XC8;IIC8_Write(0x00,IIC8_WRITE_DATA);//SetCOM/Row Scan Direction   0xc0上下反置 0xc8正常
IIC8_WRITE_DATA=0XA8;IIC8_Write(0x00,IIC8_WRITE_DATA);IIC8_WRITE_DATA=0X1F;IIC8_Write(0x00,IIC8_WRITE_DATA);   //驱动路数;12832:0x1f,12864,0x3f
IIC8_WRITE_DATA=0XD3;IIC8_Write(0x00,IIC8_WRITE_DATA);IIC8_WRITE_DATA=0X00;IIC8_Write(0x00,IIC8_WRITE_DATA);//-setdisplay offset  Shift Mapping RAM Counter(0x00~0x3F) ,0x00://-not offset
IIC8_WRITE_DATA=0XD5;IIC8_Write(0x00,IIC8_WRITE_DATA);IIC8_WRITE_DATA=0X80;IIC8_Write(0x00,IIC8_WRITE_DATA);//--setdisplay clock divide ratio/oscillatorfrequency//--set divide ratio, Set Clockas 100 Frames/Sec
IIC8_WRITE_DATA=0XD9;IIC8_Write(0x00,IIC8_WRITE_DATA);IIC8_WRITE_DATA=0X22;IIC8_Write(0x00,IIC8_WRITE_DATA);//--setpre-charge period//Set Pre-Charge as 15 Clocks & Discharge as 1 Clock
IIC8_WRITE_DATA=0XDA;IIC8_Write(0x00,IIC8_WRITE_DATA);IIC8_WRITE_DATA=0X02;IIC8_Write(0x00,IIC8_WRITE_DATA);//--setcom pins hardware configuration 12832:0x02,12864,0x12
IIC8_WRITE_DATA=0XDB;IIC8_Write(0x00,IIC8_WRITE_DATA);IIC8_WRITE_DATA=0X40;IIC8_Write(0x00,IIC8_WRITE_DATA);//--setvcomh//Set VCOM Deselect Level
   IIC8_WRITE_DATA=0XA4;IIC8_Write(0x00,IIC8_WRITE_DATA);//Disable Entire Display On (0xa4/0xa5)
   OLED_Display_On();
   OLED_Clear();
}
//***********************************************
收音机测试函数如下:
#include"board_init.h"
voidDelay(uint32_t t);
//*******************************
voidOLED_ShowChar(uint8_t x,uint8_t y,uint8_t chr);
voidOLED_Show(uint16_t Temp);
voidOLED_Init(void);
//***************************************************************************************************
voidFM_Init(void);
voidWrite_Freq(uint16_t freq);
//***************************************************************************************************
voidMain_Init(void);
voidMainProgram(void);
//***************************************************************************************************
uint16_tFreq;
uint16_tFreq_Change;
//***************************************************************************************************
voidMain_Init(void)
{
   Delay(10000);
   FM_Init();
   OLED_Init();
   OLED_ShowChar(8,0,'F');//F
   OLED_ShowChar(16,0,'M');//M
   OLED_ShowChar(88,2,'M');//M
   OLED_ShowChar(96,2,'H');//H
   OLED_ShowChar(104,2,'z');//z
      Freq=9000;//调整FM频率
}
//***************************************************************************************************
voidMainProgram(void)
{
   if(Freq_Change!=Freq)
   {
      Freq_Change=Freq;
      OLED_Show(Freq);
      Write_Freq(Freq);
   }
   
}
//***************************************************************************************************
主函数如下:
/*
* Copyright 2022 MindMotion MicroelectronicsCo., Ltd.
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include<stdint.h>
#include<stdio.h>
#include"board_init.h"
voidMain_Init(void);
voidMainProgram(void);
/*
* Definitions.
*/
/*
* Variables.
*/
/*
* Declerations.
*/
/*
* Functions.
*/
intmain(void)
{
  BOARD_Init();
//****************************************************************************
   Main_Init();
//****************************************************************************
   while (1)
   {
      MainProgram();        
   }
}
/*EOF. */
最终结果: