OLED显示数据

2019-03-25 20:06发布

小弟用OLED 0.96 显示。不知道怎么显示变化数据,如模拟量数据。请各位大哥指导。怎么显示buff_A数据。详见代码

OLED部分:

#include "oled.h"
#include "board.h"
#include <stdlib.h>
#include "codetab.h"

#define I2C_ADDR_7BIT       (0x78>>1)

#define SSD1106 1 //1.3'
#define        SSD1306 2 //0.96'
#define OLED_Stype SSD1306

void delay_ms(unsigned int Del_1ms)  //
{
        unsigned int i,j;
        for(i=0;i<Del_1ms;i++)
        {
           for(j=0;j<30000;j++);
        }
}

void delay_us(unsigned int Del_1us)  //
{
        unsigned int j;
        while(Del_1us--)
        {
           for(j=0;j<10;j++);
        }
}
//3õê¼»ˉOLED
void OLED_Init(void)
{       
#if (OLED_Stype == SSD1106)
        DEBUGOUT("IIC SSD1106 Init..."); //1.3'Æá
        Write_Command(0xAE);    /*display off*/
       
        Write_Command(0x02);    /*set lower column address*/
        Write_Command(0x10);    /*set higher column address*/
       
        Write_Command(0x40);    /*set display start line*/
       
        Write_Command(0xB0);    /*set page address*/
       
        Write_Command(0x81);    /*contract control*/
        Write_Command(0x80);    /*128*/
       
        Write_Command(0xA1);    /*set segment remap*/
       
        Write_Command(0xA6);    /*normal / reverse*/
       
        Write_Command(0xA8);    /*multiplex ratio*/
        Write_Command(0x3F);    /*duty = 1/32*/
       
        Write_Command(0xad);    /*set charge pump enable*/
        Write_Command(0x8b);     /*    0x8a    ??VCC   */
       
        Write_Command(0x30);    /*0X30---0X33  set VPP   9V liangdu!!!!*/
       
        Write_Command(0xC8);    /*Com scan direction*/
       
        Write_Command(0xD3);    /*set display offset*/
        Write_Command(0x00);   /*   0x20  */
       
        Write_Command(0xD5);    /*set osc division*/
        Write_Command(0x80);   
       
        Write_Command(0xD9);    /*set pre-charge period*/
        Write_Command(0x1f);    /*0x22*/
       
        Write_Command(0xDA);    /*set COM pins*/
        Write_Command(0x12);//0x02 -- duanhang xianshi,0x12 -- lianxuhang xianshi!!!!!!!!!
       
        Write_Command(0xdb);    /*set vcomh*/
        Write_Command(0x40);     
       
        Write_Command(0xAF);    /*display ON*/
        #else
        DEBUGOUT("IIC SSD1306 Init...");//0.96'Æá
        Write_Command(0xAE); //display off
        Write_Command(0x20);        //Set Memory Addressing Mode       
        Write_Command(0x10);        //00,Horizontal Addressing Mode;01,Vertical Addressing Mode;10,Page Addressing Mode (RESET);11,Invalid
        Write_Command(0xb0);        //Set Page Start Address for Page Addressing Mode,0-7
        Write_Command(0xc8);        //Set COM Output Scan Direction
        Write_Command(0x00); //---set low column address
        Write_Command(0x10); //---set high column address
        Write_Command(0x40); //--set start line address
        Write_Command(0x81); //--set contrast control register
        Write_Command(0xff); //áá¶èμ÷½ú 0x00~0xff
        Write_Command(0xa1); //--set segment re-map 0 to 127
        Write_Command(0xa6); //--set normal display
        Write_Command(0xa8); //--set multiplex ratio(1 to 64)
        Write_Command(0x3F); //
        Write_Command(0xa4); //0xa4,Output follows RAM content;0xa5,Output ignores RAM content
        Write_Command(0xd3); //-set display offset
        Write_Command(0x00); //-not offset
        Write_Command(0xd5); //--set display clock divide ratio/oscillator frequency
        Write_Command(0xf0); //--set divide ratio
        Write_Command(0xd9); //--set pre-charge period
        Write_Command(0x22); //
        Write_Command(0xda); //--set com pins hardware configuration
        Write_Command(0x12);
        Write_Command(0xdb); //--set vcomh
        Write_Command(0x20); //0x20,0.77xVcc
        Write_Command(0x8d); //--set DC-DC enable
        Write_Command(0x14); //
        Write_Command(0xaf); //--turn on oled panel
        #endif
        OLED_Fill(0xFF); //
        OLED_Set_Pos(0,0);
        OLED_CLS();
       
}



