⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test.c

📁 参加今年的比赛肯定要用的。谢谢支持。祝大家好运!
💻 C
字号:

#include <unistd.h>
#include <stdio.h>
#include "system.h"
#include "basic_io.h"
#include "LCD.h"
#include "Open_I2C.h"
#include "sys/alt_irq.h"
#include "Test.h"

//-------------------------------------------------------------------------
void handle_button_interrupts()
{
  outport(LED_GREEN_BASE,get_pio_edge_cap(BUTTON_PIO_BASE)*get_pio_edge_cap(BUTTON_PIO_BASE));
  set_pio_edge_cap(BUTTON_PIO_BASE,0x0);
  usleep(BUTTON_STOP_TIME);
  outport(LED_GREEN_BASE,LED_GREEN_VALUE);
}
//-------------------------------------------------------------------------
void init_button_irq()
{
  /* Enable all 4 button interrupts. */
  set_pio_irq_mask(BUTTON_PIO_BASE, BUTTON_INT_MASK);
  /* Reset the edge capture register. */
  set_pio_edge_cap(BUTTON_PIO_BASE, 0x0);
  /* Register the interrupt handler. */
  alt_irq_register( BUTTON_PIO_IRQ, NULL, (void*)handle_button_interrupts ); 
}
//-------------------------------------------------------------------------
void basic_test()
{
    //  Show LCD Test Text
  LCD_Test();
  
  //  Refresh LED
  outport(LED_GREEN_BASE,LED_GREEN_VALUE);
  outport(LED_RED_BASE,LED_RED_VALUE);
  //  Refresh SEG7
  seg7_show(SEG7_DISPLAY_BASE,SEG7_VALUE);
  
  //  I2C Core Initial & Set Freq = 100 Khz
  I2C_Init(10000000/I2C_FREQ-1);
  
  //  Check Video Encoder on I2C Bus, Address = 0x40
  if(I2C_Send(0x40,1,1))
  printf("\nFind Video Encoder on I2C Bus, Address = 0x40.\n");
  else
  printf("\nCan't Find Video Encoder on I2C Bus.\n");
  
  //  Check Audio CODEC on I2C Bus, Address = 0x34
  if(I2C_Send(0x34,1,1))
  printf("\nFind Audio CODEC on I2C Bus, Address = 0x34.\n");
  else
  printf("\nCan't Find Audio CODEC on I2C Bus.\n");

  //  Set Button PIO Interrupts
  init_button_irq();
}
//-------------------------------------------------------------------------

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -