Hello everyone,
I tried many examples on my own board with MCF52259. I am using MQX3.7 and CW10.1. I added;
I am also using USB Host bootloader with the design examle of AN4368
So I am using with;
#define MQX_ROM_VECTORS 0 //DES 1=ROM, 0=RAM vector table...used with bootloaders
in "user_config.h"
and I am using the lines
{
interrupts (RX) : ORIGIN = 0x00010000, LENGTH = 0x00000400
cfmprotrom (RX) : ORIGIN = 0x00010400, LENGTH = 0x0000010
code (RX) : ORIGIN = 0x00010410, LENGTH = 0x0006FBF0
}
in "intflash.lcf" file.
It is OK up to here.
for NQ7 usage I added
#define BSP_SW3 (GPIO_PORT_NQ | GPIO_PIN7)
line to the "m52259demo.h" file.
and I used the codes below;
The program gives me "Failed input" error when try to open "input_port" with Pin7 interrupt. But it is OK when I use NQPin1 and NQPin5.
Is anyone konws that how to use NQ7 pin interrupt? Or there a problem with MQX3.7.
I also tried _int_install_kernel_isr(MCF5225_INT_EPORT0_EPF7, new_irq7or1_isr); but it also not worked anymore.
Please help..
/**HEADER********************************************************************
*
* Copyright (c) 2008 Freescale Semiconductor;
* All Rights Reserved
*
***************************************************************************
*
* THIS SOFTWARE IS PROVIDED BY FREESCALE "AS IS" AND ANY EXPRESSED OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL FREESCALE OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*
**************************************************************************
*
* $FileName: gpio.c$
* $Version : 3.6.25.0$
* $Date : Jun-4-2010$
*
* Comments:
*
* This file contains the source for the gpio example program.
*
*END************************************************************************/
#include <mqx.h>
#include <bsp.h>
#include <io_gpio.h>
#if ! BSPCFG_ENABLE_IO_SUBSYSTEM
#error This application requires BSPCFG_ENABLE_IO_SUBSYSTEM defined non-zero in user_config.h. Please recompile BSP with this option.
#endif
#if ! BSPCFG_ENABLE_GPIODEV
#error This application requires BSPCFG_ENABLE_GPIODEV defined non-zero in user_config.h. Please recompile BSP with this option.
#endif
/* Task IDs */
#define MAIN_TASK 5
/* Function prototypes */
extern void main_task(uint_32);
void irq_callback(pointer);
int i;
static FILE_PTR input_port=NULL, output_port=NULL;
const TASK_TEMPLATE_STRUCT MQX_template_list[] =
{
/* Task Index, Function, Stack, Priority, Name, Attributes, Param, Time Slice */
{ MAIN_TASK, main_task, 1500, 5, "service", MQX_AUTO_START_TASK, 0, 0 },
{ 0 }
};
/* Example IRQ callback. Place breakpoint in function to determine if gets called */
static void irq_callback(pointer)
{
i++;
}
/*TASK*-----------------------------------------------------
**
** Task Name : main_task
** Comments :
** This task performs various open - close operation on
** several sets of pins. The purpose of this demo is to
** explain and demonstrate the use of "pin files" as the output
** of GPIO fopen command. The demonstration is focused mainly
** on debugging and realising what we are performing on which
** set of pins.
** At the end of this task, neverending loop runs and reads
** status of pin connected to SWITCH_1 and the same value writes
** on output pin connected to LED D10.
*END*-----------------------------------------------------*/
void main_task (uint_32 initial_data)
{
//Create GPIO structures for input and output
const uint_32 output_set[] = {
(BSP_LED1 | GPIO_PIN_STATUS_0),
(BSP_LED2 | GPIO_PIN_STATUS_0),
(BSP_LED3 | GPIO_PIN_STATUS_0),
(BSP_LED4 | GPIO_PIN_STATUS_0),
GPIO_LIST_END
};
const uint_32 input_set[] = {
(BSP_SW1 | GPIO_PIN_IRQ_FALLING),
(BSP_SW3 | GPIO_PIN_IRQ_FALLING),
//(BSP_SW2 | GPIO_PIN_IRQ_FALLING),
GPIO_LIST_END
};
/* Open and set port pins as output to drive LEDs (LED10 - LED13) */
output_port = fopen("gpio:write", (char_ptr) &output_set);
/* Open and set port pins as input to read value from switches */
input_port = fopen("gpio:read", (char_ptr) &input_set);
if(input_port==NULL)
printf("Failed input\n");
if(output_port==NULL)
printf("Failed output\n");
if (output_port)
ioctl(output_port, GPIO_IOCTL_WRITE_LOG0, NULL);
/* Configure input pins as interrupts */
ioctl(input_port, GPIO_IOCTL_SET_IRQ_FUNCTION, (pointer) &irq_callback);
ioctl(input_port, GPIO_IOCTL_ENABLE_IRQ, NULL);
/* It is not easy to generalize switch: every board has its own switch names */
printf("Use SWITCH on board to switch LED on or off\n");
while (TRUE)
{
/* read pin/signal status to pin list */
if (IO_OK != ioctl(input_port, GPIO_IOCTL_READ, (char_ptr) &input_set))
{
printf("Reading pin status from file3 to pins4 list failed.\n");
_mqx_exit(-1);
}
/* test first's pin of file binary value */
if (input_set[1] & GPIO_PIN_STATUS)
{
printf("LED OFF.\n");
/* clear pin to 0 (fast) */
if (IO_OK != ioctl(output_port, GPIO_IOCTL_WRITE_LOG0, NULL))
{
printf("Clearing pins2 to log 0 failed.\n");
_mqx_exit(-1);
}
}
else
{
printf("LED ON.\n");
/* set pin to 1 (fast) */
if (IO_OK != ioctl(output_port, GPIO_IOCTL_WRITE_LOG1, NULL))
{
printf("Setting pins2 to log 1 failed.\n");
_mqx_exit(-1);
}
}
_time_delay(100);
printf("%d\n",i);
}
_mqx_exit(-1);
}
/* EOF */