72 lines
1.7 KiB
C
72 lines
1.7 KiB
C
|
#include "main.h"
|
||
|
|
||
|
#include "dap_main.h"
|
||
|
#include "cdc_main.h"
|
||
|
#include "usb_desc.h"
|
||
|
#include "usart.h"
|
||
|
#include "led.h"
|
||
|
|
||
|
void JTAG_PIN_INIT()
|
||
|
{
|
||
|
GPIO_InitTypeDef GPIO_InitStructure = {0};
|
||
|
|
||
|
// clk
|
||
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1;
|
||
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
|
||
|
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
||
|
GPIO_Init(GPIOA, &GPIO_InitStructure);
|
||
|
// tms
|
||
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
|
||
|
GPIO_Init(GPIOA, &GPIO_InitStructure);
|
||
|
// rst
|
||
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3;
|
||
|
GPIO_Init(GPIOC, &GPIO_InitStructure);
|
||
|
// tdo
|
||
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;
|
||
|
GPIO_Init(GPIOA, &GPIO_InitStructure);
|
||
|
// tdi
|
||
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
|
||
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11;
|
||
|
GPIO_Init(GPIOA, &GPIO_InitStructure);
|
||
|
}
|
||
|
int main(void)
|
||
|
{
|
||
|
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
|
||
|
SystemCoreClockUpdate();
|
||
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
|
||
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);
|
||
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);
|
||
|
// RCC->APB2PCENR |= RCC_APB2Periph_GPIOA;
|
||
|
// GPIOA->CFGLR &= ~(0x0F << (4 * 4)); // RST,GPIOA4
|
||
|
// GPIOA->CFGLR |= 0x08 << (4 * 4);
|
||
|
// GPIOA->BSHR = 1 << 4;
|
||
|
|
||
|
for (volatile uint32_t i = 0; i < 100; i++)
|
||
|
{
|
||
|
__NOP();
|
||
|
}
|
||
|
|
||
|
// uint8_t temp = (GPIOA->INDR >> 4) & 0x01;
|
||
|
// if (temp == 0)
|
||
|
// {
|
||
|
// SystemReset_StartMode(Start_Mode_BOOT);
|
||
|
// NVIC_SystemReset();
|
||
|
// }
|
||
|
|
||
|
DAP_Init();
|
||
|
DAP_USB_Init();
|
||
|
|
||
|
CDC_Init();
|
||
|
USART4_DMA_Init();
|
||
|
USART4_Init();
|
||
|
USART4_DMA_Recv();
|
||
|
|
||
|
LED_Init();
|
||
|
|
||
|
while (1)
|
||
|
{
|
||
|
DAP_Task();
|
||
|
CDC_Task();
|
||
|
}
|
||
|
}
|