芯片開放社區(qū)(OCC)面向廣大開發(fā)者推出應(yīng)用實(shí)戰(zhàn)系列內(nèi)容,通過分享開發(fā)者實(shí)戰(zhàn)開發(fā)案例,總結(jié)應(yīng)用開發(fā)經(jīng)驗(yàn),梳理開發(fā)中的常見問題及解決方案,為后續(xù)參與的開發(fā)者提供更多參考與借鑒。
本文是關(guān)于開發(fā)者 乘簡(jiǎn)基于BL606P-DVK開發(fā)板實(shí)戰(zhàn)開發(fā)的系列文章中的一篇,主要介紹了驅(qū)動(dòng)MAX7219點(diǎn)陣模組,后面還會(huì)持續(xù)更新社區(qū)開發(fā)者的測(cè)評(píng)內(nèi)容,敬請(qǐng)期待!
01硬件部分
我買了一款MAX7219芯片的點(diǎn)陣模塊,8個(gè)8x8連在一起的模塊,只需要3個(gè)GPIO口即可驅(qū)動(dòng),可以顯示兩個(gè)16x16點(diǎn)陣的漢字
連線圖:
GPIO2連入DIN,GPIO3連入CS,GPIO4連入CLK,VCC接5V,GND接GND
main.c的代碼:
#include
#include
#include
#include
#include "app_main.h"
#include "max7219.h"
int main(int argc, char *argv[])
{
board_yoc_init();
max7219_Init();
printf("
app start core clock %d........
", soc_get_cur_cpu_freq());
Display();
return 0;
}
max7219.h
#ifndef _MAX7219_H_
#define _MAX7219_H_
#include
#include
#include
#define MODS_7219 8//點(diǎn)陣模塊數(shù)量
void max7219_Init();
void Display();
#endif
max7219.c
#include "max7219.h"
gpio_dev_t gpio_din = { GPIO_PIN_2, OUTPUT_PUSH_PULL, (void*)0 };
gpio_dev_t gpio_cs= { GPIO_PIN_3, OUTPUT_PUSH_PULL, (void*)0 };
gpio_dev_t gpio_clk = { GPIO_PIN_4, OUTPUT_PUSH_PULL, (void*)0 };
#define din_l() hal_gpio_output_low(&gpio_din)
#define din_h() hal_gpio_output_high(&gpio_din)
#define clk_l() hal_gpio_output_low(&gpio_clk)
#define clk_h() hal_gpio_output_high(&gpio_clk)
#define cs_l() hal_gpio_output_low(&gpio_cs)
#define cs_h() hal_gpio_output_high(&gpio_cs)
uint8_t FONT8[][8]={
{0x38,0x44,0x44,0x44,0x44,0x44,0x44,0x38},/*"0",0*/
{0x10,0x30,0x10,0x10,0x10,0x10,0x10,0x38},/*"1",1*/
{0x38,0x44,0x44,0x08,0x10,0x20,0x40,0x7C},/*"2",2*/
{0x38,0x44,0x04,0x18,0x04,0x04,0x44,0x38},/*"3",3*/
{0x08,0x18,0x18,0x28,0x48,0x7C,0x08,0x1C},/*"4",4*/
{0x7C,0x40,0x40,0x78,0x44,0x04,0x44,0x38},/*"5",5*/
{0x18,0x24,0x40,0x58,0x64,0x44,0x44,0x38},/*"6",6*/
{0x3C,0x04,0x08,0x08,0x10,0x10,0x10,0x10},/*"7",7*/
{0x38,0x44,0x44,0x38,0x44,0x44,0x44,0x38},/*"8",8*/
{0x38,0x44,0x44,0x4C,0x34,0x04,0x48,0x30},/*"9",9*/
};
//寫1個(gè)字節(jié)
void max7219_writebyte(uint8_t dat)
{
uint8_t i;
for(i=0;i<8;i++){
clk_l();
if(dat & 0x80)din_h();else din_l();
dat<<=1;
clk_h();
}
}
//寫入配置數(shù)據(jù)
void max7219_writeset(uint8_t address, uint8_t dat)
{
uint8_t i;
cs_l();
for(i=0;i
02演示效果
?
-
芯片
+關(guān)注
關(guān)注
455文章
50816瀏覽量
423663 -
開發(fā)板
+關(guān)注
關(guān)注
25文章
5050瀏覽量
97482 -
模組
+關(guān)注
關(guān)注
6文章
1492瀏覽量
30392
原文標(biāo)題:應(yīng)用速遞 | 博流BL606P音視頻開發(fā)板:驅(qū)動(dòng)MAX7219點(diǎn)陣模組
文章出處:【微信號(hào):芯片開放社區(qū),微信公眾號(hào):芯片開放社區(qū)】歡迎添加關(guān)注!文章轉(zhuǎn)載請(qǐng)注明出處。
發(fā)布評(píng)論請(qǐng)先 登錄
相關(guān)推薦
評(píng)論