1 |
581 |
jeremybenn |
//*****************************************************************************
|
2 |
|
|
//
|
3 |
|
|
// pdc.c - Driver for the Peripheral Device Controller (PDC) on the Stellaris
|
4 |
|
|
// development board.
|
5 |
|
|
//
|
6 |
|
|
// Copyright (c) 2005,2006 Luminary Micro, Inc. All rights reserved.
|
7 |
|
|
//
|
8 |
|
|
// Software License Agreement
|
9 |
|
|
//
|
10 |
|
|
// Luminary Micro, Inc. (LMI) is supplying this software for use solely and
|
11 |
|
|
// exclusively on LMI's Stellaris Family of microcontroller products.
|
12 |
|
|
//
|
13 |
|
|
// The software is owned by LMI and/or its suppliers, and is protected under
|
14 |
|
|
// applicable copyright laws. All rights are reserved. Any use in violation
|
15 |
|
|
// of the foregoing restrictions may subject the user to criminal sanctions
|
16 |
|
|
// under applicable laws, as well as to civil liability for the breach of the
|
17 |
|
|
// terms and conditions of this license.
|
18 |
|
|
//
|
19 |
|
|
// THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
|
20 |
|
|
// OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
|
21 |
|
|
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
|
22 |
|
|
// LMI SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
|
23 |
|
|
// CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
|
24 |
|
|
//
|
25 |
|
|
//*****************************************************************************
|
26 |
|
|
|
27 |
|
|
#include "LM3Sxxx.h"
|
28 |
|
|
#include "pdc.h"
|
29 |
|
|
|
30 |
|
|
//*****************************************************************************
|
31 |
|
|
//
|
32 |
|
|
//! Initializes the connection to the PDC.
|
33 |
|
|
//!
|
34 |
|
|
//! This function will enable clocking to the SSI and GPIO A modules, configure
|
35 |
|
|
//! the GPIO pins to be used for an SSI interface, and it will configure the
|
36 |
|
|
//! SSI as a 1Mb master device, operating in MOTO mode. It will also enable
|
37 |
|
|
//! the SSI module, and will enable the chip select for the PDC on the
|
38 |
|
|
//! Stellaris development board.
|
39 |
|
|
//!
|
40 |
|
|
//! This function is contained in <tt>utils/pdc.c</tt>, with
|
41 |
|
|
//! <tt>utils/pdc.h</tt> containing the API definition for use by applications.
|
42 |
|
|
//!
|
43 |
|
|
//! \return None.
|
44 |
|
|
//
|
45 |
|
|
//*****************************************************************************
|
46 |
|
|
void
|
47 |
|
|
PDCInit(void)
|
48 |
|
|
{
|
49 |
|
|
//
|
50 |
|
|
// Enable the peripherals used to drive the PDC.
|
51 |
|
|
//
|
52 |
|
|
SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI);
|
53 |
|
|
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
|
54 |
|
|
|
55 |
|
|
//
|
56 |
|
|
// Configure the appropriate pins to be SSI instead of GPIO.
|
57 |
|
|
//
|
58 |
|
|
GPIODirModeSet(GPIO_PORTA_BASE, SSI_CLK | SSI_TX | SSI_RX,
|
59 |
|
|
GPIO_DIR_MODE_HW);
|
60 |
|
|
GPIODirModeSet(GPIO_PORTA_BASE, SSI_CS, GPIO_DIR_MODE_OUT);
|
61 |
|
|
GPIOPadConfigSet(GPIO_PORTA_BASE, SSI_CLK, GPIO_STRENGTH_4MA,
|
62 |
|
|
GPIO_PIN_TYPE_STD_WPU);
|
63 |
|
|
|
64 |
|
|
//
|
65 |
|
|
// Configure the SSI port.
|
66 |
|
|
//
|
67 |
|
|
SSIConfig(SSI_BASE, SSI_FRF_MOTO_MODE_0, SSI_MODE_MASTER, 1000000, 8);
|
68 |
|
|
SSIEnable(SSI_BASE);
|
69 |
|
|
|
70 |
|
|
//
|
71 |
|
|
// Reset the PDC SSI state machine. The chip select needs to be held low
|
72 |
|
|
// for 100ns; the procedure call overhead more than accounts for this time.
|
73 |
|
|
//
|
74 |
|
|
GPIOPinWrite(GPIO_PORTA_BASE, PDC_CS, 0);
|
75 |
|
|
GPIOPinWrite(GPIO_PORTA_BASE, PDC_CS, PDC_CS);
|
76 |
|
|
}
|
77 |
|
|
|
78 |
|
|
//*****************************************************************************
|
79 |
|
|
//
|
80 |
|
|
//! Write a PDC register.
|
81 |
|
|
//!
|
82 |
|
|
//! \param ucAddr specifies the PDC register to write.
|
83 |
|
|
//! \param ucData specifies the data to write.
|
84 |
|
|
//!
|
85 |
|
|
//! This function will perform the SSI transfers required to write a register
|
86 |
|
|
//! in the PDC on the Stellaris development board.
|
87 |
|
|
//!
|
88 |
|
|
//! This function is contained in <tt>utils/pdc.c</tt>, with
|
89 |
|
|
//! <tt>utils/pdc.h</tt> containing the API definition for use by applications.
|
90 |
|
|
//!
|
91 |
|
|
//! \return None.
|
92 |
|
|
//
|
93 |
|
|
//*****************************************************************************
|
94 |
|
|
void
|
95 |
|
|
PDCWrite(unsigned char ucAddr, unsigned char ucData)
|
96 |
|
|
{
|
97 |
|
|
unsigned long ulTemp;
|
98 |
|
|
|
99 |
|
|
//
|
100 |
|
|
// Send address and write command.
|
101 |
|
|
//
|
102 |
|
|
SSIDataPut(SSI_BASE, (ucAddr & 0x0F) | PDC_WR);
|
103 |
|
|
|
104 |
|
|
//
|
105 |
|
|
// Write the data.
|
106 |
|
|
//
|
107 |
|
|
SSIDataPut(SSI_BASE, ucData);
|
108 |
|
|
|
109 |
|
|
//
|
110 |
|
|
// Flush data read during address write.
|
111 |
|
|
//
|
112 |
|
|
SSIDataGet(SSI_BASE, &ulTemp);
|
113 |
|
|
|
114 |
|
|
//
|
115 |
|
|
// Flush data read during data write.
|
116 |
|
|
//
|
117 |
|
|
SSIDataGet(SSI_BASE, &ulTemp);
|
118 |
|
|
}
|