|
51hei圖片_20210724203246.jpg (3.29 MB, 下載次數(shù): 80)
下載附件
2021-7-24 21:37 上傳
屏幕截圖 2021-07-24 203805.png (300.91 KB, 下載次數(shù): 87)
下載附件
2021-7-24 21:37 上傳
#ifndef __U_MAX7219_H__
#define __U_MAX7219_H__
/*Include==================================================================================*/
#include <stdbool.h>
#include <stdint.h>
#include "inc/hw_memmap.h"
#include "driverlib/debug.h"
#include "driverlib/gpio.h"
#include "driverlib/rom.h"
#include "driverlib/sysctl.h"
/*Define===================================================================================*/
/*Port----------------------------------------*/
#define Max7219_pinCS_H() GPIOPinWrite(GPIO_PORTD_BASE,GPIO_PIN_1,GPIO_PIN_1)
#define Max7219_pinCS_L() GPIOPinWrite(GPIO_PORTD_BASE,GPIO_PIN_1,0)
#define Max7219_pinCLK_H() GPIOPinWrite(GPIO_PORTD_BASE,GPIO_PIN_2,GPIO_PIN_2)
#define Max7219_pinCLK_L() GPIOPinWrite(GPIO_PORTD_BASE,GPIO_PIN_2,0)
#define Max7219_pinDIN_H() GPIOPinWrite(GPIO_PORTD_BASE,GPIO_PIN_3,GPIO_PIN_3)
#define Max7219_pinDIN_L() GPIOPinWrite(GPIO_PORTD_BASE,GPIO_PIN_3,0)
/*Function=================================================================================*/
void Write_Max7219_byte(uint8_t DATA);
void Write_Max7219(uint8_t address,uint8_t dat);
void Init_MAX7219(void);
void U_8X8_Lattice_Show_Byte(uint8_t addres,uint8_t byteData);
void U_8X8_Lattice_Show_Icon(uint8_t *icon);
#endif /*__U_MAX7219_H__*/
#include "U_MAX7219.h"
void Write_Max7219_byte /*向MAX7219傳輸1Byte*/
(
uint8_t DATA /*1Byte數(shù)據(jù)*/
)
{
uint8_t i;
Max7219_pinCS_L();
for(i=8;i>=1;i--)
{
Max7219_pinCLK_L();
if(DATA & 0x80)
{
Max7219_pinDIN_H();
}
else
{
Max7219_pinDIN_L();
}
DATA=DATA<<1;
Max7219_pinCLK_H();
}
}
void Write_Max7219 /*向MAX7219的寄存器寫入數(shù)據(jù)*/
(
uint8_t address, /*MAX7219的寄存器地址*/
uint8_t dat /*要寫入的內(nèi)容*/
)
{
Max7219_pinCS_L();
Write_Max7219_byte(address); //寫入地址,即數(shù)碼管編號
Write_Max7219_byte(dat); //寫入數(shù)據(jù),即數(shù)碼管顯示數(shù)字
Max7219_pinCS_H();
}
void Init_MAX7219(void) /*MAX7219初始化*/
{
uint32_t i;
Write_Max7219(0x09, 0x00); //譯碼方式:BCD碼
Write_Max7219(0x0a, 0x02); //亮度
Write_Max7219(0x0b, 0x07); //掃描界限;8個數(shù)碼管顯示
Write_Max7219(0x0c, 0x01); //掉電模式:0,普通模式:1
Write_Max7219(0x0f, 0x00); //顯示測試:1;測試結(jié)束,正常顯示:0
/*清空MAX7219數(shù)據(jù)寄存器*/
for(i=1;i<9;i++)
{
Write_Max7219(i,0x00);
}
}
void U_8X8_Lattice_Show_Byte(uint8_t addres,uint8_t byteData)
{
if((byteData & 0x01) == 1)
{
byteData = byteData ;
byteData |= 0x80;
}
else
{
byteData = byteData ;
}
Write_Max7219(addres,byteData);
}
void U_8X8_Lattice_Show_Icon(uint8_t *icon)
{
uint32_t i;
for(i=1;i<9;i++)
{
U_8X8_Lattice_Show_Byte(i,icon[i-1]);
}
}
#include <stdbool.h>
#include <stdint.h>
#include "inc/hw_memmap.h"
#include "driverlib/debug.h"
#include "driverlib/gpio.h"
#include "driverlib/rom.h"
#include "driverlib/sysctl.h"
#include "U_MAX7219.h"
uint32_t systemClock;
uint8_t disl[14][8]=
{
{0x00,0x08,0x14,0x28,0x28,0x14,0x08,0x00},
{0x08,0x14,0x22,0x44,0x44,0x22,0x14,0x08},
{0x1E,0x3F,0x7F,0xFE,0xFE,0x7F,0x3F,0x1E},
{0x00,0x1E,0x20,0x3C,0x3C,0x20,0x1E,0x00},
{0x00,0x42,0x24,0x18,0x18,0x24,0x42,0x00},
{0x00,0x00,0x02,0x04,0x78,0x04,0x02,0x00},
{0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00},
{0x00,0x00,0x18,0x3C,0x3C,0x18,0x00,0x00},
{0x00,0x18,0x3C,0x7C,0x7C,0x3C,0x18,0x00},
{0x0C,0x1E,0x3E,0x7C,0x7C,0x3E,0x1E,0x0C},
{0x0C,0x1E,0x3E,0x7C,0x7C,0x3E,0x1E,0x0C},
{0x00,0x00,0x3E,0x08,0x08,0x3E,0x00,0x00},
{0x00,0x00,0x12,0x22,0x3E,0x02,0x02,0x00},
{0x00,0x42,0x24,0x18,0x18,0x24,0x42,0x00},
};
//*****************************************************************************
//
//! \addtogroup example_list
//! <h1>Simple Project (project)</h1>
//!
//! A very simple example that can be used as a starting point for more complex
//! projects. Most notably, this project is fully TI BSD licensed, so any and
//! all of the code (including the startup code) can be used as allowed by that
//! license.
//!
//! The provided code simply toggles a GPIO using the Tiva Peripheral Driver
//! Library.
//
//*****************************************************************************
//*****************************************************************************
//
// The error routine that is called if the driver library encounters an error.
//
//*****************************************************************************
//*****************************************************************************
//
// Toggle a GPIO.
//
//*****************************************************************************
void U_GPIO_Init(void)
{
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
SysCtlDelay(1);
GPIOPinTypeGPIOOutput(GPIO_PORTD_BASE,GPIO_PIN_1);
GPIOPinTypeGPIOOutput(GPIO_PORTD_BASE,GPIO_PIN_3);
GPIOPinTypeGPIOOutput(GPIO_PORTD_BASE,GPIO_PIN_2);
}
int main(void)
{
uint8_t n;
U_GPIO_Init();
SysCtlDelay(5000000);
U_GPIO_Init();
Init_MAX7219();
U_8X8_Lattice_Show_Icon(displ[10]);
while(1)
{
for(n=0;n<14;n++)
{
U_8X8_Lattice_Show_Icon(disl[n]);
SysCtlDelay(5000000);
}
}
}
51hei.png (3.08 KB, 下載次數(shù): 72)
下載附件
2021-7-25 04:45 上傳
這2個C語言文件下載:
TI-MAX7219.rar
(3.09 KB, 下載次數(shù): 7)
2021-7-24 21:38 上傳
點(diǎn)擊文件名下載附件
下載積分: 黑幣 -5
|
評分
-
查看全部評分
|