/********************************************
// fill_Picture
********************************************/
void OLED_Fill(unsigned char fill_Data)
{
unsigned char m,n;
        for(m=0;m<8;m++)
        {
                Write_Command(0xb0+m);  //page0-page1
                Write_Command(0x00);  //low column start address
                Write_Command(0x10);  //high column start address
                #if (OLED_Stype == SSD1106)
                for(n=0;n<132;n++)
                 {
                        Write_Data(fill_Data);
                 }
                #else
                 for(n=0;n<129;n++)
                 {
                        Write_Data(fill_Data);
                 }
                 #endif
        }
}
/*********************OLED??************************************/
void OLED_CLS(void)
{
        unsigned char y,x;
        for(y=0;y<8;y++)
        {
                Write_Command(0xb0+y);
                Write_Command(0x01);
                Write_Command(0x10);
                #if (OLED_Stype == SSD1106)
                for(x=0;x<132;x++)
                Write_Data(0);
                #else
                for(x=0;x<129;x++)
                Write_Data(0);
                #endif
        }
}

/*********************OLED éèÖÃ×ø±ê ************************************/
void OLED_Set_Pos(unsigned char x, unsigned char y)
{
        Write_Command(0xb0+y);
        Write_Command(((x&0xf0)>>4)|0x10);
        Write_Command((x&0x0f)|0x01);
}

/***************1|ÄüÃèêö£oÏÔê¾6*8ò»×é±ê×¼ASCII×Ö·û′®        ÏÔê¾μÄ×ø±ê£¨x,y£©£¬yÎaò3·¶Î§0¡«7****************/
void OLED_P6x8Str(unsigned char x, unsigned char y,unsigned char ch[])
{
        unsigned char c=0,i=0,j=0;
        while (ch[j]!='')
        {
                c =ch[j]-32;
                #if (OLED_Stype == SSD1106)
                if(x>126){x=0;y++;}
                OLED_Set_Pos(x+2,y);
                for(i=0;i<6;i++)
                Write_Data(F6x8[c][i]);
                x+=6;
                j++;
                #else
                if(x>122){x=0;y++;}
                OLED_Set_Pos(x+2,y);
                for(i=0;i<6;i++)
                Write_Data(F6x8[c][i]);
                x+=6;
                j++;
                #endif
               
        }
}
/*******************1|ÄüÃèêö£oÏÔê¾8*16ò»×é±ê×¼ASCII×Ö·û′®         ÏÔê¾μÄ×ø±ê£¨x,y£©£¬yÎaò3·¶Î§0¡«7****************/
void OLED_P8x16Str(unsigned char x, unsigned char y,unsigned char ch[])
{
        unsigned char c=0,i=0,j=0;
        while (ch[j]!='')
        {
                c =ch[j]-32;
                if(x>120){x=0;y++;}
                OLED_Set_Pos(x+2,y);
                for(i=0;i<8;i++)
                Write_Data(F8X16[c*16+i]);
                OLED_Set_Pos(x+2,y+1);
                for(i=0;i<8;i++)
                Write_Data(F8X16[c*16+i+8]);
                x+=8;
                j++;
        }
}
/*****************1|ÄüÃèêö£oÏÔê¾16*16μãÕó  ÏÔê¾μÄ×ø±ê£¨x,y£©£¬yÎaò3·¶Î§0¡«7****************************/
void OLED_P16x16Ch(unsigned char x, unsigned char y, unsigned char N)
{
        unsigned char wm=0;
        unsigned int adder=32*N;
        OLED_Set_Pos(x , y);
        for(wm = 0;wm < 16;wm++)
        {
                Write_Data(F16x16[adder]);
                adder += 1;
        }
        OLED_Set_Pos(x,y + 1);
        for(wm = 0;wm < 16;wm++)
        {
                Write_Data(F16x16[adder]);
                adder += 1;
        }                  
}
/***********1|ÄüÃèêö£oÏÔê¾ÏÔê¾BMPí¼Æ¬128¡á64Æeê¼μã×ø±ê(x,y),xμÄ·¶Î§0¡«127£¬yÎaò3μÄ·¶Î§0¡«7*****************/
void Draw_BMP(unsigned char x0, unsigned char y0,unsigned char x1, unsigned char y1,unsigned char BMP[])
{
        unsigned int j=0;
        unsigned char x,y;

  if(y1%8==0) y=y1/8;      
  else y=y1/8+1;
        for(y=y0;y<y1;y++)
        {
                OLED_Set_Pos(x0,y);
    for(x=x0;x<x1;x++)
            {      
                    Write_Data(BMP[j++]);
            }
        }
}

