Firmware for MAXREFES1265
Dependencies: max32625pico SerialInterface maxim-dev USBDevice
Revision 0:4a433af35131, committed 2020-05-05
- Comitter:
- venkik
- Date:
- Tue May 05 16:39:00 2020 +0000
- Commit message:
- Final MAXREFDES1265 design
Changed in this revision
diff -r 000000000000 -r 4a433af35131 .gitignore --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.gitignore Tue May 05 16:39:00 2020 +0000 @@ -0,0 +1,4 @@ +.build +.mbed +projectfiles +*.py*
diff -r 000000000000 -r 4a433af35131 CONTRIBUTING.md --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/CONTRIBUTING.md Tue May 05 16:39:00 2020 +0000 @@ -0,0 +1,5 @@ +# Contributing to Mbed OS + +Mbed OS is an open-source, device software platform for the Internet of Things. Contributions are an important part of the platform, and our goal is to make it as simple as possible to become a contributor. + +To encourage productive collaboration, as well as robust, consistent and maintainable code, we have a set of guidelines for [contributing to Mbed OS](https://os.mbed.com/docs/mbed-os/latest/contributing/index.html).
diff -r 000000000000 -r 4a433af35131 README.md --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/README.md Tue May 05 16:39:00 2020 +0000 @@ -0,0 +1,64 @@ +![](./resources/official_armmbed_example_badge.png) +# Blinky Mbed OS example + +The example project is part of the [Arm Mbed OS Official Examples](https://os.mbed.com/code/) and is the [getting started example for Mbed OS](https://os.mbed.com/docs/mbed-os/v5.14/quick-start/index.html). It contains an application that repeatedly blinks an LED on supported [Mbed boards](https://os.mbed.com/platforms/). + +You can build the project with all supported [Mbed OS build tools](https://os.mbed.com/docs/mbed-os/latest/tools/index.html). However, this example project specifically refers to the command-line interface tool [Arm Mbed CLI](https://github.com/ARMmbed/mbed-cli#installing-mbed-cli). +(Note: To see a rendered example you can import into the Arm Online Compiler, please see our [import quick start](https://os.mbed.com/docs/mbed-os/latest/quick-start/online-with-the-online-compiler.html#importing-the-code).) + +1. [Install Mbed CLI](https://os.mbed.com/docs/mbed-os/latest/quick-start/offline-with-mbed-cli.html). + +1. Clone this repository on your system, and change the current directory to where the project was cloned: + + ```bash + $ git clone git@github.com:armmbed/mbed-os-example-blinky && cd mbed-os-example-blinky + ``` + + Alternatively, you can download the example project with Arm Mbed CLI using the `import` subcommand: + + ```bash + $ mbed import mbed-os-example-blinky && cd mbed-os-example-blinky + ``` + + +## Application functionality + +The `main()` function is the single thread in the application. It toggles the state of a digital output connected to an LED on the board. + +## Building and running + +1. Connect a USB cable between the USB port on the board and the host computer. +2. <a name="build_cmd"></a> Run the following command to build the example project and program the microcontroller flash memory: + ```bash + $ mbed compile -m <TARGET> -t <TOOLCHAIN> --flash + ``` +The binary is located at `./BUILD/<TARGET>/<TOOLCHAIN>/mbed-os-example-blinky.bin`. + +Alternatively, you can manually copy the binary to the board, which you mount on the host computer over USB. + +Depending on the target, you can build the example project with the `GCC_ARM`, `ARM` or `IAR` toolchain. After installing Arm Mbed CLI, run the command below to determine which toolchain supports your target: + +```bash +$ mbed compile -S +``` + +## Expected output +The LED on your target turns on and off every 500 milliseconds. + + +## Troubleshooting +If you have problems, you can review the [documentation](https://os.mbed.com/docs/latest/tutorials/debugging.html) for suggestions on what could be wrong and how to fix it. + +## Related Links + +* [Mbed OS Stats API](https://os.mbed.com/docs/latest/apis/mbed-statistics.html). +* [Mbed OS Configuration](https://os.mbed.com/docs/latest/reference/configuration.html). +* [Mbed OS Serial Communication](https://os.mbed.com/docs/latest/tutorials/serial-communication.html). +* [Mbed OS bare metal](https://os.mbed.com/docs/mbed-os/latest/reference/mbed-os-bare-metal.html). +* [Mbed boards](https://os.mbed.com/platforms/). + +### License and contributions + +The software is provided under Apache-2.0 license. Contributions to this project are accepted under the same license. Please see contributing.md for more info. + +This project contains code from other projects. The original license text is included in those source files. They must comply with our license guide.
diff -r 000000000000 -r 4a433af35131 SerialInterface.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SerialInterface.lib Tue May 05 16:39:00 2020 +0000 @@ -0,0 +1,1 @@ +https://developer.mbed.org/users/switches/code/SerialInterface/#a0937dc92631
diff -r 000000000000 -r 4a433af35131 USBDevice.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/USBDevice.lib Tue May 05 16:39:00 2020 +0000 @@ -0,0 +1,1 @@ +https://developer.mbed.org/teams/MaximIntegrated/code/USBDevice/#c5e178adb138
diff -r 000000000000 -r 4a433af35131 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue May 05 16:39:00 2020 +0000 @@ -0,0 +1,194 @@ +/******************************************************************************* +* Copyright (C) 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. +*******************************************************************************/ +//============================================================================== +//This code is only suitable for single switch press not simultaneous switch press +//The following code needs maxim-dev library to run. The complete package is available in the GITHUB +//============================================================================== +//Header files +#include "mbed.h" +#include "USBSerial.h" +#include "max32625pico.h" +#include "SerialInterface.h" + + +const int Slave_address = 0x70; // MAX7360 I2C slave address +const int max_key = 63; + +// Virtual serial port over USB +USBSerial microUSB(0x0B6A, 0x4360); + +DigitalIn nINTK(P4_5); // Key switch interrupt configures as GPIO, refer to page 11 of DS for more info + +//The following line of code is optional and please uncomment if you are using rotary encoder +//DigitalIn nINTI(P4_4); // Interrupt for rotary switch configuration, refer to page 14 for more info + +//The following line of code sets all the GPIO to 1.8 volts +MAX32625PICO pico(MAX32625PICO::IOH_DIP_IN, MAX32625PICO::VIO_IOH, MAX32625PICO::VIO_1V8); + +// Serial Interfaces +I2C i2c(P1_6, P1_7); + + + +int main() +{ + + +//--------Register configuration for the MAX7360-------------------------------- +//Please refer to page 10 and table 8 of the data sheet + +//Writing the configuration register (0x01) of MAX7360. + + + char Datawrite_config[2]; + Datawrite_config[0] = 0x01; //Address of the register + Datawrite_config[1] = 0x20; //Configuring the register for Interrupt by making D5 to 1 and all the other bits to 0 + i2c.write( Slave_address, Datawrite_config, 2 ); + +//Writing the Key switch interrupt register (0x03) MAX7360. +//Please refer to table 10 of the data sheet +//The interrupt register contains information related to the +//settings of the interrupt request function, as well as the +//status of the INTK output, which can also be configured +//as a GPIO + char Datawrite_Key_Switch_Interrupt[2]; + Datawrite_Key_Switch_Interrupt[0] = 0x03; //Address of the register + Datawrite_Key_Switch_Interrupt[1] = 0x08; //Configuring the TIME-BASED INTK bits to get 8 debounce cycles + i2c.write( Slave_address, Datawrite_Key_Switch_Interrupt, 2 ); + + +//Writing the auto sleep register (0x06)MAX7360 Autosleep Register no autosleep + char Autosleep[2]; + Autosleep[0] = 0x06; //Address of the register + Autosleep[1] = 0x00; //AUTOSHUTDOWN TIME to no autosleep, refer to page 25 of DS + i2c.write( Slave_address, Autosleep, 2 ); + + +//Writing the GPIO Global Configuration (0x40) +//Enable rotary encoder and normal GPIO operation + char GlobalConfig[2]; + GlobalConfig[0] = 0x40; //Address of the register + GlobalConfig[1] = 0x90; //Enabling the I2C timeout interrupt and rotary switch by setting D7 and D5 to 1 and all others to zero + i2c.write( Slave_address, GlobalConfig, 2 ); + +//============================================================================== +//Uncomment below if you would like ot use rotary encoder +//============================================================================== +//Writing GPIO Control Register +// char GPIOControl[2]; +// GPIOControl[0] = 0x41; //Address +// GPIOControl[1] = 0x3F; //Registrer configuration, All GPIOs configured as output, except ports 6 and 7, because they are connected to the rotary encoder +// i2c.write( Slave_address, GPIOControl, 2 ); +//Writing the Rotatory switch configuration (0x46). Please refer to table 20 of the data sheet +// char Datawrite_Rotatory_Switch_configuration[2]; +//Rotary Switch Configuration Register nINTI asserted 25ms after first debounced event, no debounce cycle time +// Datawrite_Rotatory_Switch_configuration[0] = 0x46; +// Datawrite_Rotatory_Switch_configuration[1] = 0x90; // Rotary Switch Configuration Register nINTI asserted 25ms after first debounced event, no debounce cycle time +//Datawrite_Rotatory_Switch_configuration[1] = 0x11; +// i2c.write( Slave_address, Datawrite_Rotatory_Switch_configuration, 2 ); + + /* + // Writing PORT6 Configuration Register mask interrupt (0x5E) + char Port6[2]; + Port6[0] = 0x5E; // Address + Port6[1] = 0x80;// masking the interrupt by enabling the D7 to 1 refer to page 30 of DS + i2c.write( Slave_address, Port6, 2 ); + + // Writing PORT7 Configuration Register mask interrupt (0x5F) + char Port7[2]; + Port7[0] = 0x5F; //Address + Port7[1] = 0x80; // masking of the interrupt by making D7 to 1 refer to page 30 of DS + i2c.write( Slave_address, Port7, 2 ); + */ +//----------------------------------------------------------------------------- +//Default register values +//----------------------------------------------------------------------------- +//writeMAX7360(0x02,0xFF);// Debounce Register only column 0 enabled, debounce set to 40ms +// writeMAX7360(0x04,0xFE); // Ports Register +// writeMAX7360(0x05,0x00); // Autorepeat Register +// writeMAX7360(0x42,0x00); // GPIO Debounce Configuration Register +// writeMAX7360(0x43,0xC0); // GPIO Constant-Current Setting Register +// writeMAX7360(0x44,0x00); // GPIO Output Mode Register +// writeMAX7360(0x45,0x00); // Common PWM Register + +//------------------End of Register configuration for MAX7360-----------------// + + + while(1) { + + + +//Reading the Key FIFO register (0x00) from MAX7360. +//Please refer to page 10 and table 7 of the data sheet + char KeyFIFOData; + char l = 0x00; + i2c.write( Slave_address, &l, 1 ); + i2c.read( Slave_address, &KeyFIFOData, 1 ); + + + if(KeyFIFOData!= max_key) { + microUSB.printf("KeyFIFOData = %d \n\r", KeyFIFOData); + } + + // wait_ms(50); This may be necessary for console printing + +//============================================================================== +//Uncomment the code below for rotary encoder +//============================================================================== +////Reading the Rotatory switch count register (0x4A). Please refer to page 12 and table 23 of the data sheet +// +// char RotaryData; +// char m = 0x4A; +// if(!nINTI) { +// i2c.write( Slave_address, &m, 1 ); +// i2c.read( Slave_address, &RotaryData, 1 ); +// +// if(RotaryData!= 0) { +// +// microUSB.printf("RotaryData = %x \r\n", RotaryData); +// } +// +// // wait_ms(100); This may be necessary for console printing +// +// } + + } +} + + + + + + + + +
diff -r 000000000000 -r 4a433af35131 max32625pico.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/max32625pico.lib Tue May 05 16:39:00 2020 +0000 @@ -0,0 +1,1 @@ +https://developer.mbed.org/users/switches/code/max32625pico/#65bda25808e4
diff -r 000000000000 -r 4a433af35131 maxim-dev.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/maxim-dev.lib Tue May 05 16:39:00 2020 +0000 @@ -0,0 +1,1 @@ +http://os.mbed.com/users/switches/code/maxim-dev/#2e7515f8c45d
diff -r 000000000000 -r 4a433af35131 resources/official_armmbed_example_badge.png Binary file resources/official_armmbed_example_badge.png has changed