You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
107 lines
2.0 KiB
C
107 lines
2.0 KiB
C
|
5 years ago
|
#include <stdint.h>
|
||
|
|
|
||
|
|
#include "tm4c_cmsis.h"
|
||
|
|
#include "delay.h"
|
||
|
|
|
||
|
|
#define LED_RED (1U << 1)
|
||
|
|
#define LED_BLUE (1U << 2)
|
||
|
|
#define LED_GREEN (1U << 3)
|
||
|
|
|
||
|
2 years ago
|
//static int16_t x = -1;
|
||
|
|
//static uint32_t y = LED_RED | LED_GREEN;
|
||
|
|
|
||
|
|
//static int16_t sqr[] = {
|
||
|
|
// 1*1,
|
||
|
|
// 2*2,
|
||
|
|
// 3*3,
|
||
|
|
// 4*4
|
||
|
|
//};
|
||
|
5 years ago
|
|
||
|
|
typedef struct {
|
||
|
|
uint8_t y;
|
||
|
|
uint16_t x;
|
||
|
|
} Point;
|
||
|
|
|
||
|
2 years ago
|
static Point p1 = {
|
||
|
5 years ago
|
123U,
|
||
|
|
0x1234U
|
||
|
|
};
|
||
|
2 years ago
|
static Point p2;
|
||
|
5 years ago
|
|
||
|
|
typedef struct {
|
||
|
|
Point top_left;
|
||
|
|
Point bottom_right;
|
||
|
|
} Window;
|
||
|
|
|
||
|
|
typedef struct {
|
||
|
2 years ago
|
Point corners[3];
|
||
|
5 years ago
|
} Triangle;
|
||
|
|
|
||
|
2 years ago
|
static Window w = {
|
||
|
5 years ago
|
{ 123U, 0x1234U },
|
||
|
|
{ 234U, 0x6789U }
|
||
|
|
};
|
||
|
2 years ago
|
static Window w2;
|
||
|
|
static Triangle t;
|
||
|
5 years ago
|
|
||
|
2 years ago
|
int main(void) {
|
||
|
5 years ago
|
Point *pp;
|
||
|
|
Window *wp;
|
||
|
|
|
||
|
|
p1.x = sizeof(Point);
|
||
|
|
p1.y = 0xAAU;
|
||
|
|
|
||
|
|
w.top_left.x = 1U;
|
||
|
|
w.bottom_right.y = 2U;
|
||
|
|
|
||
|
|
t.corners[0].x = 1U;
|
||
|
|
t.corners[2].y = 2U;
|
||
|
|
|
||
|
|
p2 = p1;
|
||
|
|
w2 = w;
|
||
|
|
|
||
|
|
pp = &p1;
|
||
|
|
wp = &w2;
|
||
|
|
|
||
|
|
(*pp).x = 1U;
|
||
|
|
|
||
|
|
(*wp).top_left = *pp;
|
||
|
|
|
||
|
|
pp->x = 1U;
|
||
|
|
wp->top_left = *pp;
|
||
|
|
|
||
|
|
SYSCTL->RCGC2 |= (1U << 5); /* enable clock for GPIOF */
|
||
|
|
SYSCTL->GPIOHSCTL |= (1U << 5); /* enable AHB for GPIOF */
|
||
|
4 years ago
|
|
||
|
|
/* make sure the Run Mode and AHB-enable take effects
|
||
|
|
* before accessing the peripherals
|
||
|
|
*/
|
||
|
|
__ISB(); /* Instruction Synchronization Barrier */
|
||
|
|
__DSB(); /* Data Memory Barrier */
|
||
|
|
|
||
|
5 years ago
|
GPIOF_HS->DIR |= (LED_RED | LED_BLUE | LED_GREEN);
|
||
|
|
GPIOF_HS->DEN |= (LED_RED | LED_BLUE | LED_GREEN);
|
||
|
|
|
||
|
4 years ago
|
/* turn all LEDs off */
|
||
|
|
GPIOF_HS->DATA_Bits[LED_RED | LED_BLUE | LED_GREEN] = 0U;
|
||
|
|
|
||
|
5 years ago
|
GPIOF_HS->DATA_Bits[LED_BLUE] = LED_BLUE;
|
||
|
|
while (1) {
|
||
|
|
GPIOF_HS->DATA_Bits[LED_RED] = LED_RED;
|
||
|
|
delay(500000);
|
||
|
|
|
||
|
|
GPIOF_HS->DATA_Bits[LED_RED] = 0;
|
||
|
|
|
||
|
|
delay(500000);
|
||
|
|
}
|
||
|
2 years ago
|
//return 0; // unreachable code
|
||
|
5 years ago
|
}
|
||
|
2 years ago
|
|
||
|
|
void Q_onAssert(char const *module, int loc) {
|
||
|
|
/* TBD: damage control */
|
||
|
|
(void)module; /* avoid the "unused parameter" compiler warning */
|
||
|
|
(void)loc; /* avoid the "unused parameter" compiler warning */
|
||
|
|
NVIC_SystemReset();
|
||
|
|
}
|
||
|
|
|