/***********1|ÄüÃèêö£oÏÔê¾oo×Ö£¬×Ö·û£¬í¼Æ¬*****************/
void OLED_Test(void)
{
        unsigned char i=0;
        OLED_CLS();//ÇåÆá
        //éîÛúóÅáú¿Æ¼¼
        OLED_P16x16Ch(16,0,0);
        OLED_P16x16Ch(32,0,1);
        OLED_P16x16Ch(48,0,2);
        OLED_P16x16Ch(64,0,3);
        OLED_P16x16Ch(80,0,4);
        OLED_P16x16Ch(96,0,5);
       
        for(i=0; i<8; i++)//í¨1yμãÕûÏÔê¾oo×Ö -- i±íê¾×Ö±íêy×éμÄλÖÃ
        {
                OLED_P16x16Ch(i*16,2,i+6);
                OLED_P16x16Ch(i*16,4,i+14);
                //OLED_P16x16Ch(i*32,6,i+22);
        }
        for(i=0; i<3; i++)//í¨1yμãÕûÏÔê¾oo×Ö -- i±íê¾×Ö±íêy×éμÄλÖÃ
        {
                //OLED_P16x16Ch(48+i*16,6,i+22);
                OLED_P16x16Ch(40+i*16,6,i+22);
        }
       
        delay_ms(3000);
        OLED_CLS();//ÇåÆá

        OLED_P8x16Str(52,0,"SAE");//μúò»DD -- 8x16μÄÏÔê¾μ¥ÔaÏÔê¾ASCIIÂë
        OLED_P8x16Str(40,3,"SG MCU");
        OLED_P6x8Str(16,6,"AEROSPACE ENERGY");
  OLED_P6x8Str(25,7,"www.sae.sh.cn");
        delay_ms(3000);
        OLED_CLS();
}
void OLED_dis(void)
{


       
        OLED_P8x16Str(52,0,"VALUE");//μúò»DD -- 8x16μÄÏÔê¾μ¥ÔaÏÔê¾ASCIIÂë
  delay_ms(500);
        OLED_CLS();
       
















主程序及ADC部分:


#include "board.h"
#include <stdlib.h>
#include "romapi_adc.h"
#include "oled.h"


#define I2C_NUM  2
#if (I2C_NUM == 2)
/** I2C interface setup */
#define I2C_ADDR_7BIT       (0x78>>1) //IIC ′óé豸μØÖ·
#define LPC_I2C_PORT         LPC_I2C2
#define LPC_I2CM_CLOCK       SYSCON_CLOCK_I2C2
#define LPC_I2CM_RESET       RESET_I2C2

#elif (I2C_NUM == 1)
#define I2C_ADDR_7BIT       (0x78>>1) //IIC ′óé豸μØÖ·
#define LPC_I2C_PORT         LPC_I2C1
#define LPC_I2CM_CLOCK       SYSCON_CLOCK_I2C1
#define LPC_I2CM_RESET       RESET_I2C1

#elif (I2C_NUM == 0)
#define I2C_ADDR_7BIT       (0x78>>1) //IIC ′óé豸μØÖ·
#define LPC_I2C_PORT         LPC_I2C0
#define LPC_I2CM_CLOCK       SYSCON_CLOCK_I2C0
#define LPC_I2CM_RESET       RESET_I2C0
#endif

/* 400KHz I2C bit-rate */
#define I2C_BITRATE         (400000)
/* ROM driver handle for I2C master */
static ROM_I2CM_HANDLE_T i2cmHandle;
/* I2C driver context area */
static uint32_t drvData[64];
/* Made global so data can be seen in the debuuger */
uint8_t rx[2];
uint8_t tx[2];
uint32_t actualRate;
ROM_I2CM_XFER_T mXfer;

/* Initializes pin muxing for I2C interface - note that SystemInit() may
   already setup your pin muxing at system startup */
static void Init_I2C_PinMux(void)
{
#if defined(BOARD_NXP_LPCXPRESSO_54102)
        /* Connect the I2C_SDA and I2C_SCL signals to port pins */
        #if (I2C_NUM == 2)
        Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 27, (IOCON_FUNC1 | IOCON_DIGITAL_EN));        /* I2C2 */
        Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 28, (IOCON_FUNC1 | IOCON_DIGITAL_EN));        /* I2C2 */
        #elif (I2C_NUM == 1)
        Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 25, (IOCON_FUNC1 | IOCON_DIGITAL_EN));        /* I2C1 */
        Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 26, (IOCON_FUNC1 | IOCON_DIGITAL_EN));        /* I2C1 */
        #elif (I2C_NUM == 0)
        Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 23, (IOCON_FUNC1 | IOCON_DIGITAL_EN));        /* I2C0 */
        Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 24, (IOCON_FUNC1 | IOCON_DIGITAL_EN));        /* I2C0 */
        #else
        Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 27, (IOCON_FUNC0 | IOCON_GPIO_MODE|IOCON_MODE_PULLUP));        /* GPIO */
        Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 28, (IOCON_FUNC0 | IOCON_GPIO_MODE|IOCON_MODE_PULLUP));        /* GPIO */
        #endif
