Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
F
fwatch
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
8
Issues
8
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
fwatch
Commits
57491331
Commit
57491331
authored
Aug 29, 2014
by
Projects
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lcd: EXTCOMIN signal is directly controlled by a timer.
parent
273f41f9
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
33 deletions
+50
-33
lcd.c
sw/common/drivers/lcd.c
+48
-32
lcd.h
sw/common/drivers/lcd.h
+1
-1
Makefile
sw/freertos/Makefile
+1
-0
No files found.
sw/common/drivers/lcd.c
View file @
57491331
...
...
@@ -28,6 +28,7 @@
#include <em_cmu.h>
#include <em_usart.h>
#include <em_rtc.h>
#include <em_timer.h>
#include <udelay.h>
// Enable 90* rotation
...
...
@@ -94,38 +95,53 @@ static void timer_delay(uint16_t usecs)
UDELAY_Delay
(
usecs
);
}
static
void
rtc
_setup
(
unsigned
int
frequency
)
static
void
extcomin
_setup
(
unsigned
int
frequency
)
{
RTC_Init_TypeDef
rtc_init
=
RTC_INIT_DEFAULT
;
CMU_ClockEnable
(
cmuClock_TIMER0
,
true
)
;
// Enable LE domain registers
if
(
!
(
CMU
->
HFCORECLKEN0
&
CMU_HFCORECLKEN0_LE
))
CMU_ClockEnable
(
cmuClock_CORELE
,
true
);
if
(
cmuSelect_LFXO
!=
CMU_ClockSelectGet
(
cmuClock_LFA
))
CMU_ClockSelectSet
(
cmuClock_LFA
,
cmuSelect_LFXO
);
CMU_ClockDivSet
(
cmuClock_RTC
,
cmuClkDiv_2
);
CMU_ClockEnable
(
cmuClock_RTC
,
true
);
// Initialize RTC
rtc_init
.
enable
=
false
;
// Do not start RTC after initialization is complete
rtc_init
.
debugRun
=
false
;
// Halt RTC when debugging
rtc_init
.
comp0Top
=
true
;
// Wrap around on COMP0 match
RTC_Init
(
&
rtc_init
);
RTC_CompareSet
(
0
,
(
CMU_ClockFreqGet
(
cmuClock_RTC
)
/
frequency
)
-
1
);
NVIC_EnableIRQ
(
RTC_IRQn
);
RTC_IntEnable
(
RTC_IEN_COMP0
);
RTC_Enable
(
true
);
}
void
RTC_IRQHandler
(
void
)
{
RTC_IntClear
(
RTC_IF_COMP0
);
GPIO_PinOutToggle
(
LCD_PORT_EXTCOMIN
,
LCD_PIN_EXTCOMIN
);
// Select CC channel parameters
TIMER_InitCC_TypeDef
timerCCInit
=
{
.
cufoa
=
timerOutputActionNone
,
.
cofoa
=
timerOutputActionToggle
,
.
cmoa
=
timerOutputActionNone
,
.
mode
=
timerCCModeCompare
,
.
filter
=
false
,
.
prsInput
=
false
,
.
coist
=
false
,
.
outInvert
=
false
,
};
// Configure CC channel
TIMER_InitCC
(
TIMER0
,
2
,
&
timerCCInit
);
// Route CC2 to location 1 (PE12) and enable pin
TIMER0
->
ROUTE
|=
(
TIMER_ROUTE_CC2PEN
|
TIMER_ROUTE_LOCATION_LOC0
);
// Set compare value starting at 0 - it will be incremented in the interrupt handler
TIMER_CompareBufSet
(
TIMER0
,
2
,
0
);
// Set Top Value
TIMER_TopSet
(
TIMER0
,
(
CMU_ClockFreqGet
(
cmuClock_HFPER
)
/
16
)
/
frequency
);
// Select timer parameters
TIMER_Init_TypeDef
timerInit
=
{
.
enable
=
true
,
.
debugRun
=
true
,
.
prescale
=
timerPrescale8
,
.
clkSel
=
timerClkSelHFPerClk
,
.
fallAction
=
timerInputActionNone
,
.
riseAction
=
timerInputActionNone
,
.
mode
=
timerModeUp
,
.
dmaClrAct
=
false
,
.
quadModeX4
=
false
,
.
oneShot
=
false
,
.
sync
=
false
,
};
// Configure timer
TIMER_Init
(
TIMER0
,
&
timerInit
);
}
void
lcd_init
(
void
)
...
...
@@ -147,8 +163,8 @@ void lcd_init(void)
// EXTMODE is hardwired
// GPIO_PinModeSet(LCD_PORT_EXTMODE, LCD_PIN_EXTMODE, gpioModePushPull, 0);
// Setup
RTC to generate interrupts at given frequency
rtc
_setup
(
LCD_POL_INV_FREQ
);
// Setup
timer to generate interrupts at given frequency for EXTCOMIN pin
extcomin
_setup
(
LCD_POL_INV_FREQ
);
lcd_power
(
1
);
...
...
sw/common/drivers/lcd.h
View file @
57491331
...
...
@@ -56,7 +56,7 @@
#define LCD_SPI_CLOCK cmuClock_USART2
#define LCD_SPI_LOCATION 0
#define LCD_SPI_BAUDRATE 500000
#define LCD_POL_INV_FREQ 6
4
#define LCD_POL_INV_FREQ 6
0
/**
* @brief LCD initialization routine.
...
...
sw/freertos/Makefile
View file @
57491331
...
...
@@ -135,6 +135,7 @@ C_SRC += \
../common/emlib/src/em_rmu.c
\
../common/emlib/src/em_rtc.c
\
../common/emlib/src/em_system.c
\
../common/emlib/src/em_timer.c
\
../common/emlib/src/em_usart.c
\
../common/emdrv/sleep/src/sleep.c
\
../common/drivers/lcd.c
\
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment