initial commit
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
/* -----------------------------------------------------------------
|
||||
* -- _____ ______ _____ -
|
||||
* -- |_ _| | ____|/ ____| -
|
||||
* -- | | _ __ | |__ | (___ Institute of Embedded Systems -
|
||||
* -- | | | '_ \| __| \___ \ Zurich University of -
|
||||
* -- _| |_| | | | |____ ____) | Applied Sciences -
|
||||
* -- |_____|_| |_|______|_____/ 8401 Winterthur, Switzerland -
|
||||
* ------------------------------------------------------------------
|
||||
* --
|
||||
* -- main.c
|
||||
* --
|
||||
* -- main for Computer Engineering "Bit Manipulations"
|
||||
* --
|
||||
* -- $Id: main.c 744 2014-09-24 07:48:46Z ruan $
|
||||
* ------------------------------------------------------------------
|
||||
*/
|
||||
//#include <reg_ctboard.h>
|
||||
#include "utils_ctboard.h"
|
||||
|
||||
#define ADDR_DIP_SWITCH_31_0 0x60000200
|
||||
#define ADDR_DIP_SWITCH_7_0 0x60000200
|
||||
#define ADDR_LED_31_24 0x60000103
|
||||
#define ADDR_LED_23_16 0x60000102
|
||||
#define ADDR_LED_15_8 0x60000101
|
||||
#define ADDR_LED_7_0 0x60000100
|
||||
#define ADDR_BUTTONS 0x60000210
|
||||
|
||||
// define your own macros for bitmasks below (#define)
|
||||
/// STUDENTS: To be programmed
|
||||
|
||||
|
||||
|
||||
|
||||
/// END: To be programmed
|
||||
|
||||
int main(void)
|
||||
{
|
||||
uint8_t led_value = 0;
|
||||
|
||||
// add variables below
|
||||
/// STUDENTS: To be programmed
|
||||
|
||||
|
||||
|
||||
|
||||
/// END: To be programmed
|
||||
|
||||
while (1) {
|
||||
// ---------- Task 3.1 ----------
|
||||
led_value = read_byte(ADDR_DIP_SWITCH_7_0);
|
||||
|
||||
/// STUDENTS: To be programmed
|
||||
|
||||
|
||||
|
||||
|
||||
/// END: To be programmed
|
||||
|
||||
write_byte(ADDR_LED_7_0, led_value);
|
||||
|
||||
// ---------- Task 3.2 and 3.3 ----------
|
||||
/// STUDENTS: To be programmed
|
||||
|
||||
|
||||
|
||||
|
||||
/// END: To be programmed
|
||||
}
|
||||
}
|
||||
@@ -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