#else
        /* Configure your own I2C pin muxing here if needed */
#warning "No I2C pin muxing defined"
#endif
}

/* Display error string and spin */
static void errorOut(char *errStr)
{
        DEBUGOUT(errStr);
        while (1) {}
}

/*****************************************************************************
* Public functions
****************************************************************************/
void Write_Command(unsigned char cmd)
{
                unsigned char buffer[2];
                buffer[0]=0x00;
                buffer[1]=cmd;
                mXfer.slaveAddr = I2C_ADDR_7BIT;
                mXfer.rxBuff = rx;
                mXfer.txBuff = buffer;
                mXfer.txSz = 2;
                mXfer.rxSz = 0;

                /* I2C master driver will block if blocking flag is used */
                mXfer.flags = ROM_I2CM_FLAG_BLOCKING;

                /* Start transfer and wait for completion */
                ROM_I2CM_Transfer(i2cmHandle, &mXfer);
}

void Write_Data(unsigned char data)
{
                unsigned char buffer[2];
                buffer[0]=0x40;
                buffer[1]=data;
                mXfer.slaveAddr = I2C_ADDR_7BIT;
        mXfer.rxBuff = rx;
                mXfer.txBuff = buffer;
                mXfer.txSz = 2;
                mXfer.rxSz = 0;

                /* I2C master driver will block if blocking flag is used */
                mXfer.flags = ROM_I2CM_FLAG_BLOCKING;

                /* Start transfer and wait for completion */
                ROM_I2CM_Transfer(i2cmHandle, &mXfer);
}

/******************************************************************************************************************************/
/*****************************************************************************
* Private types/enumerations/variables
****************************************************************************/
/* Get 32 samples for 3 channels CH0, CH3 and CH4 */
#define NUM_SAMPLES_A    6
#define NUM_CHANNELS_A    2
#define SAMPLE_COUNT_A    16/* Run 16 times */



/* SEQ_A enables channels 0, 3 and 4; Uses software trigger; doesn't use BURST */
#define ADC_SEQ_A_CONFIG  
        TRIG_SOFT |                /* Software trigger for SEQ_A */
        TRIG_POL_POS |        /* UM recommends this for S/W trigger */
        MODE_EOS |                /* Event generated after Sequence done */
        ENABLE_CH(0) | ENABLE_CH(1)         /* Associate channels 0, 2 and 3 to SEQ_A */


/* General ADC configuration */
#define ADC_CONFIG
        MODE_SYNC |        /* Enable synchronous mode */
        RESOL_12BIT |        /* Use 12-Bit resolution */       
        SAMPLE_TIME(0)        /* No extra clocks */

/* Buffer pointers */
static uint16_t buff_A[NUM_SAMPLES_A][NUM_CHANNELS_A];        /* Memory to hold samples for SEQ_A */

static uint16_t(*volatile pBufA)[NUM_CHANNELS_A];        /* Pointer to current active SEQ_A buffer */


/* ADC Driver context memory */
#define RAMBLOCK_H          60
static uint32_t  start_of_ram_block0[RAMBLOCK_H];

/* ADC ROM Driver Handle */
static ADC_HANDLE_T *hADC;

/*****************************************************************************
* Public types/enumerations/variables
****************************************************************************/

/*****************************************************************************
* Private functions
****************************************************************************/

