2022-09-30 07:57:28 +02:00
|
|
|
/* -----------------------------------------------------------------
|
|
|
|
* -- _____ ______ _____ -
|
|
|
|
* -- |_ _| | ____|/ ____| -
|
|
|
|
* -- | | _ __ | |__ | (___ 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
|
2022-09-30 08:35:44 +02:00
|
|
|
#define BRIGHT_MASK 0xC0
|
|
|
|
#define DARK_MASK 0xCF
|
2022-09-30 07:57:28 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// 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
|
2022-09-30 08:35:44 +02:00
|
|
|
led_value = (led_value | BRIGHT_MASK);
|
|
|
|
led_value = (led_value & DARK_MASK);
|
2022-09-30 07:57:28 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// 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
|
|
|
|
}
|
|
|
|
}
|