@@ -71,7 +71,7 @@ void analogReadRes(unsigned int bits) | |||
void analogReadAveraging(unsigned int num) | |||
{ | |||
uint32_t tmp32, mode, avg=0; | |||
uint32_t tmp32, mode; | |||
//disable averaging | |||
tmp32 = ADC1_GC; |
@@ -26,9 +26,10 @@ extern void pendablesrvreq_isr(void); | |||
void configure_cache(void); | |||
void unused_interrupt_vector(void); | |||
void usb_pll_start(); | |||
extern void analog_init(void); | |||
extern void pwm_init(void); | |||
uint32_t set_arm_clock(uint32_t frequency); | |||
extern void analog_init(void); // analog.c | |||
extern void pwm_init(void); // pwm.c | |||
uint32_t set_arm_clock(uint32_t frequency); // clockspeed.c | |||
extern void __libc_init_array(void); // C++ standard library | |||
__attribute__((section(".startup"), optimize("no-tree-loop-distribute-patterns"))) | |||
@@ -77,16 +78,6 @@ void ResetHandler(void) | |||
set_arm_clock(600000000); | |||
//set_arm_clock(984000000); Ludicrous Speed | |||
uint32_t armpll = CCM_ANALOG_PLL_ARM; | |||
uint32_t armdiv = CCM_CACRR; | |||
uint32_t cbcdr = CCM_CBCDR; | |||
uint32_t cbcmr = CCM_CBCMR; | |||
printf("ARM PLL = %u MHz\n", (armpll & 0x7F) * 12); | |||
printf("ARM divisor = %u\n", armdiv + 1); | |||
printf("AHB divisor = %u\n", ((cbcdr >> 10) & 7) + 1); | |||
printf("IPG divisor = %u\n", ((cbcdr >> 8) & 3) + 1); | |||
while (millis() < 20) ; // wait at least 20ms before starting USB | |||
usb_init(); | |||
analog_init(); |
@@ -2,6 +2,7 @@ | |||
#define USB_DESC_LIST_DEFINE | |||
#include "usb_desc.h" | |||
#include "usb_serial.h" | |||
#include "core_pins.h" // for delay() | |||
#include <string.h> | |||
#include "debug/printf.h" | |||
@@ -129,7 +130,7 @@ void usb_init(void) | |||
//printf("USBPHY1_RX=%08lX\n", USBPHY1_RX); | |||
//printf("USBPHY1_CTRL=%08lX\n", USBPHY1_CTRL); | |||
//printf("USB1_USBMODE=%08lX\n", USB1_USBMODE); | |||
delay(100); | |||
delay(25); | |||
} | |||
#endif | |||
// Device Controller Initialization, page 3161 |
@@ -204,7 +204,7 @@ int usb_serial_putchar(uint8_t c) | |||
} | |||
static transfer_t volatile transfer __attribute__ ((used, aligned(32))); | |||
static transfer_t transfer __attribute__ ((used, aligned(32))); | |||
static uint8_t txbuffer[1024]; | |||
//static uint8_t txbuffer1[1024]; | |||
//static uint8_t txbuffer2[1024]; | |||
@@ -218,7 +218,7 @@ int usb_serial_write(const void *buffer, uint32_t size) | |||
int count=0; | |||
//digitalWriteFast(13, HIGH); | |||
while (1) { | |||
uint32_t status = (volatile)(transfer.status); | |||
uint32_t status = transfer.status; | |||
if (count > 10) printf("status = %x\n", status); | |||
if (!(status & 0x80)) break; | |||
count++; |