static void ADC_PinMuxSetup(void)
{
#if defined(BOARD_NXP_LPCXPRESSO_54102)
        /* All pins to inactive, neither pull-up nor pull-down. */
        Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 29, IOCON_MODE_INACT | IOCON_FUNC1 | IOCON_ANALOG_EN);
        Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 30, IOCON_MODE_INACT | IOCON_FUNC1 | IOCON_ANALOG_EN);
        Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 31, IOCON_MODE_INACT | IOCON_FUNC1 | IOCON_ANALOG_EN);
        Chip_IOCON_PinMuxSet(LPC_IOCON, 1, 0, IOCON_MODE_INACT | IOCON_FUNC1 | IOCON_ANALOG_EN);
        Chip_IOCON_PinMuxSet(LPC_IOCON, 1, 1, IOCON_MODE_INACT | IOCON_FUNC1 | IOCON_ANALOG_EN);
        Chip_IOCON_PinMuxSet(LPC_IOCON, 1, 2, IOCON_MODE_INACT | IOCON_FUNC1 | IOCON_ANALOG_EN);
        Chip_IOCON_PinMuxSet(LPC_IOCON, 1, 3, IOCON_MODE_INACT | IOCON_FUNC1 | IOCON_ANALOG_EN);
        Chip_IOCON_PinMuxSet(LPC_IOCON, 1, 4, IOCON_MODE_INACT | IOCON_FUNC1 | IOCON_ANALOG_EN);
        Chip_IOCON_PinMuxSet(LPC_IOCON, 1, 5, IOCON_MODE_INACT | IOCON_FUNC1 | IOCON_ANALOG_EN);
        Chip_IOCON_PinMuxSet(LPC_IOCON, 1, 6, IOCON_MODE_INACT | IOCON_FUNC1 | IOCON_ANALOG_EN);
        Chip_IOCON_PinMuxSet(LPC_IOCON, 1, 7, IOCON_MODE_INACT | IOCON_FUNC1 | IOCON_ANALOG_EN);
        Chip_IOCON_PinMuxSet(LPC_IOCON, 1, 8, IOCON_MODE_INACT | IOCON_FUNC1 | IOCON_ANALOG_EN);

#else
#warning "No ADC setup for this example"
#endif
}

/* Initialize the ADC ROM Driver */
static int adcrom_init(void)
{
        volatile int size_in_bytes;

        ADC_PinMuxSetup();
        Chip_SYSCON_PowerUp(SYSCON_PDRUNCFG_PD_ADC0 | SYSCON_PDRUNCFG_PD_VDDA_ENA | SYSCON_PDRUNCFG_PD_VREFP);
        /* ê1ÄüíaΧê±Öó*/
        Chip_Clock_EnablePeriphClock(SYSCON_CLOCK_ADC0);
  /* ADCê±ÖóÔ′*/
        Chip_Clock_SetADCClockSource(SYSCON_ADCCLKSELSRC_MAINCLK);
        /* ADCê±Öó·ÖÆμÆ÷ */
        Chip_Clock_SetADCClockDiv(0x1);     
   /*»ñμÃADCÇy¶ˉ3ìDòéÏÏÂÎÄDèòa×Ö½úμÄÄú′æ′óD¡*/
        size_in_bytes =  ROM_ADC_GetMemSize();

        if (RAMBLOCK_H < (size_in_bytes / 4)) {
                return 1;
        }
  /*Initialize ADC ROM Driver3õê¼»ˉADCÇy¶ˉÆ÷ROM_ADC_Init*/
        hADC = ROM_ADC_Init(start_of_ram_block0, LPC_ADC_BASE, 0);

        return 0;
}

/* Configure ADC ROM Driver and pripheral */
static int adcrom_config(void)
{
        ADC_CFG_T cfg = {
                ADC_SEQ_A_CONFIG,

                ADC_CONFIG,
                0        /* Divider will be calculated during run time */
        };

        cfg.clkDiv = 0xFF;

        /* Configure the ADC */
        ROM_ADC_Configure(hADC, &cfg);

        /* Calibrate the ADC */
        if (ROM_ADC_Calibrate(hADC, Chip_Clock_GetSystemClockRate()) != LPC_OK) {
                DEBUGSTR("ERROR: Calibrating ADC ");
               
        }
        DEBUGSTR("ADC Initialized and Calibrated successfully! ");

        /* Channel configurations */
        ROM_ADC_ConfigureCh(hADC, 0, ADC_CH_THRES_DATA | ADC_CH_THRES_SEL1 | ADC_CH_THRES_CROSSING);


        return 0;
}

/* Call-Back function for ADC Start/Stop event */
static void adcrom_startstop(ADC_HANDLE_T hADC, ADC_CBINDEX_T idx, void *arg)
{
        switch (idx) {
        case ADC_START_SEQ_A:
                DEBUGSTR("Sequence A Started! ");
                break;



        case ADC_STOP_SEQ_A:
                DEBUGSTR("Sequence A Stopped! ");
                break;



        default:
                break;
        }
}

