FreeCalypso > hg > freecalypso-sw
comparison gsm-fw/bsp/abb+spi/spi_drv.c @ 148:63750f70796d
gsm-fw/bsp/abb+spi: initial import from the Leonardo TCS211 version
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Sat, 16 Nov 2013 19:03:37 +0000 |
parents | |
children | e48ea5875df7 |
comparison
equal
deleted
inserted
replaced
147:4ac657b95f52 | 148:63750f70796d |
---|---|
1 /**********************************************************************************/ | |
2 /* TEXAS INSTRUMENTS INCORPORATED PROPRIETARY INFORMATION */ | |
3 /* */ | |
4 /* Property of Texas Instruments -- For Unrestricted Internal Use Only */ | |
5 /* Unauthorized reproduction and/or distribution is strictly prohibited. This */ | |
6 /* product is protected under copyright law and trade secret law as an */ | |
7 /* unpublished work. Created 1987, (C) Copyright 1997 Texas Instruments. All */ | |
8 /* rights reserved. */ | |
9 /* */ | |
10 /* */ | |
11 /* Filename : spi_drv.c */ | |
12 /* */ | |
13 /* Description : Functions to drive the SPI module. */ | |
14 /* The Serial Port Interface is a bidirectional 3 lines */ | |
15 /* interface dedicated to the transfer of data to and */ | |
16 /* from up to 5 external devices offering a 3 lines */ | |
17 /* serial interface. */ | |
18 /* In this project, it is only used to connect the TI */ | |
19 /* Analog BaseBand (ABB). */ | |
20 /* It is assumed that the ABB is connected as the SPI */ | |
21 /* device 0. */ | |
22 /* */ | |
23 /* This interface is specified to be compatible with */ | |
24 /* the UMA1018M Philips, the FUJITSU MB15F02, the */ | |
25 /* SIEMENS PMB2306T synthesizers and the TI ABB. */ | |
26 /* */ | |
27 /* This serial port is based on a looped shift-register */ | |
28 /* thus allowing both transmit (PISO) and receive (SIPO) */ | |
29 /* modes. */ | |
30 /* */ | |
31 /* */ | |
32 /* Author : Pascal PUEL */ | |
33 /* */ | |
34 /* Version number : 1.45 */ | |
35 /* */ | |
36 /* Date and time : 07/01/03 */ | |
37 /* */ | |
38 /* Previous delta : Rework */ | |
39 /* */ | |
40 /**********************************************************************************/ | |
41 | |
42 #include "spi/spi_drv.h" | |
43 | |
44 | |
45 | |
46 /*-----------------------------------------------------------------------*/ | |
47 /* SPI_InitDev() */ | |
48 /* */ | |
49 /* This function initializes the SPI registers for an external device */ | |
50 /* connected to the serial port. */ | |
51 /* */ | |
52 /*-----------------------------------------------------------------------*/ | |
53 void SPI_InitDev(T_SPI_DEV *Device) | |
54 { | |
55 unsigned short Param,Gate,Shiftval; | |
56 unsigned short Mask = 0x7bde; | |
57 | |
58 /* Clock enable, mask ITs and pre scale setting */ | |
59 * (volatile SYS_UWORD16 *) SPI_REG_SET1 = (SPI_CLK_ON | Device->PrescVal | SPI_IT_MASK_0 | SPI_IT_MASK_1); | |
60 | |
61 /* Building the parameter for REG_SET2 initialization */ | |
62 Shiftval = Device->DevId >> 7; | |
63 Param = (Device->ClkEdge | Device->TspEnLevel | Device->TspEnForm)<<Shiftval ; | |
64 Gate = Mask<<Shiftval; | |
65 | |
66 * (volatile SYS_UWORD16 *) SPI_REG_SET2 = (* (volatile SYS_UWORD16 *) SPI_REG_SET2 & Gate) | Param; | |
67 | |
68 | |
69 /* Configuring CTRL_REG : this writting erases the previous one */ | |
70 * (volatile SYS_UWORD16 *) SPI_REG_CTRL = (Device->DataTrLength | Device->DevId); | |
71 | |
72 /* Stop the SPI clock */ | |
73 #ifdef SPI_CLK_LOW_POWER | |
74 SPI_CLK_DISABLE | |
75 #endif | |
76 } | |
77 | |
78 | |
79 |