native: Enable hard SRST signal.

This commit is contained in:
Gareth McMullin 2013-06-19 19:21:49 +12:00
parent ccb20b4420
commit 27a86e244f
2 changed files with 17 additions and 1 deletions

View File

@ -82,7 +82,6 @@ int platform_init(void)
gpio_set_mode(JTAG_PORT, GPIO_MODE_OUTPUT_50_MHZ, gpio_set_mode(JTAG_PORT, GPIO_MODE_OUTPUT_50_MHZ,
GPIO_CNF_OUTPUT_PUSHPULL, GPIO_CNF_OUTPUT_PUSHPULL,
TMS_PIN | TCK_PIN | TDI_PIN); TMS_PIN | TCK_PIN | TDI_PIN);
/* This needs some fixing... */ /* This needs some fixing... */
/* Toggle required to sort out line drivers... */ /* Toggle required to sort out line drivers... */
gpio_port_write(GPIOA, 0x8100); gpio_port_write(GPIOA, 0x8100);
@ -99,6 +98,11 @@ int platform_init(void)
* to release the device from reset if this floats. */ * to release the device from reset if this floats. */
gpio_set_mode(GPIOA, GPIO_MODE_OUTPUT_2_MHZ, gpio_set_mode(GPIOA, GPIO_MODE_OUTPUT_2_MHZ,
GPIO_CNF_OUTPUT_PUSHPULL, GPIO7); GPIO_CNF_OUTPUT_PUSHPULL, GPIO7);
/* Enable SRST output */
gpio_set_val(SRST_PORT, SRST_PIN, platform_hwversion() > 0);
gpio_set_mode(SRST_PORT, GPIO_MODE_OUTPUT_50_MHZ,
GPIO_CNF_OUTPUT_PUSHPULL,
SRST_PIN);
/* Setup heartbeat timer */ /* Setup heartbeat timer */
systick_set_clocksource(STK_CTRL_CLKSOURCE_AHB_DIV8); systick_set_clocksource(STK_CTRL_CLKSOURCE_AHB_DIV8);
@ -127,6 +131,15 @@ int platform_init(void)
return 0; return 0;
} }
void platform_srst_set_val(bool assert)
{
if (platform_hwversion() == 0) {
gpio_set_val(SRST_PORT, SRST_PIN, assert);
} else {
gpio_set_val(SRST_PORT, SRST_PIN, !assert);
}
}
void platform_delay(uint32_t delay) void platform_delay(uint32_t delay)
{ {
timeout_counter = delay; timeout_counter = delay;

View File

@ -113,6 +113,9 @@ extern usbd_device *usbdev;
gpio_set_mode(USBUSART_PORT, GPIO_MODE_OUTPUT_2_MHZ, \ gpio_set_mode(USBUSART_PORT, GPIO_MODE_OUTPUT_2_MHZ, \
GPIO_CNF_OUTPUT_ALTFN_PUSHPULL, USBUSART_TX_PIN); GPIO_CNF_OUTPUT_ALTFN_PUSHPULL, USBUSART_TX_PIN);
#define SRST_SET_VAL(x) \
platform_srst_set_val(x)
#define USB_DRIVER stm32f103_usb_driver #define USB_DRIVER stm32f103_usb_driver
#define USB_IRQ NVIC_USB_LP_CAN_RX0_IRQ #define USB_IRQ NVIC_USB_LP_CAN_RX0_IRQ
#define USB_ISR usb_lp_can_rx0_isr #define USB_ISR usb_lp_can_rx0_isr