/* Print content of buffer_A to UART */
static void print_buf_A(uint32_t cnt)
{
        int i, j;
        uint16_t(*buf)[NUM_CHANNELS_A] = pBufA;

        pBufA = 0;
        if (!buf) {
                return;
        }

        for (i = 0; i < cnt; i++) {
                DEBUGSTR("SEQ_A: ");
                for (j = 0; j < NUM_CHANNELS_A; j++) {
                        DEBUGOUT("%x ", buf[i][j]);
                }
                DEBUGSTR(" ");
        }
}



/* Register ADC event Callback functions */
static void adcrom_regcb(void)
{
        ROM_ADC_RegisterCB(hADC, ADC_STOP_SEQ_A, adcrom_startstop);        /* SEQ_A Stop */
        ROM_ADC_RegisterCB(hADC, ADC_START_SEQ_A, adcrom_startstop);/* SEQ_A Start */
       
}

/*****************************************************************************
* Public functions
****************************************************************************/

/* PININT1 IRQ handler */
void PIN_INT1_IRQHandler(void)
{
        Chip_PININT_ClearIntStatus(LPC_PININT, PININTCH(PININTSELECT1));
}

/**
* @brief        Main routine for I2C example
* @return        Function should not exit
*/
int main(void)
{
       
        uint32_t memSize, *devMem;
        ROM_I2CM_INIT_T i2cmInit;
       
        /* Generic Initialization */
        SystemCoreClockUpdate();
        Board_Init();

                /* Setup I2C pin muxing, enable I2C clock and reset I2C peripheral */
        Init_I2C_PinMux();
       
        Chip_Clock_EnablePeriphClock(LPC_I2CM_CLOCK);
        Chip_SYSCON_PeriphReset(LPC_I2CM_RESET);
       
       
        /* Get needed size for driver context memory */
        memSize = ROM_I2CM_GetMemSize();
        if (memSize > sizeof(drvData)) {
                errorOut("Can't allocate memory for I2C driver context ");
        }
        devMem = drvData;        /* Or just use malloc(memSize) */

        /* Initialize driver */
        i2cmInit.pUserData = NULL;
        i2cmInit.base = (uint32_t) LPC_I2C_PORT;
        i2cmHandle = ROM_I2CM_Init(devMem, &i2cmInit);
        if (i2cmHandle == NULL) {
                /* Error initializing I2C */
                errorOut("Error initializing ROM ");
        }

        /* Set I2C clock rate */
        actualRate = ROM_I2CM_SetClockRate(i2cmHandle,
                                                                           Chip_Clock_GetAsyncSyscon_ClockRate(), I2C_BITRATE);
        DEBUGOUT("Actual I2C master rate = %dHz ", actualRate);
        OLED_Init();
        OLED_Fill(0xFF);
        OLED_Test();
       
       
       
       
        /* Initialize the PinMux and setup the memory for ROM driver */
        if (adcrom_init()) {
                return 1;
        }

        /* Configure the ADC */
        if (adcrom_config()) {
                return 1;
        }

       
       
       
        while (1) {
       
        adcrom_regcb();        /* Register call-back functions */


               
        /* Start SEQ_A */
        if (ROM_ADC_StartConversion(hADC, ADC_SEQ_A, &buff_A[0][0], NUM_SAMPLES_A * NUM_CHANNELS_A) != LPC_OK) {
                DEBUGSTR("ERROR: Starting conversion in SEQ_A ");
        }

       
                /* Wait for buffer to be filled up with required number of samples */
        if (ROM_ADC_Handler(hADC, ADC_EV_SEQ_A_POLL) == LPC_OK) {
          pBufA = buff_A;
          print_buf_A(NUM_SAMPLES_A);        /* Print samples from the buffer */
        }

         OLED_dis();       

}


}












此帖出自小平头技术问答
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
该问题目前已经被作者或者管理员关闭, 无法添加新回复
4条回答
llh258021686
1楼-- · 2019-03-25 20:56
_NXP LPC1000_ 哈哈,搞好了
噢噢噢噢
2楼-- · 2019-03-25 21:56
 精彩回答 2  元偷偷看……
18434391446
3楼-- · 2019-03-26 00:56
楼主是采用的那款芯片呢
近道
4楼-- · 2019-03-26 02:57
有实物图片吗

一周热门 更多>