中文字幕 另类精品,亚洲欧美一区二区蜜桃,日本在线精品视频免费,孩交精品乱子片免费

<sup id="3hn2b"></sup>

    1. <sub id="3hn2b"><ol id="3hn2b"></ol></sub><legend id="3hn2b"></legend>

      1. <xmp id="3hn2b"></xmp>

      2. 新聞中心

        EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計應(yīng)用 > AVR-GCC如何調(diào)用存儲于Flash中的指向函數(shù)的指針

        AVR-GCC如何調(diào)用存儲于Flash中的指向函數(shù)的指針

        作者: 時間:2016-11-23 來源:網(wǎng)絡(luò) 收藏
        //---------------------------------------------------------------
        // 功能:演示AVR-GCC如何調(diào)用存儲于Flash中的指向函數(shù)指針 (搖擺燈)
        //---------------------------------------------------------------
        #include <avr/io.h>
        #include
        #include
        void ledrun(void);
        typedef struct
        {
        void (*pFun)(void);
        }Function;
        const Function function PROGMEM={ledrun};
        void ledrun(void)
        {
        static unsigned char light_on=0x01;
        static unsigned char light_ddr=0;
        PORTD=light_on;

        if (light_ddr==0)
        {
        if (light_on==0x80)light_ddr=1;
        else light_on<<=1;
        }

        else
        {
        if (light_on==0x01)light_ddr=0;
        else light_on>>=1;
        }

        _delay_ms(50);
        }

        int main(void)
        {
        PORTD=0;
        DDRD=~0;

        //void (*pFun)(void) =ledrun;

        while (1)
        {
        //pgm_read_word(&function.pFun);
        (*((void(*)(void))pgm_read_word(&function.pFun)))(); //別的沒什么說,關(guān)鍵就在這里了
        }

        return 0;
        }


        評論


        相關(guān)推薦

        技術(shù)專區(qū)

        關(guān)閉