board.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * File : board.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2006-2011, RT-Thread Development Team
  5. *
  6. * The license and distribution terms for this file may be
  7. * found in the file LICENSE in this distribution or at
  8. * http://www.rt-thread.org/license/LICENSE
  9. *
  10. * Change Logs:
  11. * Date Author Notes
  12. * 2011-05-23 aozima first implementation for PIC32.
  13. */
  14. // Adds support for PIC32 Peripheral library functions and macros
  15. #include <plib.h>
  16. // Configuration Bits
  17. #pragma config FNOSC = PRIPLL // Oscillator Selection
  18. #pragma config FPLLIDIV = DIV_2 // PLL Input Divider (PIC32 Starter Kit: use divide by 2 only)
  19. #pragma config FPLLMUL = MUL_20 // PLL Multiplier
  20. #pragma config FPLLODIV = DIV_1 // PLL Output Divider
  21. #pragma config FPBDIV = DIV_1 // Peripheral Clock divisor
  22. #pragma config FWDTEN = OFF // Watchdog Timer
  23. #pragma config WDTPS = PS1 // Watchdog Timer Postscale
  24. #pragma config FCKSM = CSDCMD // Clock Switching & Fail Safe Clock Monitor
  25. #pragma config OSCIOFNC = OFF // CLKO Enable
  26. #pragma config POSCMOD = XT // Primary Oscillator
  27. #pragma config IESO = OFF // Internal/External Switch-over
  28. #pragma config FSOSCEN = OFF // Secondary Oscillator Enable
  29. #pragma config CP = OFF // Code Protect
  30. #pragma config BWP = OFF // Boot Flash Write Protect
  31. #pragma config PWP = OFF // Program Flash Write Protect
  32. #pragma config ICESEL = ICS_PGx2 // ICE/ICD Comm Channel Select
  33. #pragma config DEBUG = OFF // Debugger Disabled for Starter Kit
  34. // The following is used by the main application
  35. #define SYS_FREQ (80000000)
  36. static void rt_hw_show_info(void)
  37. {
  38. rt_kprintf("\r\n\r\n---------- board info ----------\r\n");
  39. rt_kprintf("DEVICE_FAMILY: PIC32\r\n");
  40. rt_kprintf("CPU_ARCHITECTURE: MIPS\r\n");
  41. rt_kprintf("CPU_FREQ: %uMHz\r\n",SYS_FREQ/1000000UL);
  42. }
  43. /**
  44. * This function will initial FM3 Easy Kit board.
  45. */
  46. void rt_hw_board_init()
  47. {
  48. // Configure the device for maximum performance, but do not change the PBDIV clock divisor.
  49. // Given the options, this function will change the program Flash wait states,
  50. // RAM wait state and enable prefetch cache, but will not change the PBDIV.
  51. // The PBDIV value is already set via the pragma FPBDIV option above.
  52. SYSTEMConfig(SYS_FREQ, SYS_CFG_WAIT_STATES | SYS_CFG_PCACHE);
  53. rt_hw_console_init();
  54. rt_hw_show_info();
  55. }