DSP2803x_I2C.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. //###########################################################################
  2. //
  3. // FILE: DSP2803x_I2C.c
  4. //
  5. // TITLE: DSP2803x I2C Initialization & Support Functions.
  6. //
  7. //###########################################################################
  8. // $TI Release: F2803x C/C++ Header Files and Peripheral Examples V130 $
  9. // $Release Date: May 8, 2015 $
  10. // $Copyright: Copyright (C) 2009-2015 Texas Instruments Incorporated -
  11. // http://www.ti.com/ ALL RIGHTS RESERVED $
  12. //###########################################################################
  13. #include "DSP2803x_Device.h" // DSP2803x Headerfile Include File
  14. #include "DSP2803x_Examples.h" // DSP2803x Examples Include File
  15. //---------------------------------------------------------------------------
  16. // InitI2C:
  17. //---------------------------------------------------------------------------
  18. // This function initializes the I2C to a known state.
  19. //
  20. void InitI2C(void)
  21. {
  22. // Initialize I2C-A:
  23. //tbd...
  24. }
  25. //---------------------------------------------------------------------------
  26. // Example: InitI2CGpio:
  27. //---------------------------------------------------------------------------
  28. // This function initializes GPIO pins to function as I2C pins
  29. //
  30. // Each GPIO pin can be configured as a GPIO pin or up to 3 different
  31. // peripheral functional pins. By default all pins come up as GPIO
  32. // inputs after reset.
  33. //
  34. // Caution:
  35. // Only one GPIO pin should be enabled for SDAA operation.
  36. // Only one GPIO pin shoudl be enabled for SCLA operation.
  37. // Comment out other unwanted lines.
  38. void InitI2CGpio()
  39. {
  40. EALLOW;
  41. /* Enable internal pull-up for the selected pins */
  42. // Pull-ups can be enabled or disabled disabled by the user.
  43. // This will enable the pullups for the specified pins.
  44. // Comment out other unwanted lines.
  45. GpioCtrlRegs.GPAPUD.bit.GPIO28 = 0; // Enable pull-up for GPIO28 (SDAA)
  46. GpioCtrlRegs.GPAPUD.bit.GPIO29 = 0; // Enable pull-up for GPIO29 (SCLA)
  47. // GpioCtrlRegs.GPBPUD.bit.GPIO32 = 0; // Enable pull-up for GPIO32 (SDAA)
  48. // GpioCtrlRegs.GPBPUD.bit.GPIO33 = 0; // Enable pull-up for GPIO33 (SCLA)
  49. /* Set qualification for selected pins to asynch only */
  50. // This will select asynch (no qualification) for the selected pins.
  51. // Comment out other unwanted lines.
  52. GpioCtrlRegs.GPAQSEL2.bit.GPIO28 = 3; // Asynch input GPIO28 (SDAA)
  53. GpioCtrlRegs.GPAQSEL2.bit.GPIO29 = 3; // Asynch input GPIO29 (SCLA)
  54. // GpioCtrlRegs.GPBQSEL1.bit.GPIO32 = 3; // Asynch input GPIO32 (SDAA)
  55. // GpioCtrlRegs.GPBQSEL1.bit.GPIO33 = 3; // Asynch input GPIO33 (SCLA)
  56. /* Configure I2C pins using GPIO regs*/
  57. // This specifies which of the possible GPIO pins will be I2C functional pins.
  58. // Comment out other unwanted lines.
  59. GpioCtrlRegs.GPAMUX2.bit.GPIO28 = 2; // Configure GPIO28 for SDAA operation
  60. GpioCtrlRegs.GPAMUX2.bit.GPIO29 = 2; // Configure GPIO29 for SCLA operation
  61. // GpioCtrlRegs.GPBMUX1.bit.GPIO32 = 1; // Configure GPIO32 for SDAA operation
  62. // GpioCtrlRegs.GPBMUX1.bit.GPIO33 = 1; // Configure GPIO33 for SCLA operation
  63. EDIS;
  64. }
  65. //===========================================================================
  66. // End of file.
  67. //===========================================================================