久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费

標(biāo)題: TM4C123 GXL庫+MAX7219點(diǎn)陣C語言驅(qū)動(dòng) [打印本頁]

作者: 用戶210725    時(shí)間: 2021-7-24 21:44
標(biāo)題: TM4C123 GXL庫+MAX7219點(diǎn)陣C語言驅(qū)動(dòng)

#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ù)碼管編號(hào)
     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個(gè)數(shù)碼管顯示
        Write_Max7219(0x0c, 0x01);               //掉電模式:0,普通模式:1
        Write_Max7219(0x0f, 0x00);               //顯示測(cè)試:1;測(cè)試結(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);
          }
                        
      }
}



這2個(gè)C語言文件下載: TI-MAX7219.rar (3.09 KB, 下載次數(shù): 7)





歡迎光臨 (http://www.zg4o1577.cn/bbs/) Powered by Discuz! X3.1
主站蜘蛛池模板: 久久99精品视频 | 黄色一级片视频 | 久久精品99| 国产精品亚洲综合 | 国产黄色电影 | 亚洲成人av一区二区 | hitomi一区二区三区精品 | 久久亚洲二区 | 久久久久久久久久久久久9999 | 婷婷国产一区 | 欧美一区二区大片 | 国产高清免费视频 | 91精品国产欧美一区二区 | 日日干日日操 | 欧美成人专区 | 自拍偷拍亚洲欧美 | 亚洲天堂影院 | 国产中文字幕在线观看 | 免费久久久 | 97精品国产97久久久久久免费 | 国产一区二区三区免费观看在线 | 免费艹逼视频 | 精品一区二区三区不卡 | 毛片一区二区三区 | 免费一看一级毛片 | 国产成人网 | 久久免费福利 | 久久国产精99精产国高潮 | 国产a一区二区 | 大陆一级毛片免费视频观看 | 免费色网址 | 91国产视频在线 | 69福利影院 | 国产亚洲精品精品国产亚洲综合 | 欧美中文字幕一区二区 | 一区二区不卡 | 91传媒在线观看 | 日韩在线一区二区 | 操久久 | 正在播放国产精品 | caoporn免费 |