Paparazzi UAS  v4.0.4_stable-3-gf39211a
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
lcd_dogm_hw.c
Go to the documentation of this file.
1 /*
2  * $Id$
3  *
4  * Copyright (C) 2009 ENAC
5  *
6  * This file is part of paparazzi.
7  *
8  * paparazzi is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2, or (at your option)
11  * any later version.
12  *
13  * paparazzi is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with paparazzi; see the file COPYING. If not, write to
20  * the Free Software Foundation, 59 Temple Place - Suite 330,
21  * Boston, MA 02111-1307, USA.
22  *
23  */
24 
25 #include "LPC21xx.h"
26 #include "interrupt_hw.h"
27 #include "lcd_dogm_hw.h"
28 
29 
30 static void SPI1_ISR(void) __attribute__((naked));
31 
32 #define PINSEL1_SCK (2 << 2)
33 #define PINSEL1_MOSI (2 << 6)
34 #define PINSEL1_SSEL (2 << 8)
35 
36 /* SSPCR0 settings */
37 #define SSP_DSS 0x07 << 0 /* data size : 8 bits */
38 #define SSP_FRF 0x00 << 4 /* frame format : SPI */
39 #define SSP_CPOL 0x01 << 6 /* clock polarity : idle high */
40 #define SSP_CPHA 0x01 << 7 /* clock phase : low->high */
41 #define SSP_SCR 0x1F << 8 /* serial clock rate : 29.3kHz, SSP input clock / 16 */
42 
43 /* SSPCR1 settings */
44 #define SSP_LBM 0x00 << 0 /* loopback mode : disabled */
45 #define SSP_SSE 0x00 << 1 /* SSP enable : disabled */
46 #define SSP_MS 0x00 << 2 /* master slave mode : master */
47 #define SSP_SOD 0x00 << 3 /* slave output disable : don't care when master */
48 
49 #ifndef SSPCPSR_VAL
50 #define SSPCPSR_VAL 0x04
51 #endif
52 
53 
54 void lcd_spi_tx(uint8_t data) {
55  SpiClearRti();
56  SpiEnableRti();
57  SpiEnable();
58  SSPDR = data;
59 }
60 
61 void lcd_dogm_init_hw( void ) {
62  /* setup pins for SSP (SCK, MOSI) */
64 
65  /* setup SSP */
68  SSPCPSR = SSPCPSR_VAL; /* Prescaler */
69 
70  /* SS, RS pin is output */
73  /* unselected lcd */
75 
76  /* Configure interrupt vector for SPI */
77  VICIntSelect &= ~VIC_BIT(VIC_SPI1); /* SPI1 selected as IRQ */
78  VICIntEnable = VIC_BIT(VIC_SPI1); /* SPI1 interrupt enabled */
80  VICVectAddr7 = (uint32_t)SPI1_ISR; /* address of the ISR */
81 }
82 
83 void SPI1_ISR(void) {
84  ISR_ENTRY();
85 
86  while (bit_is_set(SSPSR, RNE)) {
87  uint16_t foo __attribute__ ((unused));
88  foo = SSPDR;
89  }
90  SpiClearRti(); /* clear interrupt */
91  SpiDisableRti();
92  SpiDisable ();
94 
95  VICVectAddr = 0x00000000; /* clear this interrupt from the VIC */
96  ISR_EXIT();
97 }
98 
#define VICIntSelect
Definition: LPC21xx.h:398
unsigned short uint16_t
Definition: types.h:16
#define PINSEL1_MOSI
#define SpiDisableRti()
Definition: spi_arch.h:80
#define SSP_FRF
#define SSPCPSR
Definition: LPC21xx.h:226
#define SSP_CPOL
#define SSP_SCR
#define SSP_MS
#define SSPCR0
Definition: LPC21xx.h:222
#define SpiClearRti()
Definition: spi_arch.h:84
#define SSP_SOD
#define SSPSR
Definition: LPC21xx.h:225
#define SSP_LBM
void lcd_dogm_init_hw(void)
Definition: lcd_dogm_hw.c:61
#define VICVectAddr
Definition: LPC21xx.h:404
unsigned long uint32_t
Definition: types.h:18
uint16_t foo
Definition: main_demo5.c:54
#define SpiEnable()
Definition: spi_arch.h:68
#define LCDDOGM_SS_PIN
Definition: lcd_dogm_hw.h:11
void lcd_spi_tx(uint8_t data)
#define VIC_BIT(chan)
Definition: lpcVIC.h:105
#define SSPCPSR_VAL
#define RNE
Definition: LPC21xx.h:247
unsigned char uint8_t
Definition: types.h:14
#define SpiDisable()
Definition: spi_arch.h:72
#define SSPDR
Definition: LPC21xx.h:224
#define ISR_EXIT()
Definition: armVIC.h:61
#define VICIntEnable
Definition: LPC21xx.h:399
#define PINSEL1
Definition: LPC21xx.h:316
#define lcddogmUnselect()
Definition: lcd_dogm_hw.h:31
#define VICVectAddr7
Definition: LPC21xx.h:413
#define SpiEnableRti()
Definition: spi_arch.h:76
#define VIC_SPI1
Definition: lpcVIC.h:81
#define LCDDOGM_RS_IODIR
Definition: lcd_dogm_hw.h:24
#define SSP_DSS
#define SSPCR1
Definition: LPC21xx.h:223
#define PINSEL1_SCK
#define LCDDOGM_SS_IODIR
Definition: lcd_dogm_hw.h:20
__attribute__((always_inline))
Definition: i2c_arch.c:35
#define LCDDOGM_RS_PIN
Definition: lcd_dogm_hw.h:14
#define ISR_ENTRY()
Definition: armVIC.h:40
static void SPI1_ISR(void)
Definition: lcd_dogm_hw.c:30
#define VIC_ENABLE
Definition: lpcVIC.h:102
#define VICVectCntl7
Definition: LPC21xx.h:429
#define SSP_CPHA