+// SPDX-License-Identifier: GPL-2.0-or-later
+
/***************************************************************************
* Copyright (C) 2017 by Texas Instruments, Inc. *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/
#ifdef HAVE_CONFIG_H
#include "imp.h"
#include "cc3220sf.h"
+#include <helper/binarybuffer.h>
#include <helper/time_support.h>
#include <target/algorithm.h>
#include <target/armv7m.h>
struct armv7m_algorithm armv7m_info;
};
+/* Flash helper algorithm for CC3220SF */
+static const uint8_t cc3220sf_algo[] = {
+#include "../../../contrib/loaders/flash/cc3220sf/cc3220sf.inc"
+};
+
static int cc3220sf_mass_erase(struct flash_bank *bank)
{
struct target *target = bank->target;
int retval = ERROR_OK;
- if (TARGET_HALTED != target->state) {
+ if (target->state != TARGET_HALTED) {
LOG_ERROR("Target not halted");
return ERROR_TARGET_NOT_HALTED;
}
return ERROR_COMMAND_SYNTAX_ERROR;
cc3220sf_bank = malloc(sizeof(struct cc3220sf_bank));
- if (NULL == cc3220sf_bank)
+ if (!cc3220sf_bank)
return ERROR_FAIL;
/* Initialize private flash information */
/* Finish initialization of flash bank */
bank->driver_priv = cc3220sf_bank;
- bank->next = NULL;
return ERROR_OK;
}
int retval = ERROR_OK;
- if (TARGET_HALTED != target->state) {
+ if (target->state != TARGET_HALTED) {
LOG_ERROR("Target not halted");
return ERROR_TARGET_NOT_HALTED;
}
int retval = ERROR_OK;
- if (TARGET_HALTED != target->state) {
+ if (target->state != TARGET_HALTED) {
LOG_ERROR("Target not halted");
return ERROR_TARGET_NOT_HALTED;
}
/* Check that the head value was written to flash */
result = buf_get_u32(reg_params[2].value, 0, 32);
- if (0 != result) {
+ if (result != 0) {
retval = ERROR_FAIL;
LOG_ERROR("cc3220sf: Flash operation failed");
}
/* Check that all words were written to flash */
result = buf_get_u32(reg_params[2].value, 0, 32);
- if (0 != result) {
+ if (result != 0) {
retval = ERROR_FAIL;
LOG_ERROR("cc3220sf: Flash operation failed");
break;
}
/* Do one word write for any final bytes less than a full word */
- if ((retval == ERROR_OK) && (0 != tail_count)) {
+ if ((retval == ERROR_OK) && (tail_count != 0)) {
uint8_t tail[4];
/* Set starting byte offset for data to write */
/* Check that the tail was written to flash */
result = buf_get_u32(reg_params[2].value, 0, 32);
- if (0 != result) {
+ if (result != 0) {
retval = ERROR_FAIL;
LOG_ERROR("cc3220sf: Flash operation failed");
}
free(bank->sectors);
bank->sectors = malloc(sizeof(struct flash_sector) * num_sectors);
- if (NULL == bank->sectors)
+ if (!bank->sectors)
return ERROR_FAIL;
bank->base = base;