lab2
This commit is contained in:
parent
c2204b2508
commit
05973dcd2b
|
@ -2,11 +2,18 @@
|
||||||
|
|
||||||
#include "inc/msp432p401r.h"
|
#include "inc/msp432p401r.h"
|
||||||
|
|
||||||
|
#define BUMP_PINS 0b11101101
|
||||||
|
|
||||||
void BumpInit(void) {
|
void BumpInit(void) {
|
||||||
// write this as part of Lab 2
|
// Port 4 pins 0, 2, 3, 5, 6, 7
|
||||||
|
// and enables internal resistors
|
||||||
|
P4->SEL0 &= ~BUMP_PINS;
|
||||||
|
P4->SEL1 &= ~BUMP_PINS; // 1) configure P4.0 P4.2 P4.3 P4.5 P4.6 P4.7 as gpio
|
||||||
|
P4->DIR &= ~BUMP_PINS; // 2) configure as input
|
||||||
|
P4->REN |= BUMP_PINS; // 3) enable pull resisors
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t BumpRead(void) {
|
uint8_t BumpRead(void) {
|
||||||
// write this as part of Lab 2
|
// write this as part of Lab 2
|
||||||
return 0; // replace this line
|
return P4->IN & BUMP_PINS;
|
||||||
}
|
}
|
15
lab2/main.c
15
lab2/main.c
|
@ -5,17 +5,26 @@
|
||||||
#include "../common/delay.h"
|
#include "../common/delay.h"
|
||||||
#include "../common/clock.h"
|
#include "../common/clock.h"
|
||||||
|
|
||||||
|
#define DUMP_SIZE 256
|
||||||
|
|
||||||
|
uint8_t bump_status;
|
||||||
|
uint8_t bump_dump[DUMP_SIZE];
|
||||||
|
|
||||||
void DebugDump(uint8_t bump) {
|
void DebugDump(uint8_t bump) {
|
||||||
// write this as part of Lab 2
|
static idx = 0;
|
||||||
|
idx = (idx + 1) % DUMP_SIZE;
|
||||||
|
bump_dump[idx] = bump;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
// write this as part of Lab 2
|
|
||||||
ClockInit48MHz();
|
ClockInit48MHz();
|
||||||
|
BumpInit();
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
// write this as part of Lab 2
|
|
||||||
// 10ms delay
|
// 10ms delay
|
||||||
|
Delay1ms(10);
|
||||||
|
bump_status = BumpRead();
|
||||||
// debug dump
|
// debug dump
|
||||||
|
DebugDump(bump_status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue