コード例 #1
0
ファイル: rtc_example.c プロジェクト: Malynovsky/BO-m-MRZV
/***********************************************************************
 *
 * Function: c_entry
 *
 * Purpose: Application entry point from the startup code
 *
 * Processing:
 *     See function.
 *
 * Parameters: None
 *
 * Outputs: None
 *
 * Returns: Always returns 1, or <0 on an error
 *
 * Notes: None
 *
 **********************************************************************/
int c_entry(void)
{
  SWIM_WINDOW_T win1;
  COLOR_T *fblog;
  INT_32 lcddev;

  /* Disable interrupts in ARM core */
  disable_irq_fiq();

  /* Setup miscellaneous board functions */
  phy3250_board_init();

  /* Set virtual address of MMU table */
  cp15_set_vmmu_addr((void *)
                     (IRAM_BASE + (256 * 1024) - (16 * 1024)));

  /* Initialize interrupt system */
  int_initialize(0xFFFFFFFF);

  /* Install standard IRQ dispatcher at ARM IRQ vector */
  int_install_arm_vec_handler(IRQ_VEC, (PFV) lpc32xx_irq_handler);

  /* Install RTC interrupt handler as a IRQ interrupts */
  int_install_irq_handler(IRQ_RTC, (PFV) rtc_user_interrupt);

  /* Open RTC */
  rtcdev = rtc_open(RTC, 0);
  if (rtcdev == 0)
  {
    /* Error */
    return -1;
  }

  /* Set a 1s match rate */
  secs = lsecs = 0;
  mstp.match_num      = 0;
  mstp.use_match_int  = TRUE;
  mstp.enable_onsw    = FALSE;
  mstp.match_tick_val = secs + 1;
  rtc_ioctl(rtcdev, RTC_ENABLE, 0);
  rtc_ioctl(rtcdev, RTC_SET_COUNT, 0);
  rtc_ioctl(rtcdev, RTC_CLEAR_INTS, RTC_MATCH0_INT_STS);
  rtc_ioctl(rtcdev, RTC_SETUP_MATCH, (INT_32) &mstp);

  /* Setup LCD muxing for STN Color 16BPP */
  clkpwr_setup_lcd(CLKPWR_LCDMUX_TFT16, 1);

  /* Enable clock to LCD block (HCLK_EN)*/
  clkpwr_clk_en_dis(CLKPWR_LCD_CLK, 1);

  /* Setup LCD paramaters in the LCD controller */
  lcddev = lcd_open(CLCDC, (INT_32) & LCD_DISPLAY);

  /* Upper Panel Frame Base Address register */
  lcd_ioctl(lcddev, LCD_SET_UP_FB, PHY_LCD_FRAME_BUF);

  /* Enable LCD controller and power signals */
  lcd_ioctl(lcddev, LCD_PWENABLE, 1);

  /* Enable LCD backlight */
  phy3250_lcd_backlight_enable(TRUE);

  /* Enable LCD power */
  phy3250_lcd_power_enable(TRUE);

  /* Set frame buffer address */
  fblog = (COLOR_T *) cp15_map_physical_to_virtual(PHY_LCD_FRAME_BUF);

  /* Create a SWIM window */
  swim_window_open(&win1, LCD_DISPLAY.pixels_per_line,
                   LCD_DISPLAY.lines_per_panel, fblog, 0, 0,
                   (LCD_DISPLAY.pixels_per_line - 1), (LCD_DISPLAY.lines_per_panel - 1),
                   1, WHITE, BLACK, BLACK);
  swim_put_ltext(&win1, "RTC example: This example will print the message "
                 "TICK whenever an RTC interrupt occurs (1 second intervals). It will "
                 "quit after 10 seconds\n");

  /* Enable RTC (starts counting) */
  rtc_ioctl(rtcdev, RTC_ENABLE, 1);

  /* Enable RTC interrupt in the interrupt controller */
  int_enable(IRQ_RTC);

  /* Enable IRQ interrupts in the ARM core */
  enable_irq();

  /* Loop for 10 seconds and let interrupts toggle the LEDs */
  while (secs < 10)
  {
    if (lsecs < secs)
    {
      swim_put_ltext(&win1, "TICK\n");
      lsecs = secs;
    }
  }
  /* Disable RTC interrupt in the interrupt controller */
  int_disable(IRQ_RTC);

  /* Disable interrupts in ARM core */
  disable_irq_fiq();

  /* Prior to closing the RTC, the ONSW key value is set. This will
     allow the RTC to keep it's value across resets as long as RTC
   power is maintained */
  rtc_ioctl(rtcdev, RTC_SETCLR_KEY, 1);

  /* Close RTC and LCD */
  rtc_close(rtcdev);
  lcd_close(lcddev);

  return 1;
}
コード例 #2
0
ファイル: file_op.c プロジェクト: HLi91/ECE391OS
/*
 * sys_rtc_close
 * Description: close system RTC
 * INPUTS:	
		 int32_t fd -- file descriptor
		 pcb_t* mypcb -- Process control block
 * OUTPUTS:	None
 * RETURN: None
 * SIDE EFFECTS: None
 */
extern int32_t sys_rtc_close(int32_t fd, pcb_t* mypcb)
{
	return rtc_close(fd);
}