Merge pull request #100 from jboone/master
Incorporate bgamari changes for libopencm3 upstream.
This commit is contained in:
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
[submodule "firmware/libopencm3"]
|
||||||
|
path = firmware/libopencm3
|
||||||
|
url = https://github.com/mossmann/libopencm3.git
|
@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
#include "hackrf_core.h"
|
#include "hackrf_core.h"
|
||||||
|
|
||||||
u32 boot0, boot1, boot2, boot3;
|
uint32_t boot0, boot1, boot2, boot3;
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
#BOARD ?= JELLYBEAN
|
#BOARD ?= JELLYBEAN
|
||||||
BOARD ?= JAWBREAKER
|
BOARD ?= JAWBREAKER
|
||||||
|
|
||||||
HACKRF_OPTS = -D$(BOARD)
|
HACKRF_OPTS = -D$(BOARD) -DLPC43XX -DLPC43XX_M4
|
||||||
|
|
||||||
# comment to disable RF transmission
|
# comment to disable RF transmission
|
||||||
HACKRF_OPTS += -DTX_ENABLE
|
HACKRF_OPTS += -DTX_ENABLE
|
||||||
@ -40,7 +40,7 @@ HACKRF_OPTS += $(VERSION_STRING)
|
|||||||
|
|
||||||
LDSCRIPT ?= ../common/LPC4330_M4.ld
|
LDSCRIPT ?= ../common/LPC4330_M4.ld
|
||||||
|
|
||||||
LIBOPENCM3 ?= /usr/local/arm-none-eabi
|
LIBOPENCM3 ?= ../libopencm3
|
||||||
|
|
||||||
PREFIX ?= arm-none-eabi
|
PREFIX ?= arm-none-eabi
|
||||||
CC = $(PREFIX)-gcc
|
CC = $(PREFIX)-gcc
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
#include <libopencm3/lpc43xx/cgu.h>
|
#include <libopencm3/lpc43xx/cgu.h>
|
||||||
#include <libopencm3/lpc43xx/gpio.h>
|
#include <libopencm3/lpc43xx/gpio.h>
|
||||||
#include <libopencm3/lpc43xx/nvic.h>
|
#include <libopencm3/lpc43xx/m4/nvic.h>
|
||||||
#include <libopencm3/lpc43xx/sgpio.h>
|
#include <libopencm3/lpc43xx/sgpio.h>
|
||||||
|
|
||||||
#include <hackrf_core.h>
|
#include <hackrf_core.h>
|
||||||
@ -295,7 +295,7 @@ usb_endpoint_t usb_endpoint_bulk_out = {
|
|||||||
void baseband_streaming_disable() {
|
void baseband_streaming_disable() {
|
||||||
sgpio_cpld_stream_disable();
|
sgpio_cpld_stream_disable();
|
||||||
|
|
||||||
nvic_disable_irq(NVIC_M4_SGPIO_IRQ);
|
nvic_disable_irq(NVIC_SGPIO_IRQ);
|
||||||
|
|
||||||
usb_endpoint_disable(&usb_endpoint_bulk_in);
|
usb_endpoint_disable(&usb_endpoint_bulk_in);
|
||||||
usb_endpoint_disable(&usb_endpoint_bulk_out);
|
usb_endpoint_disable(&usb_endpoint_bulk_out);
|
||||||
@ -335,8 +335,8 @@ void set_transceiver_mode(const transceiver_mode_t new_transceiver_mode) {
|
|||||||
|
|
||||||
sgpio_configure(transceiver_mode, true);
|
sgpio_configure(transceiver_mode, true);
|
||||||
|
|
||||||
nvic_set_priority(NVIC_M4_SGPIO_IRQ, 0);
|
nvic_set_priority(NVIC_SGPIO_IRQ, 0);
|
||||||
nvic_enable_irq(NVIC_M4_SGPIO_IRQ);
|
nvic_enable_irq(NVIC_SGPIO_IRQ);
|
||||||
SGPIO_SET_EN_1 = (1 << SGPIO_SLICE_A);
|
SGPIO_SET_EN_1 = (1 << SGPIO_SLICE_A);
|
||||||
|
|
||||||
sgpio_cpld_stream_enable();
|
sgpio_cpld_stream_enable();
|
||||||
@ -884,51 +884,19 @@ const usb_request_handlers_t usb_request_handlers = {
|
|||||||
.reserved = 0,
|
.reserved = 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: Seems like this should live in usb_standard_request.c.
|
void usb_configuration_changed(
|
||||||
bool usb_set_configuration(
|
usb_device_t* const device
|
||||||
usb_device_t* const device,
|
|
||||||
const uint_fast8_t configuration_number
|
|
||||||
) {
|
) {
|
||||||
const usb_configuration_t* new_configuration = 0;
|
set_transceiver_mode(transceiver_mode);
|
||||||
if( configuration_number != 0 ) {
|
|
||||||
|
|
||||||
// Locate requested configuration.
|
|
||||||
if( device->configurations ) {
|
|
||||||
usb_configuration_t** configurations = *(device->configurations);
|
|
||||||
uint32_t i = 0;
|
|
||||||
const usb_speed_t usb_speed_current = usb_speed(device);
|
|
||||||
while( configurations[i] ) {
|
|
||||||
if( (configurations[i]->speed == usb_speed_current) &&
|
|
||||||
(configurations[i]->number == configuration_number) ) {
|
|
||||||
new_configuration = configurations[i];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Requested configuration not found: request error.
|
|
||||||
if( new_configuration == 0 ) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if( new_configuration != device->configuration ) {
|
if( device->configuration->number ) {
|
||||||
// Configuration changed.
|
gpio_set(PORT_LED1_3, PIN_LED1);
|
||||||
device->configuration = new_configuration;
|
} else {
|
||||||
set_transceiver_mode(transceiver_mode);
|
gpio_clear(PORT_LED1_3, PIN_LED1);
|
||||||
|
|
||||||
if( device->configuration ) {
|
|
||||||
gpio_set(PORT_LED1_3, PIN_LED1);
|
|
||||||
} else {
|
|
||||||
gpio_clear(PORT_LED1_3, PIN_LED1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void sgpio_irqhandler() {
|
void sgpio_isr() {
|
||||||
SGPIO_CLR_STATUS_1 = (1 << SGPIO_SLICE_A);
|
SGPIO_CLR_STATUS_1 = (1 << SGPIO_SLICE_A);
|
||||||
|
|
||||||
uint32_t* const p = (uint32_t*)&usb_bulk_buffer[usb_bulk_buffer_offset];
|
uint32_t* const p = (uint32_t*)&usb_bulk_buffer[usb_bulk_buffer_offset];
|
||||||
@ -1005,7 +973,7 @@ int main(void) {
|
|||||||
usb_endpoint_init(&usb_endpoint_control_out);
|
usb_endpoint_init(&usb_endpoint_control_out);
|
||||||
usb_endpoint_init(&usb_endpoint_control_in);
|
usb_endpoint_init(&usb_endpoint_control_in);
|
||||||
|
|
||||||
nvic_set_priority(NVIC_M4_USB0_IRQ, 255);
|
nvic_set_priority(NVIC_USB0_IRQ, 255);
|
||||||
|
|
||||||
usb_run(&usb_device);
|
usb_run(&usb_device);
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
#include "usb_standard_request.h"
|
#include "usb_standard_request.h"
|
||||||
|
|
||||||
#include <libopencm3/lpc43xx/creg.h>
|
#include <libopencm3/lpc43xx/creg.h>
|
||||||
#include <libopencm3/lpc43xx/nvic.h>
|
#include <libopencm3/lpc43xx/m4/nvic.h>
|
||||||
#include <libopencm3/lpc43xx/rgu.h>
|
#include <libopencm3/lpc43xx/rgu.h>
|
||||||
#include <libopencm3/lpc43xx/usb.h>
|
#include <libopencm3/lpc43xx/usb.h>
|
||||||
|
|
||||||
@ -412,7 +412,7 @@ static void usb_interrupt_enable(
|
|||||||
usb_device_t* const device
|
usb_device_t* const device
|
||||||
) {
|
) {
|
||||||
if( device == usb_device_usb0 ) {
|
if( device == usb_device_usb0 ) {
|
||||||
nvic_enable_irq(NVIC_M4_USB0_IRQ);
|
nvic_enable_irq(NVIC_USB0_IRQ);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -602,7 +602,7 @@ static void usb_check_for_transfer_events() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void usb0_irqhandler() {
|
void usb0_isr() {
|
||||||
const uint32_t status = usb_get_status();
|
const uint32_t status = usb_get_status();
|
||||||
|
|
||||||
if( status == 0 ) {
|
if( status == 0 ) {
|
||||||
|
@ -28,13 +28,6 @@
|
|||||||
|
|
||||||
#include "usb_type.h"
|
#include "usb_type.h"
|
||||||
|
|
||||||
// TODO: This is a lame move, requiring an extern to be defined to complete
|
|
||||||
// the interface between this API and the application.
|
|
||||||
extern bool usb_set_configuration(
|
|
||||||
usb_device_t* const device,
|
|
||||||
const uint_fast8_t configuration_number
|
|
||||||
);
|
|
||||||
|
|
||||||
void usb_peripheral_reset();
|
void usb_peripheral_reset();
|
||||||
|
|
||||||
void usb_device_init(
|
void usb_device_init(
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
#include "usb_standard_request.h"
|
#include "usb_standard_request.h"
|
||||||
|
|
||||||
@ -58,10 +59,51 @@ usb_transfer_type_t usb_endpoint_descriptor_transfer_type(
|
|||||||
return (endpoint_descriptor[3] & 0x3);
|
return (endpoint_descriptor[3] & 0x3);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern bool usb_set_configuration(
|
void (*usb_configuration_changed_cb)(usb_device_t* const) = NULL;
|
||||||
|
|
||||||
|
void usb_set_configuration_changed_cb(
|
||||||
|
void (*callback)(usb_device_t* const)
|
||||||
|
) {
|
||||||
|
usb_configuration_changed_cb = callback;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool usb_set_configuration(
|
||||||
usb_device_t* const device,
|
usb_device_t* const device,
|
||||||
const uint_fast8_t configuration_number
|
const uint_fast8_t configuration_number
|
||||||
);
|
) {
|
||||||
|
|
||||||
|
const usb_configuration_t* new_configuration = 0;
|
||||||
|
if( configuration_number != 0 ) {
|
||||||
|
|
||||||
|
// Locate requested configuration.
|
||||||
|
if( device->configurations ) {
|
||||||
|
usb_configuration_t** configurations = *(device->configurations);
|
||||||
|
uint32_t i = 0;
|
||||||
|
const usb_speed_t usb_speed_current = usb_speed(device);
|
||||||
|
while( configurations[i] ) {
|
||||||
|
if( (configurations[i]->speed == usb_speed_current) &&
|
||||||
|
(configurations[i]->number == configuration_number) ) {
|
||||||
|
new_configuration = configurations[i];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Requested configuration not found: request error.
|
||||||
|
if( new_configuration == 0 ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( new_configuration != device->configuration ) {
|
||||||
|
// Configuration changed.
|
||||||
|
device->configuration = new_configuration;
|
||||||
|
if (usb_configuration_changed_cb)
|
||||||
|
usb_configuration_changed_cb(device);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
static usb_request_status_t usb_send_descriptor(
|
static usb_request_status_t usb_send_descriptor(
|
||||||
usb_endpoint_t* const endpoint,
|
usb_endpoint_t* const endpoint,
|
||||||
|
@ -25,6 +25,10 @@
|
|||||||
#include "usb_type.h"
|
#include "usb_type.h"
|
||||||
#include "usb_request.h"
|
#include "usb_request.h"
|
||||||
|
|
||||||
|
void usb_set_configuration_changed_cb(
|
||||||
|
void (*callback)(usb_device_t* const)
|
||||||
|
);
|
||||||
|
|
||||||
usb_request_status_t usb_standard_request(
|
usb_request_status_t usb_standard_request(
|
||||||
usb_endpoint_t* const endpoint,
|
usb_endpoint_t* const endpoint,
|
||||||
const usb_transfer_stage_t stage
|
const usb_transfer_stage_t stage
|
||||||
@ -42,4 +46,9 @@ usb_transfer_type_t usb_endpoint_descriptor_transfer_type(
|
|||||||
const uint8_t* const endpoint_descriptor
|
const uint8_t* const endpoint_descriptor
|
||||||
);
|
);
|
||||||
|
|
||||||
|
bool usb_set_configuration(
|
||||||
|
usb_device_t* const device,
|
||||||
|
const uint_fast8_t configuration_number
|
||||||
|
);
|
||||||
|
|
||||||
#endif//__USB_STANDARD_REQUEST_H__
|
#endif//__USB_STANDARD_REQUEST_H__
|
||||||
|
1
firmware/libopencm3
Submodule
1
firmware/libopencm3
Submodule
Submodule firmware/libopencm3 added at d7fdcefbd7
@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
u32 i;
|
uint32_t i;
|
||||||
|
|
||||||
pin_setup();
|
pin_setup();
|
||||||
|
|
||||||
|
@ -22,19 +22,19 @@
|
|||||||
#include <libopencm3/lpc43xx/gpio.h>
|
#include <libopencm3/lpc43xx/gpio.h>
|
||||||
#include <libopencm3/lpc43xx/scu.h>
|
#include <libopencm3/lpc43xx/scu.h>
|
||||||
#include <libopencm3/lpc43xx/i2c.h>
|
#include <libopencm3/lpc43xx/i2c.h>
|
||||||
#include <libopencm3/lpc43xx/nvic.h>
|
#include <libopencm3/lpc43xx/m4/nvic.h>
|
||||||
#include <libopencm3/lpc43xx/systick.h>
|
#include <libopencm3/cm3/systick.h>
|
||||||
#include <libopencm3/cm3/scs.h>
|
#include <libopencm3/cm3/scs.h>
|
||||||
|
|
||||||
#include "hackrf_core.h"
|
#include "hackrf_core.h"
|
||||||
|
|
||||||
/* Global counter incremented by SysTick Interrupt each millisecond */
|
/* Global counter incremented by SysTick Interrupt each millisecond */
|
||||||
volatile u32 g_ulSysTickCount;
|
volatile uint32_t g_ulSysTickCount;
|
||||||
u32 g_NbCyclePerSecond;
|
uint32_t g_NbCyclePerSecond;
|
||||||
|
|
||||||
void systick_setup(void)
|
void systick_setup(void)
|
||||||
{
|
{
|
||||||
u32 systick_reload_val;
|
uint32_t systick_reload_val;
|
||||||
g_ulSysTickCount = 0;
|
g_ulSysTickCount = 0;
|
||||||
|
|
||||||
/* Disable IRQ globally */
|
/* Disable IRQ globally */
|
||||||
@ -73,15 +73,15 @@ void scs_dwt_cycle_counter_enabled(void)
|
|||||||
SCS_DWT_CTRL |= SCS_DWT_CTRL_CYCCNTENA;
|
SCS_DWT_CTRL |= SCS_DWT_CTRL_CYCCNTENA;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 sys_tick_get_time_ms(void)
|
uint32_t sys_tick_get_time_ms(void)
|
||||||
{
|
{
|
||||||
return g_ulSysTickCount;
|
return g_ulSysTickCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 sys_tick_delta_time_ms(u32 start, u32 end)
|
uint32_t sys_tick_delta_time_ms(uint32_t start, uint32_t end)
|
||||||
{
|
{
|
||||||
#define MAX_T_U32 ((2^32)-1)
|
#define MAX_T_U32 ((2^32)-1)
|
||||||
u32 diff;
|
uint32_t diff;
|
||||||
|
|
||||||
if(end > start)
|
if(end > start)
|
||||||
{
|
{
|
||||||
@ -94,10 +94,10 @@ u32 sys_tick_delta_time_ms(u32 start, u32 end)
|
|||||||
return diff;
|
return diff;
|
||||||
}
|
}
|
||||||
|
|
||||||
void sys_tick_wait_time_ms(u32 wait_ms)
|
void sys_tick_wait_time_ms(uint32_t wait_ms)
|
||||||
{
|
{
|
||||||
u32 start, end;
|
uint32_t start, end;
|
||||||
u32 tickms;
|
uint32_t tickms;
|
||||||
|
|
||||||
start = sys_tick_get_time_ms();
|
start = sys_tick_get_time_ms();
|
||||||
|
|
||||||
|
@ -22,24 +22,24 @@
|
|||||||
#include <libopencm3/lpc43xx/gpio.h>
|
#include <libopencm3/lpc43xx/gpio.h>
|
||||||
#include <libopencm3/lpc43xx/scu.h>
|
#include <libopencm3/lpc43xx/scu.h>
|
||||||
#include <libopencm3/lpc43xx/i2c.h>
|
#include <libopencm3/lpc43xx/i2c.h>
|
||||||
#include <libopencm3/lpc43xx/nvic.h>
|
#include <libopencm3/lpc43xx/m4/nvic.h>
|
||||||
#include <libopencm3/lpc43xx/systick.h>
|
#include <libopencm3/cm3/systick.h>
|
||||||
#include <libopencm3/cm3/scs.h>
|
#include <libopencm3/cm3/scs.h>
|
||||||
|
|
||||||
#include "hackrf_core.h"
|
#include "hackrf_core.h"
|
||||||
|
|
||||||
/* Global counter incremented by SysTick Interrupt each millisecond */
|
/* Global counter incremented by SysTick Interrupt each millisecond */
|
||||||
extern volatile u32 g_ulSysTickCount;
|
extern volatile uint32_t g_ulSysTickCount;
|
||||||
extern u32 g_NbCyclePerSecond;
|
extern uint32_t g_NbCyclePerSecond;
|
||||||
|
|
||||||
extern u32 sys_tick_get_time_ms(void);
|
extern uint32_t sys_tick_get_time_ms(void);
|
||||||
extern u32 sys_tick_delta_time_ms(u32 start, u32 end);
|
extern uint32_t sys_tick_delta_time_ms(uint32_t start, uint32_t end);
|
||||||
extern void sys_tick_wait_time_ms(u32 wait_ms);
|
extern void sys_tick_wait_time_ms(uint32_t wait_ms);
|
||||||
|
|
||||||
|
|
||||||
u32 test_nb_instruction_per_sec_100_nop_asm(void)
|
uint32_t test_nb_instruction_per_sec_100_nop_asm(void)
|
||||||
{
|
{
|
||||||
register u32 val __asm__("r0");
|
register uint32_t val __asm__("r0");
|
||||||
|
|
||||||
__asm__(" ldr r1, =g_ulSysTickCount");
|
__asm__(" ldr r1, =g_ulSysTickCount");
|
||||||
__asm__(" ldr r2, [r1]"); /* g_ulSysTickCount */
|
__asm__(" ldr r2, [r1]"); /* g_ulSysTickCount */
|
||||||
@ -165,9 +165,9 @@ u32 test_nb_instruction_per_sec_100_nop_asm(void)
|
|||||||
return val;
|
return val;
|
||||||
};
|
};
|
||||||
|
|
||||||
u32 test_nb_instruction_per_sec_105_nop_asm(void)
|
uint32_t test_nb_instruction_per_sec_105_nop_asm(void)
|
||||||
{
|
{
|
||||||
register u32 val __asm__("r0");
|
register uint32_t val __asm__("r0");
|
||||||
|
|
||||||
__asm__(" ldr r1, =g_ulSysTickCount");
|
__asm__(" ldr r1, =g_ulSysTickCount");
|
||||||
__asm__(" ldr r2, [r1]"); /* g_ulSysTickCount */
|
__asm__(" ldr r2, [r1]"); /* g_ulSysTickCount */
|
||||||
@ -302,9 +302,9 @@ u32 test_nb_instruction_per_sec_105_nop_asm(void)
|
|||||||
return val;
|
return val;
|
||||||
};
|
};
|
||||||
|
|
||||||
u32 test_nb_instruction_per_sec_110_nop_asm(void)
|
uint32_t test_nb_instruction_per_sec_110_nop_asm(void)
|
||||||
{
|
{
|
||||||
register u32 val __asm__("r0");
|
register uint32_t val __asm__("r0");
|
||||||
|
|
||||||
__asm__(" ldr r1, =g_ulSysTickCount");
|
__asm__(" ldr r1, =g_ulSysTickCount");
|
||||||
__asm__(" ldr r2, [r1]"); /* g_ulSysTickCount */
|
__asm__(" ldr r2, [r1]"); /* g_ulSysTickCount */
|
||||||
@ -444,9 +444,9 @@ u32 test_nb_instruction_per_sec_110_nop_asm(void)
|
|||||||
return val;
|
return val;
|
||||||
};
|
};
|
||||||
|
|
||||||
u32 test_nb_instruction_per_sec_115_nop_asm(void)
|
uint32_t test_nb_instruction_per_sec_115_nop_asm(void)
|
||||||
{
|
{
|
||||||
register u32 val __asm__("r0");
|
register uint32_t val __asm__("r0");
|
||||||
|
|
||||||
__asm__(" ldr r1, =g_ulSysTickCount");
|
__asm__(" ldr r1, =g_ulSysTickCount");
|
||||||
__asm__(" ldr r2, [r1]"); /* g_ulSysTickCount */
|
__asm__(" ldr r2, [r1]"); /* g_ulSysTickCount */
|
||||||
@ -592,9 +592,9 @@ u32 test_nb_instruction_per_sec_115_nop_asm(void)
|
|||||||
return val;
|
return val;
|
||||||
};
|
};
|
||||||
|
|
||||||
u32 test_nb_instruction_per_sec_120_nop_asm(void)
|
uint32_t test_nb_instruction_per_sec_120_nop_asm(void)
|
||||||
{
|
{
|
||||||
register u32 val __asm__("r0");
|
register uint32_t val __asm__("r0");
|
||||||
|
|
||||||
__asm__(" ldr r1, =g_ulSysTickCount");
|
__asm__(" ldr r1, =g_ulSysTickCount");
|
||||||
__asm__(" ldr r2, [r1]"); /* g_ulSysTickCount */
|
__asm__(" ldr r2, [r1]"); /* g_ulSysTickCount */
|
||||||
@ -745,9 +745,9 @@ u32 test_nb_instruction_per_sec_120_nop_asm(void)
|
|||||||
return val;
|
return val;
|
||||||
};
|
};
|
||||||
|
|
||||||
u32 test_nb_instruction_per_sec_150_nop_asm(void)
|
uint32_t test_nb_instruction_per_sec_150_nop_asm(void)
|
||||||
{
|
{
|
||||||
register u32 val __asm__("r0");
|
register uint32_t val __asm__("r0");
|
||||||
|
|
||||||
__asm__(" ldr r1, =g_ulSysTickCount");
|
__asm__(" ldr r1, =g_ulSysTickCount");
|
||||||
__asm__(" ldr r2, [r1]"); /* g_ulSysTickCount */
|
__asm__(" ldr r2, [r1]"); /* g_ulSysTickCount */
|
||||||
@ -931,9 +931,9 @@ u32 test_nb_instruction_per_sec_150_nop_asm(void)
|
|||||||
return val;
|
return val;
|
||||||
};
|
};
|
||||||
|
|
||||||
u32 test_nb_instruction_per_sec_200_nop_asm(void)
|
uint32_t test_nb_instruction_per_sec_200_nop_asm(void)
|
||||||
{
|
{
|
||||||
register u32 val __asm__("r0");
|
register uint32_t val __asm__("r0");
|
||||||
|
|
||||||
__asm__(" ldr r1, =g_ulSysTickCount");
|
__asm__(" ldr r1, =g_ulSysTickCount");
|
||||||
__asm__(" ldr r2, [r1]"); /* g_ulSysTickCount */
|
__asm__(" ldr r2, [r1]"); /* g_ulSysTickCount */
|
||||||
@ -1163,9 +1163,9 @@ u32 test_nb_instruction_per_sec_200_nop_asm(void)
|
|||||||
return val;
|
return val;
|
||||||
};
|
};
|
||||||
|
|
||||||
u32 test_nb_instruction_per_sec_1000_nop_asm(void)
|
uint32_t test_nb_instruction_per_sec_1000_nop_asm(void)
|
||||||
{
|
{
|
||||||
register u32 val __asm__("r0");
|
register uint32_t val __asm__("r0");
|
||||||
|
|
||||||
__asm__(" ldr r1, =g_ulSysTickCount");
|
__asm__(" ldr r1, =g_ulSysTickCount");
|
||||||
__asm__(" ldr r2, [r1]"); /* g_ulSysTickCount */
|
__asm__(" ldr r2, [r1]"); /* g_ulSysTickCount */
|
||||||
|
@ -22,19 +22,19 @@
|
|||||||
#include <libopencm3/lpc43xx/gpio.h>
|
#include <libopencm3/lpc43xx/gpio.h>
|
||||||
#include <libopencm3/lpc43xx/scu.h>
|
#include <libopencm3/lpc43xx/scu.h>
|
||||||
#include <libopencm3/lpc43xx/i2c.h>
|
#include <libopencm3/lpc43xx/i2c.h>
|
||||||
#include <libopencm3/lpc43xx/nvic.h>
|
#include <libopencm3/lpc43xx/m4/nvic.h>
|
||||||
#include <libopencm3/lpc43xx/systick.h>
|
#include <libopencm3/cm3/systick.h>
|
||||||
#include <libopencm3/cm3/scs.h>
|
#include <libopencm3/cm3/scs.h>
|
||||||
|
|
||||||
#include "hackrf_core.h"
|
#include "hackrf_core.h"
|
||||||
|
|
||||||
/* Global counter incremented by SysTick Interrupt each millisecond */
|
/* Global counter incremented by SysTick Interrupt each millisecond */
|
||||||
volatile u32 g_ulSysTickCount;
|
volatile uint32_t g_ulSysTickCount;
|
||||||
u32 g_NbCyclePerSecond;
|
uint32_t g_NbCyclePerSecond;
|
||||||
|
|
||||||
void systick_setup(void)
|
void systick_setup(void)
|
||||||
{
|
{
|
||||||
u32 systick_reload_val;
|
uint32_t systick_reload_val;
|
||||||
g_ulSysTickCount = 0;
|
g_ulSysTickCount = 0;
|
||||||
|
|
||||||
/* Disable IRQ globally */
|
/* Disable IRQ globally */
|
||||||
@ -73,15 +73,15 @@ void scs_dwt_cycle_counter_enabled(void)
|
|||||||
SCS_DWT_CTRL |= SCS_DWT_CTRL_CYCCNTENA;
|
SCS_DWT_CTRL |= SCS_DWT_CTRL_CYCCNTENA;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 sys_tick_get_time_ms(void)
|
uint32_t sys_tick_get_time_ms(void)
|
||||||
{
|
{
|
||||||
return g_ulSysTickCount;
|
return g_ulSysTickCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 sys_tick_delta_time_ms(u32 start, u32 end)
|
uint32_t sys_tick_delta_time_ms(uint32_t start, uint32_t end)
|
||||||
{
|
{
|
||||||
#define MAX_T_U32 ((2^32)-1)
|
#define MAX_T_U32 ((2^32)-1)
|
||||||
u32 diff;
|
uint32_t diff;
|
||||||
|
|
||||||
if(end > start)
|
if(end > start)
|
||||||
{
|
{
|
||||||
@ -94,10 +94,10 @@ u32 sys_tick_delta_time_ms(u32 start, u32 end)
|
|||||||
return diff;
|
return diff;
|
||||||
}
|
}
|
||||||
|
|
||||||
void sys_tick_wait_time_ms(u32 wait_ms)
|
void sys_tick_wait_time_ms(uint32_t wait_ms)
|
||||||
{
|
{
|
||||||
u32 start, end;
|
uint32_t start, end;
|
||||||
u32 tickms;
|
uint32_t tickms;
|
||||||
|
|
||||||
start = sys_tick_get_time_ms();
|
start = sys_tick_get_time_ms();
|
||||||
|
|
||||||
@ -127,16 +127,16 @@ void sys_tick_handler(void)
|
|||||||
g_ulSysTickCount++;
|
g_ulSysTickCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 nb_inst_per_sec[16];
|
uint32_t nb_inst_per_sec[16];
|
||||||
|
|
||||||
extern u32 test_nb_instruction_per_sec_100_nop_asm();
|
extern uint32_t test_nb_instruction_per_sec_100_nop_asm();
|
||||||
extern u32 test_nb_instruction_per_sec_105_nop_asm();
|
extern uint32_t test_nb_instruction_per_sec_105_nop_asm();
|
||||||
extern u32 test_nb_instruction_per_sec_110_nop_asm();
|
extern uint32_t test_nb_instruction_per_sec_110_nop_asm();
|
||||||
extern u32 test_nb_instruction_per_sec_115_nop_asm();
|
extern uint32_t test_nb_instruction_per_sec_115_nop_asm();
|
||||||
extern u32 test_nb_instruction_per_sec_120_nop_asm();
|
extern uint32_t test_nb_instruction_per_sec_120_nop_asm();
|
||||||
extern u32 test_nb_instruction_per_sec_150_nop_asm();
|
extern uint32_t test_nb_instruction_per_sec_150_nop_asm();
|
||||||
extern u32 test_nb_instruction_per_sec_200_nop_asm();
|
extern uint32_t test_nb_instruction_per_sec_200_nop_asm();
|
||||||
extern u32 test_nb_instruction_per_sec_1000_nop_asm();
|
extern uint32_t test_nb_instruction_per_sec_1000_nop_asm();
|
||||||
|
|
||||||
#define LED1_TOGGLE() (gpio_toggle(PORT_LED1_3, (PIN_LED1)))
|
#define LED1_TOGGLE() (gpio_toggle(PORT_LED1_3, (PIN_LED1)))
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user