aboutsummaryrefslogtreecommitdiff
path: root/driver_fw/src
diff options
context:
space:
mode:
Diffstat (limited to 'driver_fw/src')
-rw-r--r--driver_fw/src/main.c35
1 files changed, 31 insertions, 4 deletions
diff --git a/driver_fw/src/main.c b/driver_fw/src/main.c
index d5b0e83..ba3ddb8 100644
--- a/driver_fw/src/main.c
+++ b/driver_fw/src/main.c
@@ -37,6 +37,8 @@ static bool idle_buf_ready = false;
void update_tx_buf(void);
+char usartbuf[256];
+int usartp = 0;
int main(void) {
/* Configure clocks for 64 MHz system clock.
@@ -158,6 +160,8 @@ int main(void) {
GPIOD->MODER = IN(0) | IN(1) | IN(2) | IN(3) | IN(4) | IN(5) | IN(6) |
IN(8) | IN(9);
+ delay_us(5*1000*1000);
+
TIM1->CCMR1 = (6<<TIM_CCMR1_OC2M_Pos) | TIM_CCMR1_OC2PE;
TIM1->CCMR2 = (6<<TIM_CCMR2_OC3M_Pos) | TIM_CCMR2_OC3PE;
TIM1->CCER = TIM_CCER_CC2E | TIM_CCER_CC2NE | TIM_CCER_CC2NP | TIM_CCER_CC3E | TIM_CCER_CC3NE | TIM_CCER_CC3P;
@@ -177,21 +181,44 @@ int main(void) {
dma_tx_constant(COUNT_OF(waveform_zero_one), 0x00);
xfr_8b10b_encode_reset(&encoder_state_8b10b);
+ USART1->CR1 = /* 8-bit -> M1, M0 clear */
+ /* OVER8 clear. Use default 16x oversampling */
+ /* CMIF clear */
+ /* MME clear */
+ /* WAKE clear */
+ /* PCE, PS clear */
+ /* RXNEIE, other interrupts clear */
+ USART_CR1_TE
+ | USART_CR1_RE;
+ USART1->CR3 |= USART_CR3_DEM; /* Output DE signal on RTS pin */
+ USART1->BRR = 6667; /* Set baudrate to 9600 Bd */
+ USART1->CR1 |= USART_CR1_UE; /* And... go! */
+
int i = 0;
int j = 0;
int k = 0;
int n = 0;
while (23) {
+ if (USART1->ISR & USART_ISR_RXNE_RXFNE) {
+ usartbuf[usartp] = USART1->RDR;
+ usartp ++;
+ if (usartp >= sizeof(usartbuf)) {
+ usartp = 0;
+ }
+ }
+ }
+
+ {
i++;
j++;
i %= 6;
j %= 4;
- delay_us(30000);
+ delay_us(100000);
set_rj45_leds(1 << j);
- set_status_leds(1 << i);
+ set_status_leds(0x01);
if (i == 0) {
k++;
- if (k == 16) {
+ if (k == 10) {
k = 0;
n++;
if (n == 16) {
@@ -203,7 +230,7 @@ int main(void) {
memset(tx_buf_write, 0, sizeof(*tx_buf_write));
for (size_t i=0; i<COUNT_OF(tx_buf_write->packet.channels); i++) {
- tx_buf_write->packet.channels[i] = 0xff;
+ tx_buf_write->packet.channels[i] = (k < 9) ? (1<<k) : 0xff;
}
for (size_t i=0; i<COUNT_OF(tx_buf_write->packet.brightness); i++) {
tx_buf_write->packet.brightness[i] = 0xff; //(n<<4) | n;