finished Task
This commit is contained in:
@@ -0,0 +1,97 @@
|
||||
#include "utils_ctboard.h"
|
||||
|
||||
uint8_t getData7Segment(uint8_t digit);
|
||||
uint16_t getData7SegmentTwoDigits(uint8_t digit);
|
||||
|
||||
int main(void) {
|
||||
/* initializations go here */
|
||||
uint8_t rotationSwitchData;
|
||||
while (1) {
|
||||
/*Connect LEDs to Switchs */
|
||||
write_word(0x60000100, read_word(0x60000200));
|
||||
/*Connect Rotation Switch to 7 Segment */
|
||||
rotationSwitchData = read_byte(0x60000211) & 0x0F;
|
||||
/*write_word(0x60000110, getData7Segment(rotationSwitchData) | 0xFFFF0000); */
|
||||
write_byte(0x60000110, getData7Segment(rotationSwitchData));
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t getData7Segment(uint8_t digit) {
|
||||
switch(digit) {
|
||||
case 0x0:
|
||||
return 0xC0;
|
||||
case 0x1:
|
||||
return 0xF9;
|
||||
case 0x2:
|
||||
return 0xA4;
|
||||
case 0x3:
|
||||
return 0xB0;
|
||||
case 0x4:
|
||||
return 0x99;
|
||||
case 0x5:
|
||||
return 0x92;
|
||||
case 0x6:
|
||||
return 0x82;
|
||||
case 0x7:
|
||||
return 0xF8;
|
||||
case 0x8:
|
||||
return 0x80;
|
||||
case 0x9:
|
||||
return 0x90;
|
||||
case 0xA:
|
||||
return 0x88;
|
||||
case 0xB:
|
||||
return 0x83;
|
||||
case 0xC:
|
||||
return 0xC6;
|
||||
case 0xD:
|
||||
return 0xA1;
|
||||
case 0xE:
|
||||
return 0x86;
|
||||
case 0xF:
|
||||
return 0x8E;
|
||||
default:
|
||||
return 0xFF;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t getData7SegmentTwoDigits(uint8_t digit) {
|
||||
switch(digit) {
|
||||
case 0x0:
|
||||
return 0xFFC0;
|
||||
case 0x1:
|
||||
return 0xFFF9;
|
||||
case 0x2:
|
||||
return 0xFFA4;
|
||||
case 0x3:
|
||||
return 0xFFB0;
|
||||
case 0x4:
|
||||
return 0xFF99;
|
||||
case 0x5:
|
||||
return 0xFF92;
|
||||
case 0x6:
|
||||
return 0xFF82;
|
||||
case 0x7:
|
||||
return 0xFFF8;
|
||||
case 0x8:
|
||||
return 0xFF80;
|
||||
case 0x9:
|
||||
return 0xFF90;
|
||||
case 0xA:
|
||||
return 0xF9C0;
|
||||
case 0xB:
|
||||
return 0xF9F9;
|
||||
case 0xC:
|
||||
return 0xF9A4;
|
||||
case 0xD:
|
||||
return 0xF9B0;
|
||||
case 0xE:
|
||||
return 0xF999;
|
||||
case 0xF:
|
||||
return 0xF992;
|
||||
default:
|
||||
return 0xFFFF;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* -- _____ ______ _____ -
|
||||
* -- |_ _| | ____|/ ____| -
|
||||
* -- | | _ __ | |__ | (___ Institute of Embedded Systems -
|
||||
* -- | | | '_ \| __| \___ \ Zurich University of -
|
||||
* -- _| |_| | | | |____ ____) | Applied Sciences -
|
||||
* -- |_____|_| |_|______|_____/ 8401 Winterthur, Switzerland -
|
||||
* ----------------------------------------------------------------------------
|
||||
* --
|
||||
* -- Project : CT Board - Cortex M4
|
||||
* -- Description : Utilities for ct board.
|
||||
* --
|
||||
* -- $Id: utils_ctboard.c 2160 2015-06-08 12:28:00Z feur $
|
||||
* ------------------------------------------------------------------------- */
|
||||
|
||||
#include <stdint.h>
|
||||
#include "utils_ctboard.h"
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
* -- Functions
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
* See header file
|
||||
*/
|
||||
uint8_t read_byte(uint32_t address)
|
||||
{
|
||||
uint8_t *pointer;
|
||||
pointer = (uint8_t *)address;
|
||||
return *pointer;
|
||||
}
|
||||
|
||||
/*
|
||||
* See header file
|
||||
*/
|
||||
uint16_t read_halfword(uint32_t address)
|
||||
{
|
||||
uint16_t *pointer;
|
||||
pointer = (uint16_t *)address;
|
||||
return *pointer;
|
||||
}
|
||||
|
||||
/*
|
||||
* See header file
|
||||
*/
|
||||
uint32_t read_word(uint32_t address)
|
||||
{
|
||||
uint32_t *pointer;
|
||||
pointer = (uint32_t *)address;
|
||||
return *pointer;
|
||||
}
|
||||
|
||||
/*
|
||||
* See header file
|
||||
*/
|
||||
uint64_t read_doubleword(uint32_t address)
|
||||
{
|
||||
uint64_t *pointer;
|
||||
pointer = (uint64_t *)address;
|
||||
return *pointer;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* See header file
|
||||
*/
|
||||
void write_byte(uint32_t address, uint8_t data)
|
||||
{
|
||||
uint8_t *pointer;
|
||||
pointer = (uint8_t *)address;
|
||||
*pointer = data;
|
||||
}
|
||||
|
||||
/*
|
||||
* See header file
|
||||
*/
|
||||
void write_halfword(uint32_t address, uint16_t data)
|
||||
{
|
||||
uint16_t *pointer;
|
||||
pointer = (uint16_t *)address;
|
||||
*pointer = data;
|
||||
}
|
||||
|
||||
/*
|
||||
* See header file
|
||||
*/
|
||||
void write_word(uint32_t address, uint32_t data)
|
||||
{
|
||||
uint32_t *pointer;
|
||||
pointer = (uint32_t *)address;
|
||||
*pointer = data;
|
||||
}
|
||||
|
||||
/*
|
||||
* See header file
|
||||
*/
|
||||
void write_doubleword(uint32_t address, uint64_t data)
|
||||
{
|
||||
uint64_t *pointer;
|
||||
pointer = (uint64_t *)address;
|
||||
*pointer = data;
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* -- _____ ______ _____ -
|
||||
* -- |_ _| | ____|/ ____| -
|
||||
* -- | | _ __ | |__ | (___ Institute of Embedded Systems -
|
||||
* -- | | | '_ \| __| \___ \ Zurich University of -
|
||||
* -- _| |_| | | | |____ ____) | Applied Sciences -
|
||||
* -- |_____|_| |_|______|_____/ 8401 Winterthur, Switzerland -
|
||||
* ----------------------------------------------------------------------------
|
||||
* --
|
||||
* -- Module : ctboard_utils
|
||||
* -- Description : Interface for module.
|
||||
* --
|
||||
* -- $Id: utils_ctboard.h 1122 2015-01-06 13:57:04Z feur $
|
||||
* ------------------------------------------------------------------------- */
|
||||
#ifndef _UTILS_CTBOARD
|
||||
#define _UTILS_CTBOARD
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
* -- Function prototypes
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
* Functions to read either a byte, halfword, word or
|
||||
* doubleword from an arbitrary address.
|
||||
* @param address: address to read from (32 bit)
|
||||
* @retval data @ address
|
||||
*/
|
||||
uint8_t read_byte(uint32_t address);
|
||||
uint16_t read_halfword(uint32_t address);
|
||||
uint32_t read_word(uint32_t address);
|
||||
uint64_t read_doubleword(uint32_t address);
|
||||
|
||||
|
||||
/*
|
||||
* Functions to write either a byte, halfword, word or
|
||||
* doubleword to an arbitrary address.
|
||||
* @param address: address to write to (32 bit)
|
||||
* data: data to write @ address
|
||||
*/
|
||||
void write_byte(uint32_t address, uint8_t data);
|
||||
void write_halfword(uint32_t address, uint16_t data);
|
||||
void write_word(uint32_t address, uint32_t data);
|
||||
void write_doubleword(uint32_t address, uint64_t data);
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
* -- Header file end
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
#endif
|
||||
Reference in New Issue
Block a user