Skip to content

Commit

Permalink
Merge pull request #64 from c1728p9/more_updates
Browse files Browse the repository at this point in the history
More updates
  • Loading branch information
sg- committed Feb 25, 2016
2 parents c42b978 + 979d0c0 commit 0a37e9c
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 48 deletions.
2 changes: 1 addition & 1 deletion source/hif_hal/atmel/sam3u2c/uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*/

#define _CPU_CLK_HZ SystemCoreClock
#define _CDC_BUFFER_SIZE (256) //64
#define _CDC_BUFFER_SIZE (512)

#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
Expand Down
2 changes: 1 addition & 1 deletion source/hif_hal/freescale/kl26z/uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include "string.h"

// Size must be 2^n for using quick wrap around
#define UART_BUFFER_SIZE (64)
#define UART_BUFFER_SIZE (512)

struct {
uint8_t data[UART_BUFFER_SIZE];
Expand Down
41 changes: 24 additions & 17 deletions source/hif_hal/nxp/lpc11u35/gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "gpio.h"
#include "compiler.h"
#include "daplink.h"
#include "target_reset.h"

// This GPIO configuration is only valid for the LPC11U35 HIF
COMPILER_ASSERT(DAPLINK_HIF_ID == DAPLINK_HIF_ID_LPC11U35);
Expand Down Expand Up @@ -91,17 +92,17 @@ void gpio_init(void) {

// configure GPIO-LED as output
// DAP led (green)
LPC_GPIO->DIR[0] |= (PIN_DAP_LED);
LPC_GPIO->CLR[0] |= (PIN_DAP_LED);
LPC_GPIO->SET[0] = (PIN_DAP_LED);
LPC_GPIO->DIR[0] |= (PIN_DAP_LED);

// MSD led (red)
LPC_GPIO->DIR[0] |= (PIN_MSD_LED);
LPC_GPIO->CLR[0] |= (PIN_MSD_LED);
LPC_GPIO->SET[0] = (PIN_MSD_LED);
LPC_GPIO->DIR[0] |= (PIN_MSD_LED);

// Serial LED (blue)
LPC_IOCON->TDI_PIO0_11 |= 0x01;
LPC_GPIO->DIR[0] |= (PIN_CDC_LED);
LPC_GPIO->CLR[0] |= (PIN_CDC_LED);
LPC_GPIO->SET[0] = (PIN_CDC_LED);
LPC_GPIO->DIR[0] |= (PIN_CDC_LED);

// configure Button(s) as input
LPC_GPIO->DIR[RESET_PORT] &= ~(1 << RESET_PIN);
Expand Down Expand Up @@ -132,39 +133,45 @@ void gpio_init(void) {

void gpio_set_hid_led(gpio_led_state_t state) {
if (state) {
LPC_GPIO->SET[0] |= (PIN_DAP_LED);
LPC_GPIO->SET[0] = (PIN_DAP_LED);
} else {
LPC_GPIO->CLR[0] |= (PIN_DAP_LED);
LPC_GPIO->CLR[0] = (PIN_DAP_LED);
}
}

void gpio_set_cdc_led(gpio_led_state_t state) {
if (state) {
LPC_GPIO->SET[0] |= (PIN_CDC_LED);
LPC_GPIO->SET[0] = (PIN_CDC_LED);
} else {
LPC_GPIO->CLR[0] |= (PIN_CDC_LED);
LPC_GPIO->CLR[0] = (PIN_CDC_LED);
}
}

void gpio_set_msc_led(gpio_led_state_t state) {
if (state) {
LPC_GPIO->SET[0] |= (PIN_MSD_LED);
LPC_GPIO->SET[0] = (PIN_MSD_LED);
} else {
LPC_GPIO->CLR[0] |= (PIN_MSD_LED);
LPC_GPIO->CLR[0] = (PIN_MSD_LED);
}
}

uint8_t gpio_get_sw_reset(void)
{
static uint8_t last_reset_forward_pressed = 0;
uint8_t reset_forward_pressed;
uint8_t reset_pressed;
reset_forward_pressed = LPC_GPIO->PIN[RESET_FWRD_PORT] & (1 << RESET_FWRD_PIN) ? 0 : 1;

// Forward reset
if (reset_forward_pressed) {
LPC_GPIO->DIR[RESET_OUT_PORT] |= (1 << RESET_OUT_PIN);
} else {
LPC_GPIO->DIR[RESET_OUT_PORT] &= ~(1 << RESET_OUT_PIN);
// Forward reset if the state of the button has changed
// This must be done on button changes so it does not interfere
// with other reset sources such as programming or CDC Break
if (last_reset_forward_pressed != reset_forward_pressed) {
if (reset_forward_pressed) {
target_set_state(RESET_HOLD);
} else {
target_set_state(RESET_RUN);
}
last_reset_forward_pressed = reset_forward_pressed;
}

reset_pressed = reset_forward_pressed || (LPC_GPIO->PIN[RESET_PORT] & (1 << RESET_PIN) ? 0 : 1);
Expand Down
11 changes: 8 additions & 3 deletions test/daplink_board.py
Original file line number Diff line number Diff line change
Expand Up @@ -609,11 +609,16 @@ def test_details_txt(self, parent_test):
details_hif_id = details_txt[DaplinkBoard.KEY_HIF_ID]
if details_unique_id is not None:
if details_unique_id != self.unique_id:
test_info.failure("Unique ID mismatch in details.txt")
test_info.failure("Unique ID mismatch in details.txt "
"details.txt=%s, usb=%s" %
(details_unique_id, self.unique_id))
if details_hif_id is not None:
if details_hif_id != details_unique_id[-8:]:
usb_hif = details_unique_id[-8:]
if details_hif_id != usb_hif:
test_info.failure("HIF ID is not the last 8 "
"digits of unique ID")
"digits of unique ID "
"details.txt=%s, usb=%s" %
(details_hif_id, usb_hif))

def _parse_assert_txt(self):
file_path = self.get_file_path("ASSERT.TXT")
Expand Down
48 changes: 22 additions & 26 deletions test/test_daplink.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def daplink_test(workspace, parent_test):
test.run()

# Test loading a hex file with shutils
test = DLMassStorageTester(board, test_info, "Shutil hex file load"
test = DLMassStorageTester(board, test_info, "Shutil hex file load "
"interface", board.MODE_BL)
test.set_shutils_copy(interface.hex_path)
test.set_expected_data(bin_data)
Expand Down Expand Up @@ -352,35 +352,31 @@ def get_file_content(addr, bin_data):
test.run()

# Test bad crc in file data
file_name = get_file_name()
local_raw_data = bytearray(raw_data)
local_raw_data[0x100] = (local_raw_data[0x100] + 1) % 0x100 # Corrupt CRC
local_data = get_file_content(data_start, local_raw_data)
test = DLMassStorageTester(board, test_info, 'Wrong data CRC',
board_mode)
test.set_programming_data(local_data, file_name)
# Note - crc is only a requirment for loading bootloades
if board_mode == board.MODE_IF:
file_name = get_file_name()
local_raw_data = bytearray(raw_data)
local_raw_data[0x100] = (local_raw_data[0x100] + 1) % 0x100 # Corrupt CRC
local_data = get_file_content(data_start, local_raw_data)
test = DLMassStorageTester(board, test_info, 'Wrong data CRC',
board_mode)
test.set_programming_data(local_data, file_name)
test.set_expected_failure_msg('The bootloader CRC did not pass.\r\n')
test.set_expected_data(None)
elif board_mode == board.MODE_BL:
# Interface images can be from other vendors and be missing
# the crc, so don't treat this as an error
test.set_expected_data(local_raw_data)
test.run()
# If bootloader is missing then this should be indicated by a file
if (board_mode == board.MODE_IF and
not os.path.isfile(board.get_file_path(NEED_BL_FILE_NAME))):
test_info.failure("Bootloader missing but file %s not present" %
NEED_BL_FILE_NAME)
test.run()
# If bootloader is missing then this should be indicated by a file
if not os.path.isfile(board.get_file_path(NEED_BL_FILE_NAME)):
test_info.failure("Bootloader missing but file %s not present" %
NEED_BL_FILE_NAME)

# Restore a good image
file_name = get_file_name()
local_data = get_file_content(data_start, raw_data)
test = DLMassStorageTester(board, test_info, "Normal Load",
board_mode)
test.set_programming_data(local_data, file_name)
test.set_expected_data(raw_data)
test.run()
# Restore a good image
file_name = get_file_name()
local_data = get_file_content(data_start, raw_data)
test = DLMassStorageTester(board, test_info, "Normal Load",
board_mode)
test.set_programming_data(local_data, file_name)
test.set_expected_data(raw_data)
test.run()

# Test wrong HIF ID
# Bootloader should perform interface update regardless of key
Expand Down

0 comments on commit 0a37e9c

Please sign in to comment.