mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-08-19 09:38:32 -04:00
Add FreeRTOS-Plus directory.
This commit is contained in:
parent
7bd5f21ad5
commit
f508a5f653
6798 changed files with 134949 additions and 19 deletions
542
FreeRTOS/Demo/CORTEX_EFMG890F128_IAR/lcd/lcdcontroller.c
Normal file
542
FreeRTOS/Demo/CORTEX_EFMG890F128_IAR/lcd/lcdcontroller.c
Normal file
|
@ -0,0 +1,542 @@
|
|||
/**************************************************************************//**
|
||||
* @file
|
||||
* @brief LCD Controller driver
|
||||
* @author Energy Micro AS
|
||||
* @version 1.0.1
|
||||
******************************************************************************
|
||||
* @section License
|
||||
* <b>(C) Copyright 2009 Energy Micro AS, http://www.energymicro.com</b>
|
||||
******************************************************************************
|
||||
*
|
||||
* This source code is the property of Energy Micro AS. The source and compiled
|
||||
* code may only be used on Energy Micro "EFM32" microcontrollers.
|
||||
*
|
||||
* This copyright notice may not be removed from the source code nor changed.
|
||||
*
|
||||
* DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Energy Micro AS has no
|
||||
* obligation to support this Software. Energy Micro AS is providing the
|
||||
* Software "AS IS", with no express or implied warranties of any kind,
|
||||
* including, but not limited to, any implied warranties of merchantability
|
||||
* or fitness for any particular purpose or warranties against infringement
|
||||
* of any proprietary rights of a third party.
|
||||
*
|
||||
* Energy Micro AS will not be liable for any consequential, incidental, or
|
||||
* special damages, or any other relief, or for any claim by any third party,
|
||||
* arising from your use of this Software.
|
||||
*
|
||||
*****************************************************************************/
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "efm32.h"
|
||||
#include "lcdcontroller.h"
|
||||
#include "lcddisplay.h"
|
||||
|
||||
/** Counts every n'th frame */
|
||||
int frameCounter = 0;
|
||||
|
||||
/**************************************************************************//**
|
||||
* @brief LCD Interrupt Handler, triggers on frame counter, every n'th frame
|
||||
*****************************************************************************/
|
||||
void LCD_IRQHandler(void)
|
||||
{
|
||||
LCD_TypeDef *lcd = LCD;
|
||||
|
||||
/* clear interrupt */
|
||||
lcd->IFC = 0xFFFFFFFF;
|
||||
frameCounter++;
|
||||
}
|
||||
|
||||
/**************************************************************************//**
|
||||
* @brief Enables a segment on the LCD display
|
||||
* @param lcd Pointer to LCD register block
|
||||
* @param com COM segment number
|
||||
* @param bitvalue Bit value for segment
|
||||
*****************************************************************************/
|
||||
static void LCD_enableSegment(LCD_TypeDef * lcd, int com, int bitvalue)
|
||||
{
|
||||
switch (com)
|
||||
{
|
||||
case 0:
|
||||
lcd->SEGD0L |= bitvalue;
|
||||
break;
|
||||
case 1:
|
||||
lcd->SEGD1L |= bitvalue;
|
||||
break;
|
||||
case 2:
|
||||
lcd->SEGD2L |= bitvalue;
|
||||
break;
|
||||
case 3:
|
||||
lcd->SEGD3L |= bitvalue;
|
||||
break;
|
||||
case 4:
|
||||
lcd->SEGD0H |= bitvalue;
|
||||
break;
|
||||
case 5:
|
||||
lcd->SEGD1H |= bitvalue;
|
||||
break;
|
||||
case 6:
|
||||
lcd->SEGD2H |= bitvalue;
|
||||
break;
|
||||
case 7:
|
||||
lcd->SEGD3H |= bitvalue;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**************************************************************************//**
|
||||
* @brief Disables a segment on the LCD Display
|
||||
* @param lcd Pointer to LCD register structure
|
||||
* @param com COM segment number
|
||||
* @param bitvalue Bit value for segment
|
||||
*****************************************************************************/
|
||||
static void LCD_disableSegment(LCD_TypeDef * lcd, int com, int bitvalue)
|
||||
{
|
||||
switch (com)
|
||||
{
|
||||
case 0:
|
||||
lcd->SEGD0L &= ~bitvalue;
|
||||
break;
|
||||
case 1:
|
||||
lcd->SEGD1L &= ~bitvalue;
|
||||
break;
|
||||
case 2:
|
||||
lcd->SEGD2L &= ~bitvalue;
|
||||
break;
|
||||
case 3:
|
||||
lcd->SEGD3L &= ~bitvalue;
|
||||
break;
|
||||
case 4:
|
||||
lcd->SEGD0H &= ~bitvalue;
|
||||
break;
|
||||
case 5:
|
||||
lcd->SEGD1H &= ~bitvalue;
|
||||
break;
|
||||
case 6:
|
||||
lcd->SEGD2H &= ~bitvalue;
|
||||
break;
|
||||
case 7:
|
||||
lcd->SEGD3H &= ~bitvalue;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**************************************************************************//**
|
||||
* @brief Write number on numeric part on LCD display
|
||||
* @param lcd Pointer to LCD control block
|
||||
* @param value Numeric value to put on display, in range -999 to +9999
|
||||
*****************************************************************************/
|
||||
void LCD_Number(LCD_TypeDef *lcd, int value)
|
||||
{
|
||||
int num, i, com, bit, digit, div, neg;
|
||||
uint16_t bitpattern;
|
||||
|
||||
/* Parameter consistancy check */
|
||||
if (value >= 9999)
|
||||
{
|
||||
value = 9999;
|
||||
}
|
||||
if (value <= -1000)
|
||||
{
|
||||
value = -999;
|
||||
}
|
||||
if (value < 0)
|
||||
{
|
||||
value = abs(value);
|
||||
neg = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
neg = 0;
|
||||
}
|
||||
/* Extract useful digits */
|
||||
div = 1;
|
||||
for (digit = 0; digit < 4; digit++)
|
||||
{
|
||||
num = (value / div) % 10;
|
||||
if ((neg == 1) && (digit == 3)) num = 10;
|
||||
bitpattern = EM_Numbers[num];
|
||||
for (i = 0; i < 7; i++)
|
||||
{
|
||||
bit = EFMDisplay.Number[digit].bit[i];
|
||||
com = EFMDisplay.Number[digit].com[i];
|
||||
if (bitpattern & (1 << i))
|
||||
{
|
||||
LCD_enableSegment(lcd, com, 1 << bit);
|
||||
}
|
||||
else
|
||||
{
|
||||
LCD_disableSegment(lcd, com, 1 << bit);
|
||||
}
|
||||
}
|
||||
div = div * 10;
|
||||
}
|
||||
}
|
||||
|
||||
/**************************************************************************//**
|
||||
* @brief Turn all segments on numeric display off
|
||||
* @param lcd Pointer to LCD register structure
|
||||
*****************************************************************************/
|
||||
void LCD_NumberOff(LCD_TypeDef *lcd)
|
||||
{
|
||||
int digit, i, bit, com;
|
||||
|
||||
/* Turn off all segments */
|
||||
for (digit = 0; digit < 4; digit++)
|
||||
{
|
||||
for (i = 0; i < 7; i++)
|
||||
{
|
||||
bit = EFMDisplay.Number[digit].bit[i];
|
||||
com = EFMDisplay.Number[digit].com[i];
|
||||
LCD_disableSegment(lcd, com, 1 << bit);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************//**
|
||||
* @brief Write text on LCD display
|
||||
* @param lcd Pointer to LCD register structure
|
||||
* @param string Text string to show on display
|
||||
*****************************************************************************/
|
||||
void LCD_Write(LCD_TypeDef *lcd, char *string)
|
||||
{
|
||||
int data, length, index;
|
||||
uint16_t bitfield;
|
||||
uint32_t value;
|
||||
uint32_t com, bit;
|
||||
int i;
|
||||
|
||||
length = strlen(string);
|
||||
index = 0;
|
||||
/* fill out all characters on display */
|
||||
for (index = 0; index < 7; index++)
|
||||
{
|
||||
if (index < length)
|
||||
{
|
||||
data = (int) *string;
|
||||
}
|
||||
else /* padding with space */
|
||||
{
|
||||
data = 0x20; /* SPACE */
|
||||
}
|
||||
/* defined letters currently starts at "SPACE" - 0x20; */
|
||||
data = data - 0x20;
|
||||
bitfield = EM_alphabet[data];
|
||||
|
||||
|
||||
for (i = 0; i < 14; i++)
|
||||
{
|
||||
bit = EFMDisplay.Text[index].bit[i];
|
||||
com = EFMDisplay.Text[index].com[i];
|
||||
value = (1 << bit);
|
||||
|
||||
if (bitfield & (1 << i))
|
||||
{
|
||||
/* Turn on segment */
|
||||
LCD_enableSegment(lcd, com, value);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Turn off segment */
|
||||
LCD_disableSegment(lcd, com, value);
|
||||
}
|
||||
}
|
||||
string++;
|
||||
}
|
||||
while (lcd->SYNCBUSY) ;
|
||||
}
|
||||
|
||||
/**************************************************************************//**
|
||||
* @brief LCD Disable all segments
|
||||
* @param lcd Pointer to LCD register block
|
||||
*****************************************************************************/
|
||||
void LCD_AllOff(LCD_TypeDef *lcd)
|
||||
{
|
||||
lcd->SEGD0L = 0x00000000;
|
||||
lcd->SEGD0H = 0x00000000;
|
||||
lcd->SEGD1L = 0x00000000;
|
||||
lcd->SEGD1H = 0x00000000;
|
||||
lcd->SEGD2L = 0x00000000;
|
||||
lcd->SEGD2H = 0x00000000;
|
||||
lcd->SEGD3L = 0x00000000;
|
||||
lcd->SEGD3H = 0x00000000;
|
||||
while (lcd->SYNCBUSY) ;
|
||||
}
|
||||
|
||||
/**************************************************************************//**
|
||||
* @brief LCD Enable all segments
|
||||
* @param lcd Pointer to LCD register block
|
||||
*****************************************************************************/
|
||||
void LCD_AllOn(LCD_TypeDef *lcd)
|
||||
{
|
||||
lcd->SEGD0L = 0xffffffff;
|
||||
lcd->SEGD0H = 0xffffffff;
|
||||
lcd->SEGD1L = 0xffffffff;
|
||||
lcd->SEGD1H = 0xffffffff;
|
||||
lcd->SEGD2L = 0xffffffff;
|
||||
lcd->SEGD2H = 0xffffffff;
|
||||
lcd->SEGD3L = 0xffffffff;
|
||||
lcd->SEGD3H = 0xffffffff;
|
||||
while (lcd->SYNCBUSY) ;
|
||||
}
|
||||
|
||||
/**************************************************************************//**
|
||||
* @brief LCD Light up or shut off Energy Mode indicator
|
||||
* @param lcd Pointer to LCD register block
|
||||
* @pararm em Energy Mode numer 0 to 4
|
||||
* @param on Zero is off, non-zero is on
|
||||
*****************************************************************************/
|
||||
void LCD_EnergyMode(LCD_TypeDef *lcd, int em, int on)
|
||||
{
|
||||
uint32_t com, bitvalue;
|
||||
|
||||
com = EFMDisplay.EMode.com[em];
|
||||
bitvalue = 1 << EFMDisplay.EMode.bit[em];
|
||||
|
||||
if (on)
|
||||
{
|
||||
LCD_enableSegment(lcd, com, bitvalue);
|
||||
}
|
||||
else
|
||||
{
|
||||
LCD_disableSegment(lcd, com, bitvalue);
|
||||
}
|
||||
}
|
||||
|
||||
/**************************************************************************//**
|
||||
* @brief LCD Light up or shut off Ring of Indicators
|
||||
* @param lcd Pointer to LCD register block
|
||||
* @param anum "Segment number" on "Ring", range 0 - 7
|
||||
* @param on Zero is off, non-zero is on
|
||||
*****************************************************************************/
|
||||
void LCD_ARing(LCD_TypeDef *lcd, int anum, int on)
|
||||
{
|
||||
uint32_t com, bitvalue;
|
||||
|
||||
com = EFMDisplay.ARing.com[anum];
|
||||
bitvalue = 1 << EFMDisplay.ARing.bit[anum];
|
||||
|
||||
if (on)
|
||||
{
|
||||
LCD_enableSegment(lcd, com, bitvalue);
|
||||
}
|
||||
else
|
||||
{
|
||||
LCD_disableSegment(lcd, com, bitvalue);
|
||||
}
|
||||
}
|
||||
|
||||
/**************************************************************************//**
|
||||
* @brief LCD Light up or shut off various symbols on LCD Display
|
||||
* @param lcd Pointer to LCD register block
|
||||
* @param s Which symbol to turn on or off
|
||||
* @param on Zero is off, non-zero is on
|
||||
*****************************************************************************/
|
||||
void LCD_Symbol(LCD_TypeDef *lcd, lcdSymbol s, int on)
|
||||
{
|
||||
int com, bit;
|
||||
|
||||
switch (s)
|
||||
{
|
||||
case LCD_SYMBOL_GECKO:
|
||||
com = 3; bit = 8;
|
||||
break;
|
||||
case LCD_SYMBOL_ANT:
|
||||
com = 3; bit = 1;
|
||||
break;
|
||||
case LCD_SYMBOL_PAD0:
|
||||
com = 1; bit = 8;
|
||||
break;
|
||||
case LCD_SYMBOL_PAD1:
|
||||
com = 2; bit = 8;
|
||||
break;
|
||||
case LCD_SYMBOL_AM:
|
||||
com = 4; bit = 0;
|
||||
break;
|
||||
case LCD_SYMBOL_PM:
|
||||
com = 4; bit = 3;
|
||||
break;
|
||||
case LCD_SYMBOL_EFM32:
|
||||
com = 0; bit = 8;
|
||||
break;
|
||||
case LCD_SYMBOL_MINUS:
|
||||
com = 0; bit = 9;
|
||||
break;
|
||||
case LCD_SYMBOL_COL3:
|
||||
com = 0; bit = 16;
|
||||
break;
|
||||
case LCD_SYMBOL_COL5:
|
||||
com = 0; bit = 24;
|
||||
break;
|
||||
case LCD_SYMBOL_COL10:
|
||||
com = 4; bit = 7;
|
||||
break;
|
||||
case LCD_SYMBOL_DP2:
|
||||
com = 4; bit = 2;
|
||||
break;
|
||||
case LCD_SYMBOL_DP3:
|
||||
com = 5; bit = 2;
|
||||
break;
|
||||
case LCD_SYMBOL_DP4:
|
||||
com = 6; bit = 2;
|
||||
break;
|
||||
case LCD_SYMBOL_DP5:
|
||||
com = 7; bit = 2;
|
||||
break;
|
||||
case LCD_SYMBOL_DP6:
|
||||
com = 0; bit = 21;
|
||||
break;
|
||||
case LCD_SYMBOL_DP10:
|
||||
com = 4; bit = 5;
|
||||
break;
|
||||
}
|
||||
if (on)
|
||||
{
|
||||
LCD_enableSegment(lcd, com, 1 << bit);
|
||||
}
|
||||
else
|
||||
{
|
||||
LCD_disableSegment(lcd, com, 1 << bit);
|
||||
}
|
||||
}
|
||||
|
||||
/**************************************************************************//**
|
||||
* @brief LCD Light up or shut off Battery Indicator
|
||||
* @param lcd Pointer to LCD register block
|
||||
* @param batteryLevel Battery Level, 0 to 4 (0 turns all off)
|
||||
*****************************************************************************/
|
||||
void LCD_Battery(LCD_TypeDef *lcd, int batteryLevel)
|
||||
{
|
||||
uint32_t com, bitvalue;
|
||||
int i, on;
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
if (i < batteryLevel)
|
||||
{
|
||||
on = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
on = 0;
|
||||
}
|
||||
com = EFMDisplay.Battery.com[i];
|
||||
bitvalue = 1 << EFMDisplay.Battery.bit[i];
|
||||
|
||||
if (on)
|
||||
{
|
||||
LCD_enableSegment(lcd, com, bitvalue);
|
||||
}
|
||||
else
|
||||
{
|
||||
LCD_disableSegment(lcd, com, bitvalue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**************************************************************************//**
|
||||
* @brief LCD Initialization routine for EFM32 DVK display
|
||||
* @param lcd Pointer to LCD register block
|
||||
*****************************************************************************/
|
||||
void LCD_Init(LCD_TypeDef *lcd)
|
||||
{
|
||||
CMU_TypeDef *cmu = CMU;
|
||||
|
||||
/* Enable LFXO oscillator */
|
||||
cmu->OSCENCMD |= CMU_OSCENCMD_LFXOEN;
|
||||
while (!(cmu->STATUS & CMU_STATUS_LFXORDY)) ;
|
||||
|
||||
/* Enable LCD clock in CMU */
|
||||
cmu->LFACLKEN0 |= CMU_LFACLKEN0_LCD;
|
||||
|
||||
/* Select LFXO for LCD */
|
||||
cmu->LFCLKSEL = CMU_LFCLKSEL_LFA_LFXO | CMU_LFCLKSEL_LFB_LFXO;
|
||||
|
||||
/* LCD Controller Prescaler (divide by 1) */
|
||||
/* CLKlcd = 0.25 kHz */
|
||||
cmu->LFAPRESC0 &= ~_CMU_LFAPRESC0_LCD_MASK;
|
||||
cmu->LFAPRESC0 |= _CMU_LFAPRESC0_LCD_DIV128 << _CMU_LFAPRESC0_LCD_SHIFT;
|
||||
|
||||
/* Set up interrupt handler */
|
||||
lcd->IEN = 0;
|
||||
while (lcd->SYNCBUSY) ;
|
||||
|
||||
/* Clear pending interrupts */
|
||||
lcd->IFC = ~0;
|
||||
/* Enable interrupt */
|
||||
NVIC_EnableIRQ(LCD_IRQn);
|
||||
lcd->IEN = LCD_IEN_FC;
|
||||
|
||||
/* Frame rate is 32Hz, 0.25Khz LFCLK128, QUADRUPLEX mode, FDIV=0 */
|
||||
lcd->DISPCTRL = LCD_DISPCTRL_MUX_QUADRUPLEX |
|
||||
LCD_DISPCTRL_BIAS_ONETHIRD |
|
||||
LCD_DISPCTRL_WAVE_LOWPOWER |
|
||||
LCD_DISPCTRL_CONLEV_MAX |
|
||||
LCD_DISPCTRL_VLCDSEL_VDD |
|
||||
LCD_DISPCTRL_VBLEV_3V00;
|
||||
|
||||
/* No voltage boost, framerate 32Hz */
|
||||
cmu->LCDCTRL = 0;
|
||||
|
||||
/* Turn all segments off */
|
||||
LCD_AllOff(lcd);
|
||||
|
||||
/* Enable all segment registers */
|
||||
lcd->SEGEN = 0x000003FF;
|
||||
lcd->CTRL = LCD_CTRL_EN | LCD_CTRL_UDCTRL_FRAMESTART;
|
||||
while (lcd->SYNCBUSY) ;
|
||||
|
||||
/* Configure LCD to give a frame counter interrupt every 8th frame. */
|
||||
lcd->BACTRL = LCD_BACTRL_FCEN | (7 << _LCD_BACTRL_FCTOP_SHIFT) | (0 << _LCD_BACTRL_FCPRESC_SHIFT);
|
||||
while (lcd->SYNCBUSY) ;
|
||||
lcd->IFC = LCD_IFC_FC;
|
||||
lcd->IEN = LCD_IEN_FC;
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************//**
|
||||
* @brief Disables LCD controller
|
||||
* @param lcd Pointer to LCD register block
|
||||
*****************************************************************************/
|
||||
void LCD_Disable(LCD_TypeDef *lcd)
|
||||
{
|
||||
CMU_TypeDef *cmu = CMU;
|
||||
|
||||
/* Turn off interrupts */
|
||||
lcd->IEN = 0x00000000;
|
||||
lcd->IFC = LCD_IFC_FC;
|
||||
NVIC_DisableIRQ(LCD_IRQn);
|
||||
/* Disable LCD */
|
||||
lcd->CTRL = 0;
|
||||
/* Turn off LCD clock */
|
||||
cmu->LFACLKEN0 &= ~(CMU_LFACLKEN0_LCD);
|
||||
/* Turn off voltage boost if enabled */
|
||||
cmu->LCDCTRL = 0;
|
||||
}
|
||||
|
||||
/**************************************************************************//**
|
||||
* @brief LCD scrolls a text over the display, sort of "polled printf"
|
||||
* @param lcd Pointer to LCD register block
|
||||
*****************************************************************************/
|
||||
void LCD_ScrollText(LCD_TypeDef *lcd, char *scrolltext)
|
||||
{
|
||||
int i, len;
|
||||
char buffer[8];
|
||||
|
||||
buffer[7] = 0x00;
|
||||
len = strlen(scrolltext);
|
||||
if (len < 7) return;
|
||||
for (i = 0; i < (len - 7); i++)
|
||||
{
|
||||
memcpy(buffer, scrolltext + i, 7);
|
||||
LCD_Write(lcd, buffer);
|
||||
vTaskDelay(100/portTICK_RATE_MS);
|
||||
}
|
||||
}
|
||||
|
||||
|
73
FreeRTOS/Demo/CORTEX_EFMG890F128_IAR/lcd/lcdcontroller.h
Normal file
73
FreeRTOS/Demo/CORTEX_EFMG890F128_IAR/lcd/lcdcontroller.h
Normal file
|
@ -0,0 +1,73 @@
|
|||
/**************************************************************************//**
|
||||
* @file
|
||||
* @brief LCD Controller header file
|
||||
* @author Energy Micro AS
|
||||
* @version 1.0.1
|
||||
******************************************************************************
|
||||
* @section License
|
||||
* <b>(C) Copyright 2009 Energy Micro AS, http://www.energymicro.com</b>
|
||||
******************************************************************************
|
||||
*
|
||||
* This source code is the property of Energy Micro AS. The source and compiled
|
||||
* code may only be used on Energy Micro "EFM32" microcontrollers.
|
||||
*
|
||||
* This copyright notice may not be removed from the source code nor changed.
|
||||
*
|
||||
* DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Energy Micro AS has no
|
||||
* obligation to support this Software. Energy Micro AS is providing the
|
||||
* Software "AS IS", with no express or implied warranties of any kind,
|
||||
* including, but not limited to, any implied warranties of merchantability
|
||||
* or fitness for any particular purpose or warranties against infringement
|
||||
* of any proprietary rights of a third party.
|
||||
*
|
||||
* Energy Micro AS will not be liable for any consequential, incidental, or
|
||||
* special damages, or any other relief, or for any claim by any third party,
|
||||
* arising from your use of this Software.
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef _LCDCONTROLLER_H
|
||||
#define _LCDCONTROLLER_H
|
||||
|
||||
#include "efm32.h"
|
||||
|
||||
/* Range of symbols available on display */
|
||||
typedef enum
|
||||
{
|
||||
LCD_SYMBOL_GECKO,
|
||||
LCD_SYMBOL_ANT,
|
||||
LCD_SYMBOL_PAD0,
|
||||
LCD_SYMBOL_PAD1,
|
||||
LCD_SYMBOL_AM,
|
||||
LCD_SYMBOL_PM,
|
||||
LCD_SYMBOL_EFM32,
|
||||
LCD_SYMBOL_MINUS,
|
||||
LCD_SYMBOL_COL3,
|
||||
LCD_SYMBOL_COL5,
|
||||
LCD_SYMBOL_COL10,
|
||||
LCD_SYMBOL_DP2,
|
||||
LCD_SYMBOL_DP3,
|
||||
LCD_SYMBOL_DP4,
|
||||
LCD_SYMBOL_DP5,
|
||||
LCD_SYMBOL_DP6,
|
||||
LCD_SYMBOL_DP10,
|
||||
} lcdSymbol;
|
||||
|
||||
/* Regular functions */
|
||||
void LCD_Init(LCD_TypeDef *lcd);
|
||||
void LCD_IRQHandler(void);
|
||||
void LCD_Disable(LCD_TypeDef *lcd);
|
||||
|
||||
void LCD_AllOff(LCD_TypeDef *lcd);
|
||||
void LCD_AllOn(LCD_TypeDef *lcd);
|
||||
|
||||
void LCD_ARing(LCD_TypeDef *lcd, int anum, int on);
|
||||
void LCD_Battery(LCD_TypeDef *lcd, int batteryLevel);
|
||||
void LCD_EnergyMode(LCD_TypeDef *lcd, int em, int on);
|
||||
void LCD_Number(LCD_TypeDef *lcd, int value);
|
||||
void LCD_NumberOff(LCD_TypeDef *lcd);
|
||||
void LCD_Symbol(LCD_TypeDef *lcd, lcdSymbol s, int on);
|
||||
void LCD_Write(LCD_TypeDef *lcd, char *string);
|
||||
void LCD_ScrollText(LCD_TypeDef *lcd, char *scrolltext);
|
||||
|
||||
#endif
|
391
FreeRTOS/Demo/CORTEX_EFMG890F128_IAR/lcd/lcddisplay.h
Normal file
391
FreeRTOS/Demo/CORTEX_EFMG890F128_IAR/lcd/lcddisplay.h
Normal file
|
@ -0,0 +1,391 @@
|
|||
/**************************************************************************//**
|
||||
* @file
|
||||
* @brief LCD Controller font and display layout for EFM32 development MCU
|
||||
* module
|
||||
* @author Energy Micro AS
|
||||
* @version 1.0.1
|
||||
******************************************************************************
|
||||
* @section License
|
||||
* <b>(C) Copyright 2009 Energy Micro AS, http://www.energymicro.com</b>
|
||||
******************************************************************************
|
||||
*
|
||||
* This source code is the property of Energy Micro AS. The source and compiled
|
||||
* code may only be used on Energy Micro "EFM32" microcontrollers.
|
||||
*
|
||||
* This copyright notice may not be removed from the source code nor changed.
|
||||
*
|
||||
* DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Energy Micro AS has no
|
||||
* obligation to support this Software. Energy Micro AS is providing the
|
||||
* Software "AS IS", with no express or implied warranties of any kind,
|
||||
* including, but not limited to, any implied warranties of merchantability
|
||||
* or fitness for any particular purpose or warranties against infringement
|
||||
* of any proprietary rights of a third party.
|
||||
*
|
||||
* Energy Micro AS will not be liable for any consequential, incidental, or
|
||||
* special damages, or any other relief, or for any claim by any third party,
|
||||
* arising from your use of this Software.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef _LCDDISPLAY_H
|
||||
#define _LCDDISPLAY_H
|
||||
|
||||
#include <stdint.h>
|
||||
/**************************************************************************//**
|
||||
* @brief
|
||||
* Defines each text symbol's segment in terms of COM and BIT numbers,
|
||||
* in a way that we can enumerate each bit for each text segment in the
|
||||
* following bit pattern:
|
||||
* @verbatim
|
||||
* -------0------
|
||||
*
|
||||
* | \7 |8 /9 |
|
||||
* |5 \ | / |1
|
||||
*
|
||||
* --6--- ---10--
|
||||
*
|
||||
* | / | \11 |
|
||||
* |4 /13 |12 \ |2
|
||||
*
|
||||
* -------3------
|
||||
* @endverbatim
|
||||
* E.g.: First text character bit pattern #3 (above) is
|
||||
* Segment 1D for Display
|
||||
* Location COM 3, BIT 0
|
||||
*****************************************************************************/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t com[14]; /**< LCD COM line (for multiplexing) */
|
||||
uint32_t bit[14]; /**< LCD bit number */
|
||||
} CHAR_TypeDef;
|
||||
|
||||
|
||||
/**************************************************************************//**
|
||||
* @brief Defines segment COM and BIT fields numeric display
|
||||
*****************************************************************************/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t com[7];
|
||||
uint32_t bit[7];
|
||||
} NUMBER_TypeDef;
|
||||
|
||||
/**************************************************************************//**
|
||||
* @brief Defines segment COM and BIT fields for Energy Modes on display
|
||||
*****************************************************************************/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t com[5]; /**< LCD COM line (for multiplexing) */
|
||||
uint32_t bit[5]; /**< LCD bit number */
|
||||
} EM_TypeDef;
|
||||
|
||||
/**************************************************************************//**
|
||||
* @brief Defines segment COM and BIT fields for A-wheel (suited for Anim)
|
||||
*****************************************************************************/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t com[8]; /**< LCD COM line (for multiplexing) */
|
||||
uint32_t bit[8]; /**< LCD bit number */
|
||||
} ARING_TypeDef;
|
||||
|
||||
/**************************************************************************//**
|
||||
* @brief Defines segment COM and BIT fields for A-wheel (suited for Anim)
|
||||
*****************************************************************************/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t com[4]; /**< LCD COM line (for multiplexing) */
|
||||
uint32_t bit[4]; /**< LCD bit number */
|
||||
} BATTERY_TypeDef;
|
||||
|
||||
/**************************************************************************//**
|
||||
* @brief Defines prototype for all segments in display
|
||||
*****************************************************************************/
|
||||
typedef struct
|
||||
{
|
||||
CHAR_TypeDef Text[7];
|
||||
NUMBER_TypeDef Number[4];
|
||||
EM_TypeDef EMode;
|
||||
ARING_TypeDef ARing;
|
||||
BATTERY_TypeDef Battery;
|
||||
} MCU_DISPLAY;
|
||||
|
||||
/**************************************************************************//**
|
||||
* @brief Working instance of LCD display
|
||||
*****************************************************************************/
|
||||
MCU_DISPLAY EFMDisplay = {
|
||||
.Text = {
|
||||
{ /* 1 */
|
||||
.com[0] = 3, .com[1] = 3, .com[2] = 1, .com[3] = 0,
|
||||
.bit[0] = 10, .bit[1] = 12, .bit[2] = 12, .bit[3] = 10,
|
||||
|
||||
.com[4] = 1, .com[5] = 3, .com[6] = 2, .com[7] = 2,
|
||||
.bit[4] = 9, .bit[5] = 9, .bit[6] = 9, .bit[7] = 10,
|
||||
|
||||
.com[8] = 2, .com[9] = 3, .com[10] = 2, .com[11] = 0,
|
||||
.bit[8] = 11, .bit[9] = 11, .bit[10] = 12, .bit[11] = 11,
|
||||
|
||||
.com[12] = 1, .com[13] = 1,
|
||||
.bit[12] = 11, .bit[13] = 10
|
||||
},
|
||||
{ /* 2 */
|
||||
.com[0] = 3, .com[1] = 3, .com[2] = 1, .com[3] = 0,
|
||||
.bit[0] = 14, .bit[1] = 16, .bit[2] = 16, .bit[3] = 14,
|
||||
|
||||
.com[4] = 1, .com[5] = 3, .com[6] = 2, .com[7] = 2,
|
||||
.bit[4] = 13, .bit[5] = 13, .bit[6] = 13, .bit[7] = 14,
|
||||
|
||||
.com[8] = 2, .com[9] = 3, .com[10] = 2, .com[11] = 0,
|
||||
.bit[8] = 15, .bit[9] = 15, .bit[10] = 16, .bit[11] = 15,
|
||||
|
||||
.com[12] = 1, .com[13] = 1,
|
||||
.bit[12] = 15, .bit[13] = 14
|
||||
},
|
||||
{ /* 3 */
|
||||
.com[0] = 3, .com[1] = 3, .com[2] = 1, .com[3] = 0,
|
||||
.bit[0] = 18, .bit[1] = 20, .bit[2] = 20, .bit[3] = 18,
|
||||
|
||||
.com[4] = 1, .com[5] = 3, .com[6] = 2, .com[7] = 2,
|
||||
.bit[4] = 17, .bit[5] = 17, .bit[6] = 17, .bit[7] = 18,
|
||||
|
||||
.com[8] = 2, .com[9] = 3, .com[10] = 2, .com[11] = 0,
|
||||
.bit[8] = 19, .bit[9] = 19, .bit[10] = 20, .bit[11] = 19,
|
||||
|
||||
.com[12] = 1, .com[13] = 1,
|
||||
.bit[12] = 19, .bit[13] = 18
|
||||
},
|
||||
{ /* 4 */
|
||||
.com[0] = 3, .com[1] = 3, .com[2] = 1, .com[3] = 0,
|
||||
.bit[0] = 22, .bit[1] = 24, .bit[2] = 24, .bit[3] = 22,
|
||||
|
||||
.com[4] = 1, .com[5] = 3, .com[6] = 2, .com[7] = 2,
|
||||
.bit[4] = 21, .bit[5] = 21, .bit[6] = 21, .bit[7] = 22,
|
||||
|
||||
.com[8] = 2, .com[9] = 3, .com[10] = 2, .com[11] = 0,
|
||||
.bit[8] = 23, .bit[9] = 23, .bit[10] = 24, .bit[11] = 23,
|
||||
|
||||
.com[12] = 1, .com[13] = 1,
|
||||
.bit[12] = 23, .bit[13] = 22
|
||||
},
|
||||
{ /* 5 */
|
||||
.com[0] = 3, .com[1] = 3, .com[2] = 1, .com[3] = 0,
|
||||
.bit[0] = 25, .bit[1] = 6, .bit[2] = 6, .bit[3] = 25,
|
||||
|
||||
.com[4] = 1, .com[5] = 3, .com[6] = 2, .com[7] = 2,
|
||||
.bit[4] = 7, .bit[5] = 7, .bit[6] = 7, .bit[7] = 25,
|
||||
|
||||
.com[8] = 2, .com[9] = 3, .com[10] = 2, .com[11] = 0,
|
||||
.bit[8] = 26, .bit[9] = 26, .bit[10] = 6, .bit[11] = 26,
|
||||
|
||||
.com[12] = 1, .com[13] = 1,
|
||||
.bit[12] = 26, .bit[13] = 25
|
||||
},
|
||||
{ /* 6 */
|
||||
.com[0] = 3, .com[1] = 3, .com[2] = 1, .com[3] = 0,
|
||||
.bit[0] = 27, .bit[1] = 04, .bit[2] = 04, .bit[3] = 27,
|
||||
|
||||
.com[4] = 1, .com[5] = 3, .com[6] = 2, .com[7] = 2,
|
||||
.bit[4] = 5, .bit[5] = 5, .bit[6] = 5, .bit[7] = 27,
|
||||
|
||||
.com[8] = 2, .com[9] = 3, .com[10] = 2, .com[11] = 0,
|
||||
.bit[8] = 28, .bit[9] = 28, .bit[10] = 4, .bit[11] = 28,
|
||||
|
||||
.com[12] = 1, .com[13] = 1,
|
||||
.bit[12] = 28, .bit[13] = 27
|
||||
},
|
||||
{ /* 7 */
|
||||
.com[0] = 3, .com[1] = 3, .com[2] = 1, .com[3] = 0,
|
||||
.bit[0] = 29, .bit[1] = 2, .bit[2] = 2, .bit[3] = 29,
|
||||
|
||||
.com[4] = 1, .com[5] = 3, .com[6] = 2, .com[7] = 2,
|
||||
.bit[4] = 03, .bit[5] = 3, .bit[6] = 3, .bit[7] = 29,
|
||||
|
||||
.com[8] = 2, .com[9] = 3, .com[10] = 2, .com[11] = 0,
|
||||
.bit[8] = 30, .bit[9] = 30, .bit[10] = 2, .bit[11] = 30,
|
||||
|
||||
.com[12] = 1, .com[13] = 1,
|
||||
.bit[12] = 30, .bit[13] = 29
|
||||
}
|
||||
},
|
||||
.Number = {
|
||||
{
|
||||
.com[0] = 3, .com[1] = 2, .com[2] = 1, .com[3] = 0,
|
||||
.bit[0] = 31, .bit[1] = 31, .bit[2] = 31, .bit[3] = 31,
|
||||
|
||||
.com[4] = 5, .com[5] = 7, .com[6] = 6,
|
||||
.bit[4] = 0, .bit[5] = 0, .bit[6] = 0,
|
||||
},
|
||||
{
|
||||
.com[0] = 7, .com[1] = 6, .com[2] = 5, .com[3] = 4,
|
||||
.bit[0] = 1, .bit[1] = 1, .bit[2] = 1, .bit[3] = 1,
|
||||
|
||||
.com[4] = 5, .com[5] = 7, .com[6] = 6,
|
||||
.bit[4] = 3, .bit[5] = 3, .bit[6] = 3,
|
||||
},
|
||||
{
|
||||
.com[0] = 7, .com[1] = 6, .com[2] = 5, .com[3] = 4,
|
||||
.bit[0] = 4, .bit[1] = 4, .bit[2] = 4, .bit[3] = 4,
|
||||
|
||||
.com[4] = 5, .com[5] = 7, .com[6] = 6,
|
||||
.bit[4] = 5, .bit[5] = 5, .bit[6] = 5,
|
||||
},
|
||||
{
|
||||
.com[0] = 7, .com[1] = 6, .com[2] = 5, .com[3] = 4,
|
||||
.bit[0] = 6, .bit[1] = 6, .bit[2] = 6, .bit[3] = 6,
|
||||
|
||||
.com[4] = 5, .com[5] = 7, .com[6] = 6,
|
||||
.bit[4] = 7, .bit[5] = 7, .bit[6] = 7,
|
||||
},
|
||||
},
|
||||
.EMode = {
|
||||
.com[0] = 1, .bit[0] = 1,
|
||||
.com[1] = 2, .bit[1] = 1,
|
||||
.com[2] = 1, .bit[2] = 0,
|
||||
.com[3] = 2, .bit[3] = 0,
|
||||
.com[4] = 3, .bit[4] = 0,
|
||||
},
|
||||
.ARing = {
|
||||
.com[0] = 0, .bit[0] = 0,
|
||||
.com[1] = 0, .bit[1] = 1,
|
||||
.com[2] = 0, .bit[2] = 2,
|
||||
.com[3] = 0, .bit[3] = 3,
|
||||
|
||||
.com[4] = 0, .bit[4] = 4,
|
||||
.com[5] = 0, .bit[5] = 5,
|
||||
.com[6] = 0, .bit[6] = 6,
|
||||
.com[7] = 0, .bit[7] = 7,
|
||||
},
|
||||
.Battery = {
|
||||
.com[0] = 0, .bit[0] = 12,
|
||||
.com[1] = 0, .bit[1] = 17,
|
||||
.com[2] = 0, .bit[2] = 20,
|
||||
.com[3] = 0, .bit[3] = 13,
|
||||
}
|
||||
};
|
||||
|
||||
/**************************************************************************//**
|
||||
* @brief
|
||||
* Defines higlighted segments for the alphabet, starting from "blank" (SPACE)
|
||||
* Uses bit pattern as defined for text segments above.
|
||||
* E.g. a capital O, would have bits 0 1 2 3 4 5 => 0x003f defined
|
||||
*****************************************************************************/
|
||||
uint16_t EM_alphabet[] = {
|
||||
0x0000, /* space */
|
||||
0x1100, /* ! */
|
||||
0x0280, /* " */
|
||||
0x0000, /* # */
|
||||
0x0000, /* $ */
|
||||
0x0000, /* % */
|
||||
0x0000, /* & */
|
||||
0x0000, /* £ */
|
||||
0x0039, /* ( */
|
||||
0x000f, /* ) */
|
||||
0x0000, /* * */
|
||||
0x1540, /* + */
|
||||
0x0000, /* , */
|
||||
0x0440, /* - */
|
||||
0x0000, /* . */
|
||||
0x2200, /* / */
|
||||
|
||||
0x003f, /* 0 */
|
||||
0x0006, /* 1 */
|
||||
0x045b, /* 2 */
|
||||
0x044f, /* 3 */
|
||||
0x0466, /* 4 */
|
||||
0x046d, /* 5 */
|
||||
0x047d, /* 6 */
|
||||
0x0007, /* 7 */
|
||||
0x047f, /* 8 */
|
||||
0x046f, /* 9 */
|
||||
|
||||
0x0000, /* : */
|
||||
0x0000, /* ; */
|
||||
0x0a00, /* < */
|
||||
0x0000, /* = */
|
||||
0x2080, /* > */
|
||||
0x0000, /* ? */
|
||||
0xffff, /* @ */
|
||||
|
||||
0x0477, /* A */
|
||||
0x0a79, /* B */
|
||||
0x0039, /* C */
|
||||
0x20b0, /* D */
|
||||
0x0079, /* E */
|
||||
0x0071, /* F */
|
||||
0x047d, /* G */
|
||||
0x0476, /* H */
|
||||
0x0006, /* I */
|
||||
0x000e, /* J */
|
||||
0x0a70, /* K */
|
||||
0x0038, /* L */
|
||||
0x02b6, /* M */
|
||||
0x08b6, /* N */
|
||||
0x003f, /* O */
|
||||
0x0473, /* P */
|
||||
0x083f, /* Q */
|
||||
0x0c73, /* R */
|
||||
0x046d, /* S */
|
||||
0x1101, /* T */
|
||||
0x003e, /* U */
|
||||
0x2230, /* V */
|
||||
0x2836, /* W */
|
||||
0x2a80, /* X */
|
||||
0x046e, /* Y */
|
||||
0x2209, /* Z */
|
||||
|
||||
0x0039, /* [ */
|
||||
0x0880, /* backslash */
|
||||
0x000f, /* ] */
|
||||
0x0001, /* ^ */
|
||||
0x0008, /* _ */
|
||||
0x0100, /* ` */
|
||||
|
||||
0x1058, /* a */
|
||||
0x047c, /* b */
|
||||
0x0058, /* c */
|
||||
0x045e, /* d */
|
||||
0x2058, /* e */
|
||||
0x0471, /* f */
|
||||
0x0c0c, /* g */
|
||||
0x0474, /* h */
|
||||
0x0004, /* i */
|
||||
0x000e, /* j */
|
||||
0x0c70, /* k */
|
||||
0x0038, /* l */
|
||||
0x1454, /* m */
|
||||
0x0454, /* n */
|
||||
0x045c, /* o */
|
||||
0x0473, /* p */
|
||||
0x0467, /* q */
|
||||
0x0450, /* r */
|
||||
0x0c08, /* s */
|
||||
0x0078, /* t */
|
||||
0x001c, /* u */
|
||||
0x2010, /* v */
|
||||
0x2814, /* w */
|
||||
0x2a80, /* x */
|
||||
0x080c, /* y */
|
||||
0x2048, /* z */
|
||||
|
||||
0x0000,
|
||||
};
|
||||
|
||||
/**************************************************************************//**
|
||||
* @brief
|
||||
* Defines higlighted segments for the numeric display
|
||||
*****************************************************************************/
|
||||
uint16_t EM_Numbers[] =
|
||||
{
|
||||
0x003f, /* 0 */
|
||||
0x0006, /* 1 */
|
||||
0x005b, /* 2 */
|
||||
0x004f, /* 3 */
|
||||
0x0066, /* 4 */
|
||||
0x006d, /* 5 */
|
||||
0x007d, /* 6 */
|
||||
0x0007, /* 7 */
|
||||
0x007f, /* 8 */
|
||||
0x006f, /* 9 */
|
||||
0x0040, /* - */
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue