Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev me12 fthr support #469

Merged
merged 5 commits into from
Mar 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions Examples/MAX32662/I2C/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
#include "nvic_table.h"
#include "i2c.h"
#include "dma.h"
#include "board.h"

/***** Definitions *****/
//#define MASTERDMA //Comment this line out if standard I2C transaction is required
Expand Down Expand Up @@ -199,9 +200,17 @@ int main()
printf("read and write to another I2C which acts as a slave.\n");

printf("\nYou will need to connect P0.12->P0.6 (SCL) and\n");
printf("P0.13->P0.9 (SDA). As well jumper JP1 (VREF) needs\n");
printf("P0.13->P0.9 (SDA).");
#if defined(BOARD_EVKIT_V1)
printf("As well jumper JP1 (VREF) needs\n");
printf("to be removed.\n");
#else
printf("\nTo have pull up resistor\n");
printf("Either connect SLAVE_SCL to P0.12 and SLAVE_SDA to P0.13\n");
printf("Or use breadboard and connect P0.12 to 3.3V with 4.7k \n");
printf("and P0.13 to 3.3V with 4.7k\n");

#endif
int error, i = 0;

//Setup the I2CM
Expand Down Expand Up @@ -277,7 +286,7 @@ int main()
printf("\n-->Result: \n");
printData();
printf("\n");
if (verifyData()) {
if (!verifyData()) {
printf("\n-->I2C Transaction Successful\n");
} else {
printf("\n-->I2C Transaction Failed\n");
Expand Down
13 changes: 7 additions & 6 deletions Examples/MAX32662/UART/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,11 @@

#define UART_BAUD 115200
#define BUFF_SIZE 1024
#define READING_UART MXC_UART0
#define READ_IDX MXC_UART_GET_IDX(MXC_UART0)
#define WRITING_UART MXC_UART1
#define WRITE_IDX MXC_UART_GET_IDX(MXC_UART1)

#define READING_UART MXC_UART1
#define READ_IDX MXC_UART_GET_IDX(MXC_UART1)
#define WRITING_UART MXC_UART0
#define WRITE_IDX MXC_UART_GET_IDX(MXC_UART0)

/***** Globals *****/
volatile int READ_FLAG;
Expand Down Expand Up @@ -100,7 +101,7 @@ int main(void)

printf("\n\n**************** UART Example ******************\n");
printf("This example shows a loopback test between the 2 UARTs on the MAX32662.\n");
printf("\nConnect UART0 to UART1 (P0.11 (AIN2) -> P0.2) for this example.\n");
printf("\nConnect UART0B TX to UART1A RX (P0.8 -> P0.3) for this example.\n");
printf("The LEDs are used to indicate the success of the test.\nBlinking->Success, "
"Solid->Failure\n");

Expand Down Expand Up @@ -133,7 +134,7 @@ int main(void)
MXC_Delay(MXC_DELAY_SEC(1));

// Initialize the UART
if ((error = MXC_UART_Init(WRITING_UART, UART_BAUD, MXC_UART_APB_CLK, MAP_A)) != E_NO_ERROR) {
if ((error = MXC_UART_Init(WRITING_UART, UART_BAUD, MXC_UART_APB_CLK, MAP_B)) != E_NO_ERROR) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#if else condition seems not needed.
The function and parameters are exactly same.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if calls MAP_A else calls MAB_B. They are not exactly same.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The UART0B pins are accessible on the EvKit (RX: P0.7; TX: P0.8). Would it be easier if both the EvKit and FTHR boards use UART0B as the WRITING_UART and UART1A as the READING_UART? Unless you want to show the MAP_A vs MAP_B difference, this will minimize the amount of #if,#else,#endif directives used between the two boards if both run on the same set of pins.

Shutdown_UARTS();
Console_Init();
printf("-->Error initializing UART: %d\n", error);
Expand Down
7 changes: 7 additions & 0 deletions Libraries/Boards/MAX32662/EvKit_V1/Include/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@
extern "C" {
#endif

/*
Define board name:
Use as #if defined(BOARD_EVKIT_V1)
Not as #if BOARD_EVKIT_V1
*/
#define BOARD_EVKIT_V1 1

#ifndef CONSOLE_UART
#define CONSOLE_UART 0 /// UART instance to use for console
#endif
Expand Down
98 changes: 98 additions & 0 deletions Libraries/Boards/MAX32662/FTHR/Include/board.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/******************************************************************************
* Copyright (C) 2023 Maxim Integrated Products, Inc., All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
* OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Except as contained in this notice, the name of Maxim Integrated
* Products, Inc. shall not be used except as stated in the Maxim Integrated
* Products, Inc. Branding Policy.
*
* The mere transfer of this software does not imply any licenses
* of trade secrets, proprietary technology, copyrights, patents,
* trademarks, maskwork rights, or any other form of intellectual
* property whatsoever. Maxim Integrated Products, Inc. retains all
* ownership rights.
*
******************************************************************************/

/**
* @file board.h
* @brief Board support package API.
*/

#include <stdio.h>

#ifndef LIBRARIES_BOARDS_MAX32662_FTHR_INCLUDE_BOARD_H_
#define LIBRARIES_BOARDS_MAX32662_FTHR_INCLUDE_BOARD_H_

#ifdef __cplusplus
extern "C" {
#endif

/*
Define board name:
Use as #if defined(BOARD_FTHR)
Not as #if BOARD_FTHR
*/
#define BOARD_FTHR 1

#ifndef CONSOLE_UART
#define CONSOLE_UART 0 /// UART instance to use for console
#endif

#ifndef CONSOLE_BAUD
#define CONSOLE_BAUD 115200 /// Console baud rate
#endif

#define LED_OFF 1 /// Inactive state of LEDs
#define LED_ON 0 /// Active state of LEDs

#define LED1 0
#define LED2 1

/**
* \brief Initialize the BSP and board interfaces.
* \returns #E_NO_ERROR if everything is successful
*/
int Board_Init(void);

/**
* \brief Initialize or reinitialize the console. This may be necessary if the
* system clock rate is changed.
* \returns #E_NO_ERROR if everything is successful
*/
int Console_Init(void);

/**
* \brief Shutdown the console.
* \returns #E_NO_ERROR if everything is successful
*/
int Console_Shutdown(void);

/**
* \brief Attempt to prepare the console for sleep.
* \returns #E_NO_ERROR if ready to sleep, #E_BUSY if not ready for sleep.
*/
int Console_PrepForSleep(void);

#ifdef __cplusplus
}
#endif

#endif // LIBRARIES_BOARDS_MAX32662_FTHR_INCLUDE_BOARD_H_
115 changes: 115 additions & 0 deletions Libraries/Boards/MAX32662/FTHR/Source/board.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
/******************************************************************************
* Copyright (C) 2023 Maxim Integrated Products, Inc., All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
* OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Except as contained in this notice, the name of Maxim Integrated
* Products, Inc. shall not be used except as stated in the Maxim Integrated
* Products, Inc. Branding Policy.
*
* The mere transfer of this software does not imply any licenses
* of trade secrets, proprietary technology, copyrights, patents,
* trademarks, maskwork rights, or any other form of intellectual
* property whatsoever. Maxim Integrated Products, Inc. retains all
* ownership rights.
*
******************************************************************************/

#include <stdio.h>
#include "mxc_device.h"
#include "mxc_sys.h"
#include "mxc_errors.h"
#include "mxc_assert.h"
#include "board.h"
#include "uart.h"
#include "gpio.h"
#include "mxc_pins.h"
#include "led.h"
#include "pb.h"

/***** Global Variables *****/
mxc_uart_regs_t *ConsoleUart = MXC_UART_GET_UART(CONSOLE_UART);
extern uint32_t SystemCoreClock;

const mxc_gpio_cfg_t pb_pin[] = { { MXC_GPIO0, MXC_GPIO_PIN_6, MXC_GPIO_FUNC_IN,
MXC_GPIO_PAD_PULL_UP, MXC_GPIO_VSSEL_VDDIOH } };
const unsigned int num_pbs = (sizeof(pb_pin) / sizeof(mxc_gpio_cfg_t));

const mxc_gpio_cfg_t led_pin[] = { { MXC_GPIO0, MXC_GPIO_PIN_14, MXC_GPIO_FUNC_OUT,
MXC_GPIO_PAD_NONE, MXC_GPIO_VSSEL_VDDIO } };
const unsigned int num_leds = (sizeof(led_pin) / sizeof(mxc_gpio_cfg_t));

/***** File Scope Variables *****/

/******************************************************************************/
void mxc_assert(const char *expr, const char *file, int line)
{
printf("MXC_ASSERT %s #%d: (%s)\n", file, line, expr);
while (1) {}
}

/******************************************************************************/
int Board_Init(void)
{
int err;

if ((err = Console_Init()) < E_NO_ERROR) {
return err;
}

if ((err = PB_Init()) != E_NO_ERROR) {
MXC_ASSERT_FAIL();
return err;
}

if ((err = LED_Init()) != E_NO_ERROR) {
MXC_ASSERT_FAIL();
return err;
}

return E_NO_ERROR;
}

/******************************************************************************/
int Console_Init(void)
{
int err;

if ((err = MXC_UART_Init(ConsoleUart, CONSOLE_BAUD, MXC_UART_APB_CLK, MAP_A)) != E_NO_ERROR) {
return err;
}

return E_NO_ERROR;
}

int Console_Shutdown(void)
{
int err;

if ((err = MXC_UART_Shutdown(ConsoleUart)) != E_NO_ERROR) {
return err;
}

return E_NO_ERROR;
}
/******************************************************************************/
void NMI_Handler(void)
{
__NOP();
}
82 changes: 82 additions & 0 deletions Libraries/Boards/MAX32662/FTHR/Source/rom_stub.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/******************************************************************************
* Copyright (C) 2023 Maxim Integrated Products, Inc., All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
* OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Except as contained in this notice, the name of Maxim Integrated
* Products, Inc. shall not be used except as stated in the Maxim Integrated
* Products, Inc. Branding Policy.
*
* The mere transfer of this software does not imply any licenses
* of trade secrets, proprietary technology, copyrights, patents,
* trademarks, maskwork rights, or any other form of intellectual
* property whatsoever. Maxim Integrated Products, Inc. retains all
* ownership rights.
*
******************************************************************************/

#include "max32662.h"

/* The stack address is defined by the linker
* It is typed as a function here to avoid compiler warnings
*/
extern void __StackTop(void);

void Reset_Handler(void);
void NMI_Handler_ROM(void);
void HardFault_Handler_ROM(void);
void MemManage_Handler(void);
void BusFault_Handler(void);
void UsageFault_Handler(void);
void SVC_Handler(void);
void DebugMon_Handler(void);
void PendSV_Handler(void);
void SysTick_Handler(void);

/* Create a vector table to locate at zero in the ROM for handling reset and startup */
__attribute__((section(".rom_vector"))) void (*const rom_vector[])(void) = {
__StackTop, /* Top of Stack */
Reset_Handler, /* Reset Handler */
NMI_Handler_ROM, /* NMI Handler */
HardFault_Handler_ROM, /* Hard Fault Handler */
MemManage_Handler, /* MPU Fault Handler */
BusFault_Handler, /* Bus Fault Handler */
UsageFault_Handler, /* Usage Fault Handler */
0, /* Reserved */
0, /* Reserved */
0, /* Reserved */
0, /* Reserved */
SVC_Handler, /* SVCall Handler */
DebugMon_Handler, /* Debug Monitor Handler */
0, /* Reserved */
PendSV_Handler, /* PendSV Handler */
SysTick_Handler, /* SysTick Handler */
};

/* This is needed to handle the NMI at POR */
__attribute__((section(".rom_handlers"))) void NMI_Handler_ROM(void)
{
__NOP();
}

/* This is needed to handle the fault after initial programming */
__attribute__((section(".rom_handlers"))) void HardFault_Handler_ROM(void)
{
NVIC_SystemReset();
}
Loading